39 #ifndef ORO_SERVICE_PROVIDER_HPP 40 #define ORO_SERVICE_PROVIDER_HPP 53 #include <boost/shared_ptr.hpp> 54 #include <boost/static_assert.hpp> 55 #include <boost/type_traits/function_traits.hpp> 56 #include <boost/function_types/components.hpp> 57 #include <boost/enable_shared_from_this.hpp> 58 #if BOOST_VERSION >= 104000 && BOOST_VERSION < 105300 59 #include <boost/smart_ptr/enable_shared_from_this2.hpp> 61 #if BOOST_VERSION >= 105300 62 #include <boost/smart_ptr/enable_shared_from_raw.hpp> 68 #if BOOST_VERSION >= 104000 69 #if BOOST_VERSION < 105300 105 #if BOOST_VERSION >= 105300 139 const std::string&
getName()
const {
return mname; }
144 const std::string&
doc()
const {
return mdescription; }
149 void doc(
const std::string& description) { mdescription = description; }
154 void setName(
const std::string& name) { mname = name;}
166 void setParent(shared_ptr new_parent);
177 virtual ProviderNames getProviderNames()
const;
204 virtual bool addService( shared_ptr obj );
215 virtual void removeService( std::string
const& service_name );
245 shared_ptr getService(
const std::string& service_name);
252 bool hasService(
const std::string& service_name);
266 std::vector<std::string> getOperationNames()
const;
272 bool hasOperation(
const std::string& name)
const;
294 boost::shared_ptr<base::DisposableInterface> getLocalOperation( std::string name );
311 void removeOperation(
const std::string& name );
340 template<
class Signature>
343 if ( this->addLocalOperation( op ) ==
false )
349 #ifdef ORO_SIGNALLING_OPERATIONS 359 template<
class Signature>
363 if ( this->addLocalOperation( op ) ==
false )
365 this->add( op.
getName(),
new internal::EventOperationInterfacePartFused<Signature>( &op ) );
378 template<
class Signature>
381 if ( this->addLocalOperation( op ) ==
false )
400 template<
class Func,
class Class>
406 ownedoperations.push_back(op);
407 return addOperation( *op );
425 typedef Func Signature;
426 boost::function<Signature> bfunc = func;
428 ownedoperations.push_back(op);
429 return addOperation( *op );
432 #ifdef ORO_SIGNALLING_OPERATIONS 448 typedef Func Signature;
449 boost::function<Signature> bfunc = func;
451 ownedoperations.push_back(op);
452 return addEventOperation( *op );
467 template<
class Func,
class Class>
473 ownedoperations.push_back(op);
474 return addEventOperation( *op );
490 template<
class Func,
class Class>
496 ownedoperations.push_back(op);
497 return addSynchronousOperation( *op );
505 template<
class Func,
class ObjT>
511 ownedoperations.push_back(op);
512 return addOperationDS( sp, *op );
520 template<
class Signature,
class ObjT>
523 if ( this->addLocalOperation( op ) ==
false ) {
541 const std::vector<base::DataSourceBase::shared_ptr>& args,
ExecutionEngine* caller)
const 543 return this->produce(name, args, caller);
561 typedef std::map< std::string, shared_ptr >
Services;
const std::string & getName() const
Returns the name of this service instance.
DataSource is a base class representing a generic way to read data of type T.
TaskContext * getOwner() const
The owner is the top-level TaskContext owning this service (indirectly).
OperationInterfacePart implementation that uses boost::fusion to produce items.
This base class serves as a template-less handle for operation objects and also stores the name and d...
The Interface of a TaskContext which exposes its data-flow ports.
internal::ArgMember< typename boost::remove_pointer< FunctionT >::type >::type Signature
Operation< Signature > & addOperationDS(internal::DataSource< boost::shared_ptr< ObjT > > *sp, Operation< Signature > &op)
For internal use only.
boost::shared_ptr< const Service > shared_constptr
The operation ties a C or C++ function into a component interface.
Operation< Signature > & addOperation(Operation< Signature > &op)
Add an operation object to the interface.
void setName(const std::string &name)
Changes the name of this service.
shared_ptr getParent() const
The parent is the direct parent of this service.
std::vector< std::string > ProviderNames
Services services
the services we implement.
Operation< typename internal::GetSignature< Func >::Signature > & addSynchronousOperation(const std::string name, Func func, Class *obj, ExecutionThread et=ClientThread)
Add an operation to the synchronous interface by means of a function.
base::DataSourceBase::shared_ptr getOperation(std::string name, const std::vector< base::DataSourceBase::shared_ptr > &args, ExecutionEngine *caller) const
For internal use only.
An execution engine serialises (executes one after the other) the execution of all commands...
boost::shared_ptr< Service > shared_ptr
This class allows storage and retrieval of operations, ports, attributes and properties provided by a...
Operation< Signature > & addSynchronousOperation(Operation< Signature > &op)
Add an operation object to the interface.
OperationInterfacePart implementation that uses boost::fusion to produce items.
void doc(const std::string &description)
Sets the descriptive text for this service.
const std::string & doc() const
Returns a descriptive text for this service.
std::map< std::string, base::OperationBase * > SimpleOperations
SimpleOperations simpleoperations
internal::UnMember< typename boost::remove_pointer< FunctionT >::type >::type Signature
A template-less manager for OperationCaller calls.
std::vector< base::OperationBase * > OperationList
A class for keeping track of Attribute, Constant and Property objects of a TaskContext.
This class defines the interface for creating operation objects without using C++ templates...
OperationList ownedoperations
std::map< std::string, shared_ptr > Services
The TaskContext is the C++ representation of an Orocos component.
Operation< typename internal::GetSignatureDS< Func >::Signature > & addOperationDS(const std::string &name, Func func, internal::DataSource< boost::shared_ptr< ObjT > > *sp, ExecutionThread et=ClientThread)
For internal use only.
boost::intrusive_ptr< DataSourceBase > shared_ptr
Use this type to store a pointer to a DataSourceBase.
Operation< Func > & addOperation(const std::string name, Func *func, ExecutionThread et=ClientThread)
Add an operation to the interface by means of a free C/C++ function.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
OperationInterfacePart implementation that only provides synchronous access to an operation...
const std::string & getName()
Returns the name of this operation.
OperationInterface Factory
Holds all exported operations of a component and is able to produce callers for these operations...
Operation< typename internal::GetSignature< Func >::Signature > & addOperation(const std::string name, Func func, Class *obj, ExecutionThread et=ClientThread)
Add an operation to the interface by means of a C++ Class member function.
boost::enable_shared_from_this< Service > shared_from_raw
ExecutionThread
Users can choose if an operation's function is executed in the component's thread (OwnThread) or in t...