46 using namespace detail;
48 using namespace boost;
53 owner->
provides()->addService( ret );
83 log(
Error) <<
"Could not add Service " << obj->getName() <<
": name already in use." <<endlog();
89 me = shared_from_this();
90 }
catch ( boost::bad_weak_ptr& bw ) {
114 return shared_from_this();
115 }
catch( boost::bad_weak_ptr& ) {
116 log(
Error) <<
"When using boost < 1.40.0 : You are not allowed to call provides() on a Service that does not yet belong to a TaskContext or another Service (for example in a constructor)." << endlog();
117 log(
Error) <<
"Try to avoid using provides() in this case: omit it or use the service directly." <<endlog();
118 throw std::runtime_error(
"Illegal use of provides()");
123 if (service_name ==
"this")
128 sp = boost::make_shared<Service>(service_name,
mowner);
133 me = shared_from_this();
134 }
catch ( boost::bad_weak_ptr& bw ) {
143 Services::iterator it =
services.find(service_name);
155 log(
Warning) <<
"No such operation in service '"<<
getName() <<
"': "<< name <<endlog();
180 if (service_name ==
"this")
189 log(
Error) <<
"Failed to add Operation: '"<< op.
getName() <<
"' has no name." <<endlog();
194 log(
Error) <<
"Failed to add Operation: '"<< op.
getName() <<
"' is not ready: not bound to a function." <<endlog();
198 log(
Warning) <<
"While adding Operation: '"<< op.
getName() <<
"': replacing previously added operation." <<endlog();
214 return boost::shared_ptr<base::DisposableInterface>();
263 it->second->setOwner( new_owner ? new_owner->
engine() : 0);
268 it->second->setOwner( new_owner );
273 me = shared_from_this();
274 }
catch ( boost::bad_weak_ptr& bw ) {
277 it->second->setParent( me );
const std::string & getName() const
Returns the name of this service instance.
void setParent(shared_ptr new_parent)
Sets the parent service in case this service is a sub-service.
TaskContext * getOwner() const
The owner is the top-level TaskContext owning this service (indirectly).
This base class serves as a template-less handle for operation objects and also stores the name and d...
Service::shared_ptr provides()
Returns this Service, unless no shared_ptr yet exists.
bool hasOperation(const std::string &name) const
Query for the existence of a Operation in this interface.
static Service::shared_ptr Create(const std::string &name, TaskContext *owner=0)
Creates a Service with a name and an owner.
Service::shared_ptr provides()
Returns this Service.
The interface class for operation callers.
boost::shared_ptr< base::DisposableInterface > getLocalOperation(std::string name)
Get a locally added operation from this interface.
Service(const std::string &name, TaskContext *owner=0)
Creates a Service with a name and an owner.
void clear()
Erases the whole repository.
bool setThread(ExecutionThread et, ExecutionEngine *executor)
Sets the Thread execution policy of this object.
virtual void removeService(std::string const &service_name)
Remove a previously added sub-service, potentially freeing it (and this) from memory.
Services services
the services we implement.
bool hasMember(const std::string &name) const
Query if an operation is present.
virtual ProviderNames getProviderNames() const
Return a standard container which contains all the sub-service names of this Service.
void removeOperation(const std::string &name)
Removes a previously added operation.
bool resetOperation(std::string name, base::OperationBase *impl)
Reset the implementation of a operation.
boost::shared_ptr< OperationCallerInterface > shared_ptr
Use this type for shared pointer storage of an OperationCallerInterface object.
An execution engine serialises (executes one after the other) the execution of all commands...
boost::shared_ptr< Service > shared_ptr
OperationInterfacePart * getPart(const std::string &name)
Get a previously added part of this factory.
This class allows storage and retrieval of operations, ports, attributes and properties provided by a...
Service * getService() const
Returns the service this interface belongs to.
SimpleOperations simpleoperations
A template-less manager for OperationCaller calls.
virtual bool addService(shared_ptr obj)
Add a new sub-service to this Service.
This class defines the interface for creating operation objects without using C++ templates...
bool hasService(const std::string &service_name)
Check if this service has the sub-service service_name.
bool addLocalOperation(base::OperationBase &op)
Add an Operation object to the operation interface.
virtual DisposableInterface::shared_ptr getImplementation()=0
Returns the implementation object of this operation.
boost::shared_ptr< DisposableInterface > shared_ptr
Use this type for shared pointer storage of an DisposableInterface object.
std::vector< std::string > getOperationNames() const
Returns the names of all operations added to this interface.
virtual RTT_API boost::shared_ptr< base::DisposableInterface > getLocalOperation() const
Returns any local operation associated with this operation.
void clear()
Remove and delete all added operations.
OperationList ownedoperations
std::vector< typename MapT::key_type > keys(const MapT &map)
Notify the Logger in which 'module' the message occured.
ExecutionEngine * getOwnerExecutionEngine() const
Return the execution engine of this service owner.
The TaskContext is the C++ representation of an Orocos component.
void setOwner(ExecutionEngine *ee)
Updates the owning ExecutionEngine that might execute this operation.
OperationInterfacePart * getOperation(std::string name)
Get a previously added operation for use in a C++ OperationCaller object.
Service * mservice
The parent Service.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
bool setOperationThread(std::string const &name, ExecutionThread et)
Sets the thread of execution of a previously added operation.
const std::string & getName()
Returns the name of this operation.
void setOwner(TaskContext *new_owner)
Sets the owning TaskContext that will execute the operations in this service.
internal::OperationCallerC create(std::string name, ExecutionEngine *caller)
Create a OperationCallerC object, a template-less operation invocation object.
void remove(const std::string &name)
Remove an added operation from the interface.
const ExecutionEngine * engine() const
Get a const pointer to the ExecutionEngine of this Task.
void clear()
Clear all added operations, properties and sub-services from this Service.
ExecutionThread
Users can choose if an operation's function is executed in the component's thread (OwnThread) or in t...