Orocos Real-Time Toolkit  2.8.3
RemotePorts.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Thu Oct 22 11:59:07 CEST 2009 RemotePorts.hpp
3 
4  RemotePorts.hpp - description
5  -------------------
6  begin : Thu October 22 2009
7  copyright : (C) 2009 Peter Soetens
8  email : peter@thesourcworks.com
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 
39 #ifndef RTT_CORBA_REMOTE_PORTS_HPP
40 #define RTT_CORBA_REMOTE_PORTS_HPP
41 
42 #include "../../base/PortInterface.hpp"
43 #include "../../base/ChannelElement.hpp"
44 #include "../../InputPort.hpp"
45 #include "../../OutputPort.hpp"
46 #include "DataFlowI.h"
47 #include <cassert>
48 
49 namespace RTT {
50  namespace corba {
61  template<typename PortClass>
62  class RemotePort : public PortClass
63  {
64  protected:
66  CDataFlowInterface_var dataflow;
67  PortableServer::POA_var mpoa;
68 
69  bool connectionAdded( base::ChannelElementBase::shared_ptr channel, ConnPolicy const& policy ) { assert(false && "Can/Should not add connection to remote port object !");return false; }
70 
71  public:
72  RemotePort(types::TypeInfo const* type_info,
73  CDataFlowInterface_ptr dataflow,
74  std::string const& name,
75  PortableServer::POA_ptr poa);
76 
77  PortableServer::POA_ptr _default_POA();
78  CDataFlowInterface_ptr getDataFlowInterface() const;
79 
80  internal::ConnID* getPortID() const;
81 
82  types::TypeInfo const* getTypeInfo() const;
83  int serverProtocol() const;
84  bool connected() const;
85  bool createStream( const ConnPolicy& policy );
86  virtual bool addConnection(internal::ConnID* port_id, base::ChannelElementBase::shared_ptr channel_input, ConnPolicy const& policy);
87  virtual void disconnect();
88  using PortClass::disconnect;
89  };
90 
97  : public RemotePort<base::OutputPortInterface>
98  {
99  public:
101  CDataFlowInterface_ptr dataflow,
102  std::string const& name,
103  PortableServer::POA_ptr poa);
104 
105  bool keepsLastWrittenValue() const;
106  void keepLastWrittenValue(bool new_flag);
107 
108  virtual bool disconnect(PortInterface* port);
110 
111  bool createConnection( base::InputPortInterface& sink, ConnPolicy const& policy );
113 
114  virtual base::DataSourceBase::shared_ptr getDataSource() const;
115 
116  base::PortInterface* clone() const;
117  base::PortInterface* antiClone() const;
118  };
119 
127  : public RemotePort<base::InputPortInterface>
128  {
129  typedef std::map<base::ChannelElementBase*,RTT::corba::CChannelElement_var> ChannelMap;
130  ChannelMap channel_map;
131  protected:
139  virtual bool addConnection(internal::ConnID* port_id, base::ChannelElementBase::shared_ptr channel_input, ConnPolicy const& policy) { return true; }
140  public:
142  CDataFlowInterface_ptr dataflow,
143  std::string const& name,
144  PortableServer::POA_ptr poa);
145 
158  base::ChannelElementBase::shared_ptr buildRemoteChannelOutput(
159  base::OutputPortInterface& output_port,
160  types::TypeInfo const* type,
161  base::InputPortInterface& reader_,
162  ConnPolicy const& policy);
163 
164  base::PortInterface* clone() const;
165  base::PortInterface* antiClone() const;
166 
167  virtual bool disconnect(PortInterface* port);
169 
170  base::DataSourceBase* getDataSource();
171 
179  virtual bool channelReady(base::ChannelElementBase::shared_ptr channel, ConnPolicy const& policy);
180  };
181  }
182 }
183 
184 #endif
185 
virtual bool addConnection(internal::ConnID *port_id, base::ChannelElementBase::shared_ptr channel_input, ConnPolicy const &policy)
The ConnectionFactory calls this.
The base class of the InputPort.
bool createStream(const ConnPolicy &policy)
Definition: RemotePorts.cpp:91
The base class for all internal data representations.
CDataFlowInterface_var dataflow
Definition: RemotePorts.hpp:66
types::TypeInfo const * type_info
Definition: RemotePorts.hpp:65
bool connectionAdded(base::ChannelElementBase::shared_ptr channel, ConnPolicy const &policy)
Definition: RemotePorts.hpp:69
bool connected() const
Definition: RemotePorts.cpp:71
virtual bool addConnection(internal::ConnID *port_id, base::ChannelElementBase::shared_ptr channel_input, ConnPolicy const &policy)
Definition: RemotePorts.cpp:98
A connection policy object describes how a given connection should behave.
Definition: ConnPolicy.hpp:92
The base class of each OutputPort.
types::TypeInfo const * getTypeInfo() const
Definition: RemotePorts.cpp:67
virtual void disconnect()
Definition: RemotePorts.cpp:76
Proxy for a remote output port.
Definition: RemotePorts.hpp:96
RemotePort(types::TypeInfo const *type_info, CDataFlowInterface_ptr dataflow, std::string const &name, PortableServer::POA_ptr poa)
Definition: RemotePorts.cpp:54
Contains the common CORBA management code for proxy port objects representing ports available through...
Definition: RemotePorts.hpp:62
PortableServer::POA_ptr _default_POA()
Definition: RemotePorts.cpp:83
bool createConnection(InputPortInterface &sink)
Connects this write port to the given read port, using as policy the default policy of the sink port...
A class for representing a user type, and which can build instances of that type. ...
Definition: TypeInfo.hpp:66
internal::ConnID * getPortID() const
Definition: RemotePorts.cpp:87
PortableServer::POA_var mpoa
Definition: RemotePorts.hpp:67
CDataFlowInterface_ptr getDataFlowInterface() const
Definition: RemotePorts.cpp:64
boost::intrusive_ptr< ChannelElementBase > shared_ptr
int serverProtocol() const
Definition: RemotePorts.cpp:69
This class is used in places where a permanent representation of a reference to a connection is neede...
Definition: ConnID.hpp:58
boost::intrusive_ptr< DataSourceBase > shared_ptr
Use this type to store a pointer to a DataSourceBase.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:51
The base class of every data flow port.
Proxy for a remote input port.