CorbaDataObjectProxy.hpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef ORO_CORBA_DATAOBJECTPROXY_HPP
00041 #define ORO_CORBA_DATAOBJECTPROXY_HPP
00042
00043
00044 #include "../DataObjectInterfaces.hpp"
00045 #include "../DataSources.hpp"
00046 #include "OperationsC.h"
00047 #include "CorbaLib.hpp"
00048 #include "corba.h"
00049
00050 namespace RTT
00051 { namespace Corba {
00052
00053
00062 template<class T>
00063 class CorbaDataObjectProxy
00064 : public DataObjectInterface<T>
00065 {
00066 std::string name;
00067 AssignableExpression_var mec;
00068 public:
00076 CorbaDataObjectProxy(const std::string& _name, AssignableExpression_ptr ec )
00077 : name(_name), mec(AssignableExpression::_duplicate(ec) )
00078 {
00079 }
00080
00084 ~CorbaDataObjectProxy() {
00085 }
00086
00092 const std::string& getName() const { return name;}
00093
00094 void setName( const std::string& _name )
00095 {
00096 name = _name;
00097 }
00098
00102 typedef T DataType;
00103
00109 void Get( DataType& pull ) const {
00110 Logger::In in("CorbaDataObjectProxy::Get");
00111 CORBA::Any_var v;
00112 v = mec->get();
00113 ReferenceDataSource<T> rds(pull);
00114 rds.ref();
00115 if ( rds.updateBlob(ORO_CORBA_PROTOCOL_ID, &v.in() ) == false) {
00116 log(Error) << "Could not read remote value: wrong data type."<<endlog();
00117 return;
00118 }
00119 }
00120
00126 DataType Get() const { DataType p; this->Get(p); return p; }
00127
00133 void Set( const DataType& push ) {
00134
00135
00136
00137 ValueDataSource<T> vds(push);
00138 vds.ref();
00139 CORBA::Any_var toset = (CORBA::Any_ptr)vds.createBlob(ORO_CORBA_PROTOCOL_ID);
00140 mec->set( toset.in() );
00141 }
00142
00143 CorbaDataObjectProxy<DataType>* clone() const {
00144 return new CorbaDataObjectProxy<DataType>(name, mec.in());
00145 }
00146
00147 CorbaDataObjectProxy<DataType>* copy( std::map<const DataSourceBase*, DataSourceBase*>& ) const {
00148 return const_cast<CorbaDataObjectProxy<DataType>*>(this);
00149 }
00150
00151 };
00152 }}
00153
00154 #endif
00155