44 #include <boost/bind.hpp> 50 using namespace boost;
51 using namespace detail;
55 mrname(name), mrowner(tc)
86 OperationCallers::iterator it =
mmethods.find(name);
94 for(OperationCallers::iterator it =
mmethods.begin(); it !=
mmethods.end(); ++it)
95 it->second->setCaller( new_owner ? new_owner->
engine() : 0);
100 it->second->setOwner( new_owner );
105 return shared_from_this();
106 }
catch( boost::bad_weak_ptr& ) {
107 log(
Error) <<
"When using boost < 1.40.0 : You are not allowed to call requires() on a ServiceRequester that does not yet belong to a TaskContext or another ServiceRequester." <<
endlog();
108 log(
Error) <<
"Try to avoid using requires() in this case: omit it or use the service requester directly." <<
endlog();
109 log(
Error) <<
"OR: upgrade to boost 1.40.0, then this error will go away." <<
endlog();
110 throw std::runtime_error(
"Illegal use of requires()");
115 if (service_name ==
"this")
117 Requests::iterator it =
mrequests.find(service_name);
128 log(
Error) <<
"Could not add ServiceRequester " << obj->getRequestName() <<
": name already in use." <<
endlog();
141 if (!sp)
return false;
142 for (OperationCallers::iterator it =
mmethods.begin(); it !=
mmethods.end(); ++it) {
143 if ( !it->second->ready() ) {
144 if (sp->hasOperation( it->first )) {
145 it->second->setImplementation( sp->getLocalOperation( it->first ),
mrowner ?
mrowner->
engine() : 0 );
146 if ( it->second->ready() ) {
147 log(
Debug) <<
"Successfully set up OperationCaller " << it->first <<
endlog();
149 log(
Debug) <<
"OperationCaller "<< it->first <<
" has no caller set: using GlobalEngine."<<
endlog();
152 if (sp->hasMember( it->first )) {
153 it->second->setImplementationPart( sp->getOperation( it->first ),
mrowner ?
mrowner->
engine() : 0 );
154 if ( it->second->ready() ) {
155 log(
Debug) <<
"Successfully set up OperationCaller " << it->first <<
endlog();
157 log(
Debug) <<
"OperationCaller "<< it->first <<
" has no caller set: using GlobalEngine."<<
endlog();
181 for (OperationCallers::const_iterator it =
mmethods.begin(); it !=
mmethods.end(); ++it)
182 if ( !it->second->ready() ) {
183 log(
Debug) <<
"ServiceRequester: "<< it->first <<
" not set up." <<
endlog();
virtual const std::string & getName() const =0
RequesterNames getRequesterNames() const
OperationCallers mmethods
virtual bool ready() const
void setOwner(TaskContext *new_owner)
boost::shared_ptr< ServiceRequester > shared_ptr
virtual void disconnect()
Requests mrequests
the services we implement.
base::OperationCallerBaseInvoker * getOperationCaller(const std::string &name)
boost::shared_ptr< Service > shared_ptr
ServiceRequester(const std::string &name, TaskContext *owner=0)
Service::shared_ptr mprovider
OperationCallerNames getOperationCallerNames() const
ServiceRequester::shared_ptr requires()
std::vector< typename MapT::key_type > keys(const MapT &map)
virtual void disconnect()=0
virtual bool connectTo(Service::shared_ptr sp)
bool addServiceRequester(shared_ptr obj)
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
const ExecutionEngine * engine() const
static Logger::LogFunction endlog()
virtual ~ServiceRequester()
bool addOperationCaller(base::OperationCallerBaseInvoker &mbi)