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 #include <Types.hpp>
00041 #include "OperationsI.h"
00042 #include "ExpressionProxy.hpp"
00043 #include <iostream>
00044
00045 #include <ace/String_Base.h>
00046
00047 using namespace std;
00048
00049 namespace RTT
00050 {namespace Corba
00051 {
00052
00053 ExpressionProxy::EMap ExpressionProxy::proxies;
00054 ExpressionProxy::DMap ExpressionProxy::dproxies;
00055
00056 ExpressionProxy::ExpressionProxy( ::RTT::Corba::Expression_ptr e)
00057 : mdata( ::RTT::Corba::Expression::_duplicate(e) )
00058 {
00059 try {
00060 CORBA::String_var nm = mdata->getType();
00061 }
00062 catch (CORBA::Exception &e) {
00063 Logger::log() <<Logger::Error << "CORBA exception raised when creating ExpressionProxy!" << Logger::nl;
00064 Logger::log() << e._info().c_str() << Logger::endl;
00065 }
00066 catch (...) {
00067 throw;
00068 }
00069 }
00070
00071 ExpressionProxy::shared_ptr ExpressionProxy::Create(::RTT::Corba::Expression_ptr t) {
00072 if ( CORBA::is_nil( t ) )
00073 return 0;
00074
00075
00076 for (EMap::iterator it = proxies.begin(); it != proxies.end(); ++it)
00077 if ( (it->first)->_is_equivalent( t ) )
00078 return proxies[t];
00079
00080
00081 ExpressionProxy* ctp = new ExpressionProxy( t );
00082 proxies[t] = ctp;
00083 return ctp;
00084 }
00085
00086 DataSourceBase::shared_ptr ExpressionProxy::CreateDataSource(::RTT::Corba::Expression_ptr t) {
00087 if ( CORBA::is_nil( t ) )
00088 return 0;
00089
00090
00091 for (DMap::iterator it = dproxies.begin(); it != dproxies.end(); ++it)
00092 if ( (it->first)->_is_equivalent( t ) )
00093 return dproxies[t];
00094
00095
00096 CORBA::String_var tn = t->getTypeName();
00097 TypeInfo* builder = TypeInfoRepository::Instance()->type( tn.in() );
00098 DataSourceBase* dsb;
00099 if ( builder && builder->getProtocol(ORO_CORBA_PROTOCOL_ID) )
00100 dsb = builder->getProtocol(ORO_CORBA_PROTOCOL_ID)->proxy( t );
00101 else
00102 return Create( t );
00103
00104 dproxies[t] = dsb;
00105 return dsb;
00106 }
00107
00108
00109
00110
00111
00112
00113
00114 }}
00115