DatafieldFilter.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package
19 * @author
20 * @date
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
25#pragma once
26
27#include <deque>
28#include <mutex>
29
30#include <ArmarXCore/interface/observers/ObserverInterface.h>
32
33namespace armarx
34{
35 const Ice::Current staticIceCurrent = Ice::emptyCurrent;
36 using TimeVariantBaseMap = std::deque<std::pair<long, VariantBasePtr>>;
37
38 /**
39 * @class DatafieldFilter
40 * @ingroup ObserverFilters
41 * @brief The DatafieldFilter class is the base class for all filters
42 * and filter implementation should derive from this class.
43 * For usage explanation see \ref Observers-Filters.
44 */
45 class DatafieldFilter : virtual public DatafieldFilterBase
46 {
47 public:
49 DatafieldFilter(DatafieldFilter const& filter);
50
51 // DatafieldFilterBase interface
52
53 /**
54 * @brief Adds the given value to the data map, erases old values if maximum size was reached,
55 * and calculates the new filtered value.
56 * @param timestamp Timestamp at which the data value was taken.
57 * @param value The new data value.
58 */
59 void update(Ice::Long timestamp,
60 const VariantBasePtr& value,
61 const Ice::Current& c = Ice::emptyCurrent) override;
62
63 /**
64 * @brief Retrieves the current, filtered value.
65 * Triggers calculates if if filtered value pointer is empty.
66 */
67 VariantBasePtr getValue(const Ice::Current& c = Ice::emptyCurrent) const override;
68
69 /**
70 * @brief Checks whether the given type is supported.
71 * @param variantType
72 * @return
73 */
74 bool checkTypeSupport(VariantTypeId variantType,
75 const Ice::Current& c = Ice::emptyCurrent) const override;
76 armarx::StringFloatDictionary
77 getProperties(const Ice::Current& c = Ice::emptyCurrent) const override;
78 void setProperties(const armarx::StringFloatDictionary& newValues,
79 const Ice::Current& c = Ice::emptyCurrent) override;
81
82 protected:
84 mutable std::mutex historyMutex;
85 };
86
87} // namespace armarx
std::string timestamp()
constexpr T c
void update(Ice::Long timestamp, const VariantBasePtr &value, const Ice::Current &c=Ice::emptyCurrent) override
Adds the given value to the data map, erases old values if maximum size was reached,...
const TimeVariantBaseMap & getDataHistory() const
VariantBasePtr getValue(const Ice::Current &c=Ice::emptyCurrent) const override
Retrieves the current, filtered value.
TimeVariantBaseMap dataHistory
armarx::StringFloatDictionary getProperties(const Ice::Current &c=Ice::emptyCurrent) const override
void setProperties(const armarx::StringFloatDictionary &newValues, const Ice::Current &c=Ice::emptyCurrent) override
bool checkTypeSupport(VariantTypeId variantType, const Ice::Current &c=Ice::emptyCurrent) const override
Checks whether the given type is supported.
This file offers overloads of toIce() and fromIce() functions for STL container types.
const Ice::Current staticIceCurrent
std::deque< std::pair< long, VariantBasePtr > > TimeVariantBaseMap
Ice::Int VariantTypeId
Definition Variant.h:43
::IceInternal::Handle<::armarx::VariantBase > VariantBasePtr