GenericTopicSubscriber.h
Go to the documentation of this file.
1/*
2* This file is part of ArmarX.
3*
4* ArmarX is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License version 2 as
6* published by the Free Software Foundation.
7*
8* ArmarX is distributed in the hope that it will be useful, but
9* WITHOUT ANY WARRANTY; without even the implied warranty of
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* GNU General Public License for more details.
12*
13* You should have received a copy of the GNU General Public License
14* along with this program. If not, see <http://www.gnu.org/licenses/>.
15*
16* @package ArmarX
17* @author Mirko Waechter( mirko.waechter at kit dot edu)
18* @date 2016
19* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20* GNU General Public License
21*/
22#pragma once
23
24#include <mutex>
25#include <queue>
26
27#include <Ice/Object.h>
28
30
31namespace armarx
32{
33
36
37 class GenericTopicSubscriber : public Ice::Blobject
38 {
39 public:
41 const std::string& topicName,
42 IceUtil::Time startTimestamp,
43 float maxFrequency = -1.0f);
44 void getData(std::queue<TopicUtil::TopicData>& data);
45
46 void
47 setTime(IceUtil::Time time)
48 {
49 startTimestamp = time;
50 }
51
52 // Blobject interface
53 public:
54 bool ice_invoke(const std::vector<Ice::Byte>& inParams,
55 std::vector<Ice::Byte>& outParams,
56 const Ice::Current& current) override;
57
58 private:
59 bool checkTimestamp(const std::string& operationName, const IceUtil::Time& timestamp);
60 std::string topicName;
61 std::queue<TopicUtil::TopicData> dataQueue;
62 std::mutex queueMutex;
64 IceUtil::Time startTimestamp;
65 float maxFrequency;
66 std::map<std::string, IceUtil::Time> functionCallTimestamps;
67 };
68
70
71
72} // namespace armarx
std::string timestamp()
void getData(std::queue< TopicUtil::TopicData > &data)
bool ice_invoke(const std::vector< Ice::Byte > &inParams, std::vector< Ice::Byte > &outParams, const Ice::Current &current) override
GenericTopicSubscriber(TopicRecorderComponentPtr recorder, const std::string &topicName, IceUtil::Time startTimestamp, float maxFrequency=-1.0f)
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< GenericTopicSubscriber > GenericTopicSubscriberPtr
IceInternal::Handle< TopicRecorderComponent > TopicRecorderComponentPtr