OrocosComponentLibrary  2.8.3
datasender.hpp
1 /***************************************************************************
2 
3  datasender.hpp - description
4  -------------------
5  begin : Wed August 9 2006
6  copyright : (C) 2006 Bas Kemper
7  (C) 2007 Ruben Smits //Changed subscription structure
8  email : kst@baskemper.be
9  first dot last at mech dot kuleuven dot be
10 
11  ***************************************************************************
12  * This library is free software; you can redistribute it and/or *
13  * modify it under the terms of the GNU Lesser General Public *
14  * License as published by the Free Software Foundation; either *
15  * version 2.1 of the License, or (at your option) any later version. *
16  * *
17  * This library is distributed in the hope that it will be useful, *
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
20  * Lesser General Public License for more details. *
21  * *
22  * You should have received a copy of the GNU Lesser General Public *
23  * License along with this library; if not, write to the Free Software *
24  * Foundation, Inc., 59 Temple Place, *
25  * Suite 330, Boston, MA 02111-1307 USA *
26  * *
27  ***************************************************************************/
28 
29 #ifndef ORO_COMP_TCP_DATASENDER
30 #define ORO_COMP_TCP_DATASENDER
31 
32 #include <rtt/Activity.hpp>
33 #include <rtt/os/Mutex.hpp>
34 #include <rtt/Property.hpp>
35 
36 using RTT::os::Mutex;
37 using RTT::base::PropertyBase;
38 using RTT::Property;
39 using RTT::PropertyBag;
40 
41 namespace RTT
42 {
43  class SocketMarshaller;
44 }
45 namespace OCL{
46 
47  namespace TCP{
48  using namespace RTT;
49  class TcpReportingInterpreter;
50  class Socket;
51 
59  class Datasender
60  : public RTT::Activity
61  {
62  private:
63  os::Mutex lock;
64  TcpReportingInterpreter* interpreter;
65  void checkbag(const PropertyBag &v);
66  void writeOut(base::PropertyBase* v);
67  void writeOut(const PropertyBag &v);
68  Socket* os;
69  OCL::TcpReporting* reporter;
70  unsigned long long limit;
71  unsigned long long curframe;
72  bool silenced;
73  RTT::SocketMarshaller* marshaller;
74  std::vector<std::string> subscriptions;
75 
76  public:
77  Datasender(RTT::SocketMarshaller* marshaller, Socket* os);
78  virtual ~Datasender();
79 
84  bool isValid() const;
85 
89  void setLimit(unsigned long long newlimit);
90 
94  void serialize(const PropertyBag &v);
95 
99  RTT::SocketMarshaller* getMarshaller() const;
100 
101  bool addSubscription(const std::string name );
102  bool removeSubscription( const std::string& name );
103 
107  void listSubscriptions();
108 
112  Socket& getSocket() const;
113 
117  virtual void loop();
118 
122  virtual bool breakloop();
123 
127  void silence(bool newstate);
128 
132  void remove();
133  };
134 }
135 }
136 #endif
This class manages the connection with one single client.
Definition: datasender.hpp:59
A component which writes data reports to a tcp/ip socket.
Reads a line from the client and interprete it.
Definition: command.hpp:45
marsh::MarshallInterface which sends data to multiple sockets.
The Orocos Component Library.
Definition: Component.hpp:43
Definition: Category.hpp:10