Orocos Real-Time Toolkit  2.9.0
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;
90  };
91 
98  : public RemotePort<base::OutputPortInterface>
99  {
100  public:
102  CDataFlowInterface_ptr dataflow,
103  std::string const& name,
104  PortableServer::POA_ptr poa);
105 
106  bool keepsLastWrittenValue() const;
107  void keepLastWrittenValue(bool new_flag);
108 
109  virtual bool disconnect(PortInterface* port);
111 
112  bool createConnection( base::InputPortInterface& sink, ConnPolicy const& policy );
114 
115  virtual base::DataSourceBase::shared_ptr getDataSource() const;
116 
117  base::PortInterface* clone() const;
118  base::PortInterface* antiClone() const;
119  };
120 
128  : public RemotePort<base::InputPortInterface>
129  {
130  protected:
139 
140  public:
142  CDataFlowInterface_ptr dataflow,
143  std::string const& name,
144  PortableServer::POA_ptr poa);
145 
146  void clear();
147 
160  base::ChannelElementBase::shared_ptr buildRemoteChannelOutput(
161  base::OutputPortInterface& output_port,
162  types::TypeInfo const* type,
163  base::InputPortInterface& reader_,
164  ConnPolicy const& policy);
165 
170  bool createConnection( internal::SharedConnectionBase::shared_ptr shared_connection, ConnPolicy const& policy = ConnPolicy() );
172 
173  base::PortInterface* clone() const;
174  base::PortInterface* antiClone() const;
175 
176  virtual bool disconnect(PortInterface* port);
178 
179  base::DataSourceBase* getDataSource();
180  };
181  }
182 }
183 
184 #endif
185 
The base class of the InputPort.
virtual bool createConnection(internal::SharedConnectionBase::shared_ptr shared_connection, ConnPolicy const &policy=ConnPolicy())
Connects the port to an existing shared connection instance.
virtual bool addConnection(internal::ConnID *, base::ChannelElementBase::shared_ptr, ConnPolicy const &)
The ConnectionFactory calls this.
bool createStream(const ConnPolicy &policy)
Definition: RemotePorts.cpp:91
boost::intrusive_ptr< SharedConnectionBase > shared_ptr
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:107
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:97
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...
base::ChannelElementBase * getEndpoint() const
A class for representing a user type, and which can build instances of that type. ...
Definition: TypeInfo.hpp:67
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:52
In the data flow implementation, a channel is created by chaining ChannelElementBase objects...
The base class of every data flow port.
Proxy for a remote input port.