Orocos Real-Time Toolkit  2.9.0
OperationCallerProxy.hpp
Go to the documentation of this file.
1 #include "ServiceRequesterC.h"
2 #include <string>
3 #include "../../base/OperationCallerBaseInvoker.hpp"
5 
6 namespace RTT
7 {
8  namespace corba {
16  {
17  std::string mname;
18  CServiceRequester_var msrq;
19  OperationCallerProxy(const std::string& opname, CServiceRequester_ptr srq)
20  : mname(opname), msrq(srq) {}
21 
22  virtual bool ready() const {
23  return msrq->callerReady( mname.c_str() );
24  }
25 
26  virtual void disconnect() {
27  msrq->disconnectCaller( mname.c_str() );
28  }
29 
30  virtual bool setImplementation(boost::shared_ptr<base::DisposableInterface> impl, ExecutionEngine* caller = 0) {
31  // impossible for remote operation callers.
32  return false;
33  }
34 
36  // todo: forward to remote side.
37  // if orp is local, we need to provide the remote side with a service to this operation part.
38  // if orp is remote, we need to pass on the service
39  CorbaOperationCallerFactory* cocf = dynamic_cast<CorbaOperationCallerFactory*>(orp);
40  if (cocf) {
41  // good: it's already a remote service, just pass on the misery
42  return msrq->connectCallerTo(mname.c_str(), cocf->getService() );
43  } else {
44  // bad: we need to create or lookup
45  log(Error) <<"Can't connect an operation caller proxy directly to a local service."<<endlog();
46  log(Error) <<"Use CServiceRequester::connectTo() or CServiceRequester::connectCallerTo(). "<<endlog();
47  }
48  return false;
49  }
50 
51  virtual void setCaller(ExecutionEngine* caller) {
52  // ignored.
53  }
54 
55  virtual const std::string& getName() const {
56  return mname;
57  }
58  };
59  }
60 }
corba::CService_ptr getService()
Returns the remote service that hosts this part.
virtual bool setImplementation(boost::shared_ptr< base::DisposableInterface > impl, ExecutionEngine *caller=0)
Sets a new implementation for this method.
An invoker can be given an implementation and is identified by a name.
virtual void disconnect()
Disconnects this caller from the operation it was connected to.
A local factory for creating remote Corba methods.
virtual void setCaller(ExecutionEngine *caller)
Sets the caller of this method after the implementation was set.
An execution engine serialises (executes one after the other) the execution of all commands...
virtual const std::string & getName() const
Returns the name of this method instance.
This class defines the interface for creating operation objects without using C++ templates...
OperationCallerProxy(const std::string &opname, CServiceRequester_ptr srq)
Mirrors a remote operation caller in a ServiceRequestor.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:52
virtual bool setImplementationPart(OperationInterfacePart *orp, ExecutionEngine *caller=0)
Sets a new implementation for this method by using a service part.
virtual bool ready() const
Returns true if this OperationCaller has received a correct implementation.