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 "OperationsI.h"
00041 #include "CommandProxy.hpp"
00042 #include "ConditionInterface.hpp"
00043
00044 #include <ace/String_Base.h>
00045
00046 using namespace std;
00047
00048 namespace RTT
00049 {namespace Corba
00050 {
00051
00052 CommandProxy::CommandProxy( ::RTT::Corba::Command_ptr e)
00053 : mdata( ::RTT::Corba::Command::_duplicate(e) )
00054 {
00055 try {
00056 mdata->reset();
00057 }
00058 catch (CORBA::Exception &e) {
00059 Logger::log() <<Logger::Error << "CORBA exception raised when creating CommandProxy!" << Logger::nl;
00060 Logger::log() << e._info().c_str() << Logger::endl;
00061 }
00062 catch (...) {
00063 throw;
00064 }
00065 }
00066
00067 CommandProxy::~CommandProxy()
00068 {
00069 }
00070
00071 namespace {
00072 struct ValidCondition
00073 : public ConditionInterface
00074 {
00075 ::RTT::Corba::Command_var mserver;
00076
00077 ValidCondition( ::RTT::Corba::Command_ptr server )
00078 : mserver(::RTT::Corba::Command::_duplicate(server) )
00079 {}
00080 bool evaluate()
00081 {
00082 return mserver->done();
00083 }
00084
00085 ValidCondition* clone() const
00086 {
00087 return new ValidCondition( mserver.in() );
00088 }
00089
00090 ValidCondition* copy( std::map<const DataSourceBase*, DataSourceBase*>& alreadyCloned ) const {
00091 return this->clone();
00092 }
00093 };
00094 }
00095
00096 ConditionInterface* CommandProxy::createCondition() const {
00097 return new ValidCondition( mdata.in() );
00098 }
00099
00100
00101 CommandProxy* CommandProxy::Create(::RTT::Corba::Command_ptr t) {
00102 if ( CORBA::is_nil( t ) )
00103 return 0;
00104
00105
00106 CommandProxy* ctp = new CommandProxy( t );
00107 return ctp;
00108 }
00109
00110 Corba::Command_ptr CommandProxy::server() const
00111 {
00112 return Corba::Command::_duplicate( mdata.in() );
00113 }
00114
00115 }}
00116