Orocos Real-Time Toolkit  2.8.3
CorbaTemplateProtocol.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: FMTC Tue Mar 11 21:49:24 CET 2008 CorbaTemplateProtocol.hpp
3 
4  CorbaTemplateProtocol.hpp - description
5  -------------------
6  begin : Tue March 11 2008
7  copyright : (C) 2008 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 
39 #ifndef ORO_CORBA_TEMPATE_PROTOCOL_HPP
40 #define ORO_CORBA_TEMPATE_PROTOCOL_HPP
41 
42 #include "CorbaTypeTransporter.hpp"
43 #include "RemoteChannelElement.hpp"
44 #include "../../types/Types.hpp"
45 #include "../../InputPort.hpp"
46 #include "../../OutputPort.hpp"
47 #include "ServiceC.h"
48 #include "DataFlowI.h"
49 #include "../../internal/ConnID.hpp"
50 #include "DataSourceProxy.hpp"
51 
52 namespace RTT
53 { namespace corba
54  {
58  template<class T>
60  : public CorbaTypeTransporter
61  {
62  public:
66  typedef T UserType;
71 
72  CRemoteChannelElement_i* createChannelElement_i(DataFlowInterface* sender,PortableServer::POA_ptr poa, bool is_pull) const
73  { return new RemoteChannelElement<T>(*this, sender, poa, is_pull); }
74 
78  virtual CORBA::Any* createAny( base::DataSourceBase::shared_ptr source) const
79  {
81  if ( d ) {
82  if ( !d->evaluate() ) return 0;
84  }
85 
86  return 0;
87  }
88 
92  virtual bool updateAny( base::DataSourceBase::shared_ptr source, CORBA::Any& any) const
93  {
95  if ( d ) {
96  if ( !d->evaluate() ) return false;
98  }
99 
100  return false;
101  }
102 
103  virtual base::DataSourceBase::shared_ptr createDataSource(const CORBA::Any* any) const
104  {
106  if ( updateFromAny(any, result) )
107  return result;
109  }
110 
114  virtual bool updateFromAny(const CORBA::Any* any, base::DataSourceBase::shared_ptr target) const
115  {
117  if ( ad ) {
118  if ( AnyConversion<PropertyType>::update(*any, ad->set() ) ) {
119  ad->updated();
120  return true;
121  }
122  }
123 
124  return false;
125  }
126 
127  virtual base::DataSourceBase::shared_ptr createPropertyDataSource(CService_ptr serv, const std::string& vname) {
129  }
130 
131  virtual base::DataSourceBase::shared_ptr createAttributeDataSource(CService_ptr serv, const std::string& vname) {
132  if ( serv->isAttributeAssignable( vname.c_str() ) ) {
133  return base::DataSourceBase::shared_ptr( new ValueDataSourceProxy<PropertyType>( serv, vname, false) );
134  }
135  else {
136  return base::DataSourceBase::shared_ptr( new DataSourceProxy<PropertyType>( serv, vname, false ) );
137  }
138  }
139  };
140 }
141 }
142 
143 #endif
static bool updateAny(StdType tp, CORBA::Any &any)
Updates an CORBA::Any object from of a C++/IDL type.
This class converts a given application-specific type to a CORBA::Any object and vice versa...
virtual CORBA::Any * createAny(base::DataSourceBase::shared_ptr source) const
Create an transportable object for a protocol which contains the value of source. ...
The Interface of a TaskContext which exposes its data-flow ports.
virtual void set(param_t t)=0
Set this DataSource with a value.
For each transportable type T, specify the conversion functions.
Property< T >::DataSourceType PropertyType
When Properties of T are constructed, they are non-const, non-reference.
virtual base::DataSourceBase::shared_ptr createAttributeDataSource(CService_ptr serv, const std::string &vname)
Base class for CORBA channel servers.
Definition: DataFlowI.h:69
Mirrors a remote assignable value datasource.
Implements the CRemoteChannelElement of the CORBA IDL interface.
virtual const_reference_t rvalue() const =0
Get a const reference to the value of this DataSource.
boost::intrusive_ptr< DataSource< T > > shared_ptr
Definition: DataSource.hpp:115
boost::intrusive_ptr< AssignableDataSource< T > > shared_ptr
Use this type to store a pointer to an AssignableDataSource.
Definition: DataSource.hpp:198
T UserType
The given T parameter is the type for reading DataSources.
static AssignableDataSource< T > * narrow(base::DataSourceBase *db)
This method narrows a base::DataSourceBase to a typeded AssignableDataSource, possibly returning a ne...
Definition: DataSource.inl:72
static DataSource< T > * narrow(base::DataSourceBase *db)
This method narrows a base::DataSourceBase to a typeded DataSource, possibly returning a new object...
Definition: DataSource.inl:66
virtual bool updateAny(base::DataSourceBase::shared_ptr source, CORBA::Any &any) const
Update a transportable object for a protocol which contains the value of source.
static CORBA::Any_ptr createAny(StdType tp)
Creates an CORBA::Any object out of a C++/IDL type.
CRemoteChannelElement_i * createChannelElement_i(DataFlowInterface *sender, PortableServer::POA_ptr poa, bool is_pull) const
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
virtual bool evaluate() const
Force an evaluation of the DataSourceBase.
Definition: DataSource.inl:52
virtual base::DataSourceBase::shared_ptr createDataSource(const CORBA::Any *any) const
Create a Data Source from an any.
A simple, yet very useful DataSource, which keeps a value, and returns it in its get() method...
Definition: DataSources.hpp:60
Mirrors a remote DataSource.
virtual void updated()
In case the internal::DataSource returns a &#39;reference&#39; type, call this method to notify it that the d...
Definition: DataSource.cpp:112
value_t DataSourceType
Definition: Property.hpp:89
Extends the TypeTransporter in order to allow the creation of channel elements or output halves for a...
virtual base::DataSourceBase::shared_ptr createPropertyDataSource(CService_ptr serv, const std::string &vname)
Create a data source for an attribute or property.
virtual bool updateFromAny(const CORBA::Any *any, base::DataSourceBase::shared_ptr target) const
Update target with the contents of any which is an object of a protocol.