Orocos Real-Time Toolkit  2.8.3
DataFlowI.h
Go to the documentation of this file.
1 /***************************************************************************
2  tag: FMTC do nov 2 13:06:20 CET 2006 DataFlowI.h
3 
4  DataFlowI.h - description
5  -------------------
6  begin : do november 02 2006
7  copyright : (C) 2006 FMTC
8  email : peter.soetens@fmtc.be
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU General Public *
13  * License as published by the Free Software Foundation; *
14  * version 2 of the License. *
15  * *
16  * As a special exception, you may use this file as part of a free *
17  * software library without restriction. Specifically, if other files *
18  * instantiate templates or use macros or inline functions from this *
19  * file, or you compile this file and link it with other files to *
20  * produce an executable, this file does not by itself cause the *
21  * resulting executable to be covered by the GNU General Public *
22  * License. This exception does not however invalidate any other *
23  * reasons why the executable file might be covered by the GNU General *
24  * Public License. *
25  * *
26  * This library is distributed in the hope that it will be useful, *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29  * Lesser General Public License for more details. *
30  * *
31  * You should have received a copy of the GNU General Public *
32  * License along with this library; if not, write to the Free Software *
33  * Foundation, Inc., 59 Temple Place, *
34  * Suite 330, Boston, MA 02111-1307 USA *
35  * *
36  ***************************************************************************/
37 
38 #ifndef DATAFLOWI_H_
39 #define DATAFLOWI_H_
40 
41 #include "corba.h"
42 #ifdef CORBA_IS_TAO
43 #include "DataFlowS.h"
44 #else
45 #include "DataFlowC.h"
46 #endif
47 #include "CorbaConversion.hpp"
48 #include "../../base/ChannelElement.hpp"
49 #include "../../internal/DataSources.hpp"
50 #include "CorbaTypeTransporter.hpp"
51 #include <list>
52 #include <rtt/os/Mutex.hpp>
53 
54 #if !defined (ACE_LACKS_PRAGMA_ONCE)
55 #pragma once
56 #endif /* ACE_LACKS_PRAGMA_ONCE */
57 
58 
59 namespace RTT {
60 
61  namespace corba {
62  class CDataFlowInterface_i;
63 
69  class RTT_CORBA_API CRemoteChannelElement_i
70  : public POA_RTT::corba::CRemoteChannelElement
71  , public virtual PortableServer::RefCountServantBase
72  {
73  protected:
74  CRemoteChannelElement_var remote_side;
76  PortableServer::POA_var mpoa;
78 
79  public:
80  // standard constructor
82  PortableServer::POA_ptr poa);
83  virtual ~CRemoteChannelElement_i();
84 
85  virtual RTT::corba::CRemoteChannelElement_ptr activate_this() {
86  PortableServer::ObjectId_var oid = mpoa->activate_object(this); // ref count=2
87  _remove_ref(); // ref count=1
88  return _this();
89  }
90 
91  virtual void transferSamples() = 0;
92 
94  mdataflow = dataflow;
95  }
96 
97  PortableServer::POA_ptr _default_POA();
98 
99  void setRemoteSide(CRemoteChannelElement_ptr remote) ACE_THROW_SPEC ((
100  CORBA::SystemException
101  ));
102  };
103 
111  class RTT_CORBA_API CDataFlowInterface_i
112  : public virtual POA_RTT::corba::CDataFlowInterface
113  {
114  DataFlowInterface* mdf;
115  PortableServer::POA_var mpoa;
116 
120  struct ServantInfo
121  {
122  RTT::corba::CDataFlowInterface_var objref;
124  DataFlowInterface* getDataFlowInterface() const { return servant->getDataFlowInterface(); }
125  ServantInfo(CDataFlowInterface_var objref, CDataFlowInterface_i* servant)
126  : objref(objref), servant(servant) {}
127  };
128  typedef std::list<ServantInfo> ServantMap;
129  static ServantMap s_servant_map;
130 
131  typedef std::list<
132  std::pair<RTT::corba::CChannelElement_var, base::ChannelElementBase::shared_ptr>
133  > ChannelList;
134  ChannelList channel_list;
135  // Lock that should be taken before access to channel_list
136  RTT::os::Mutex channel_list_mtx;
137  public:
138  // standard constructor
139  CDataFlowInterface_i(DataFlowInterface* interface, PortableServer::POA_ptr poa);
140  virtual ~CDataFlowInterface_i();
141 
142  DataFlowInterface* getDataFlowInterface() const;
143 
144  static void registerServant(CDataFlowInterface_ptr objref, CDataFlowInterface_i* servant);
145  static void deregisterServant(DataFlowInterface* obj);
146  static void clearServants();
147  static DataFlowInterface* getLocalInterface(CDataFlowInterface_ptr objref);
148 
150  void deregisterChannel(CChannelElement_ptr channel);
151 
156  static CDataFlowInterface_ptr getRemoteInterface(DataFlowInterface* dfi, PortableServer::POA_ptr poa);
157 
158  virtual RTT::corba::CDataFlowInterface_ptr activate_this() {
159  PortableServer::ObjectId_var oid = mpoa->activate_object(this); // ref count=2
160  //_remove_ref(); // ref count=1
161  return _this();
162  }
163 
164  PortableServer::POA_ptr _default_POA();
165 
166  // methods corresponding to defined IDL attributes and operations
168  CORBA::SystemException
169  ));
171  CORBA::SystemException
172  ));
173  RTT::corba::CPortType getPortType(const char* port_name) ACE_THROW_SPEC ((
174  CORBA::SystemException
176  ));
177  char* getDataType(const char* port_name) ACE_THROW_SPEC ((
178  CORBA::SystemException
180  ));
181  ::CORBA::Boolean isConnected(const char* port_name) ACE_THROW_SPEC ((
182  CORBA::SystemException
184  ));
185  ::CORBA::Boolean channelReady(const char* port_name, RTT::corba::CChannelElement_ptr channel, RTT::corba::CConnPolicy const& policy) ACE_THROW_SPEC ((
186  CORBA::SystemException
188  ));
189  void disconnectPort(const char* port_name) ACE_THROW_SPEC ((
190  CORBA::SystemException
192  ));
193 
194  CChannelElement_ptr buildChannelOutput(const char* reader_port, RTT::corba::CConnPolicy& policy) ACE_THROW_SPEC ((
195  CORBA::SystemException
198  ));
199  CChannelElement_ptr buildChannelInput(const char* writer_port, RTT::corba::CConnPolicy& policy) ACE_THROW_SPEC ((
200  CORBA::SystemException
203  ));
204 
205  ::CORBA::Boolean createConnection( const char* writer_port,
206  CDataFlowInterface_ptr reader_interface,
207  const char* reader_port,
209  CORBA::SystemException
211  ));
212  bool removeConnection( const char* writer_port,
213  CDataFlowInterface_ptr reader_interface,
214  const char* reader_port) ACE_THROW_SPEC ((
215  CORBA::SystemException
217  ));
218 
219  ::CORBA::Boolean createStream( const char* port,
221  CORBA::SystemException
223  ));
224  void removeStream( const char* port, const char* stream_name) ACE_THROW_SPEC ((
225  CORBA::SystemException
227  ));
228  };
229  }
230 }
231 
232 
233 #endif /* DATAFLOWI_H_ */
234 
The Interface of a TaskContext which exposes its data-flow ports.
Emitted when information is requested on a port that does not exist.
Definition: DataFlow.idl:97
RTT::corba::CorbaTypeTransporter const & transport
Definition: DataFlowI.h:75
Base class for CORBA channel servers.
Definition: DataFlowI.h:69
sequence< CPortDescription > CPortDescriptions
Definition: DataFlow.idl:122
Emitted during connections, when there is no CORBA transport defined for the data type of the given p...
Definition: DataFlow.idl:101
DataFlowInterface * getDataFlowInterface() const
Definition: DataFlowI.cpp:78
#define ACE_THROW_SPEC(x)
Definition: corba.h:67
CDataFlowInterface_i * mdataflow
Definition: DataFlowI.h:77
virtual RTT::corba::CRemoteChannelElement_ptr activate_this()
Definition: DataFlowI.h:85
CRemoteChannelElement_var remote_side
Definition: DataFlowI.h:74
sequence< string > CPortNames
Definition: DataFlow.idl:121
An object oriented wrapper around a non recursive mutex.
Definition: Mutex.hpp:82
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:51
virtual RTT::corba::CDataFlowInterface_ptr activate_this()
Definition: DataFlowI.h:158
Represents a remote data flow interface.
Definition: DataFlowI.h:111
PortableServer::POA_var mpoa
Definition: DataFlowI.h:76
Extends the TypeTransporter in order to allow the creation of channel elements or output halves for a...
void setCDataFlowInterface(CDataFlowInterface_i *dataflow)
Definition: DataFlowI.h:93