39 #ifndef ORO_TASK_CONTEXT_HPP 40 #define ORO_TASK_CONTEXT_HPP 49 #include <boost/make_shared.hpp> 117 virtual const std::string&
getName()
const {
return tcservice->getName(); }
169 virtual void clear();
179 virtual bool ready();
181 virtual bool start();
198 virtual bool addPeer(
TaskContext* peer, std::string alias =
"" );
203 virtual void removePeer(
const std::string& name );
220 virtual void disconnect();
225 virtual void disconnectPeers(
const std::string& name );
231 virtual PeerList getPeerList()
const;
236 virtual bool hasPeer(
const std::string& peer_name )
const;
242 virtual TaskContext* getPeer(
const std::string& peer_name )
const;
277 return tcrequests->requires(service_name);
297 template<
class ServiceType>
298 boost::shared_ptr<ServiceType>
getProvider(
const std::string& name) {
299 if (!prepareProvide(name))
return boost::shared_ptr<ServiceType>();
300 LocalServices::iterator it = localservs.find(name);
301 if ( it != localservs.end() ) {
302 return boost::dynamic_pointer_cast<ServiceType>(it->second);
304 boost::shared_ptr<ServiceType> st = boost::make_shared<ServiceType>(
this);
305 st->connectTo( provides(name) );
306 localservs[name] = st;
315 bool loadService(
const std::string& service_name);
335 template<
class Signature>
338 return tcservice->addOperation(op);
345 template<
class Func,
class Service>
349 return tcservice->addOperation(name,func, serv, et);
356 template<
class Signature>
360 return tcservice->addOperation(name, func, et);
374 return tcservice->getOperation(name);
401 return tcservice->addAttribute(name, attr);
414 return tcservice->addConstant(name, attr);
428 return tcservice->addAttribute(a);
441 return tcservice->getAttribute(name);
469 return tcservice->addProperty(name, attr);
477 return tcservice->addProperty(pb);
489 return tcservice->getProperty(name);
514 return ports()->addPort(port);
523 return ports()->addPort(port);
538 return ports()->addEventPort(port,callback);
550 return ports()->addEventPort(port,callback);
559 return ports()->getPort(name);
567 return tcservice.get();
574 return tcservice.get();
626 typedef std::map< std::string, TaskContext* > PeerMap;
627 typedef std::vector< TaskContext* > Users;
651 typedef std::map<base::PortInterface*, SlotFunction > UserCallbacks;
652 UserCallbacks user_callbacks;
677 bool prepareProvide(
const std::string& name);
679 typedef std::map<std::string, boost::shared_ptr<ServiceRequester> > LocalServices;
680 LocalServices localservs;
Property< T > & addProperty(const std::string &name, T &attr)
Adds a variable of any type as a property to the attribute interface.
The Interface of a TaskContext which exposes its data-flow ports.
const DataFlowInterface * ports() const
Get the Data flow ports of this task.
base::PortInterface * getPort(const std::string &name) const
Get a port of this Component.
Service::shared_ptr provides()
Returns this Service.
ConfigurationInterface * attributes()
Returns the attributes of this TaskContext as an ConfigurationInterface.
base::InputPortInterface & addEventPort(const std::string &name, base::InputPortInterface &port, SlotFunction callback=SlotFunction())
Name and add an Event triggering Port to the interface of this task and add a Service with the same n...
The operation ties a C or C++ function into a component interface.
Base class for all properties.
Operation< Signature > & addOperation(const std::string name, Signature *func, ExecutionThread et=ClientThread)
Adds a C function as an operation.
bool addProperty(base::PropertyBase &pb)
Add an base::PropertyBase as a property.
OperationInterface * operations()
Returns the operations of this TaskContext as an OperationInterface.
bool addConstant(const std::string &name, const T &attr)
Adds a variable of any type as read-only attribute to the attribute interface.
boost::shared_ptr< ServiceRequester > shared_ptr
Operation< typename internal::GetSignature< Func >::Signature > & addOperation(const std::string name, Func func, Service *serv, ExecutionThread et=ClientThread)
Adds a C++ function as an operation.
A container for holding references to properties.
bool addAttribute(base::AttributeBase &a)
Add an base::AttributeBase which remains owned by the user.
base::InputPortInterface & addEventPort(base::InputPortInterface &port, SlotFunction callback=SlotFunction())
Add an Event triggering Port to the interface of this task and add a Service with the same name of th...
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...
ServiceRequester::shared_ptr requires()
Returns the object that manages which methods this Task requires to be implemented by another task...
boost::function< void(base::PortInterface *)> SlotFunction
Name and add a Port to the interface of this task and add a Service with the same name of the port...
DataFlowInterface * ports()
Get the Data flow ports of this task.
An attribute is a minimalistic, named placeholder for data.
boost::shared_ptr< ActivityInterface > shared_ptr
Service::shared_ptr provides(const std::string &service_name)
Returns a sub-Service which resorts under this Service.
Interface to start/stop and query a Activity.
base::PortInterface & addPort(const std::string &name, base::PortInterface &port)
Name and add a Port to the interface of this task and add a Service with the same name of the port...
A property represents a named value of any type with a description.
base::AttributeBase * getAttribute(const std::string &name) const
Adds a variable of any type as read/write attribute to the attribute interface.
std::vector< std::string > PeerList
A list of Peer TaskContext names.
bool setName(const std::string &name)
Change the name of this unconnected Port.
A class for keeping track of Attribute, Constant and Property objects of a TaskContext.
TaskState
Describes the different states a component can have.
This class defines the interface for creating operation objects without using C++ templates...
bool addAttribute(const std::string &name, T &attr)
Adds a variable of any type as read/write attribute to the attribute interface.
T * getActivity()
Get a pointer to the activity running this component.
PropertyBag * properties()
Returns the properties of this TaskContext as a PropertyBag.
OperationInterfacePart * getOperation(std::string name)
Get a previously added operation for use in a C++ OperationCaller object.
base::PropertyBase * getProperty(const std::string &name) const
Get a Property with name name.
The TaskContext is the C++ representation of an Orocos component.
An object oriented wrapper around a non recursive mutex.
bool connectPorts(TaskContext *A, TaskContext *B)
Connect the Data Flow Ports of A and B in both directions, by matching port names.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
The base class of every data flow port.
Operation< Signature > & addOperation(Operation< Signature > &op)
Add an operation object to the interface.
Holds all exported operations of a component and is able to produce callers for these operations...
base::PortInterface & addPort(base::PortInterface &port)
Add a Port to the interface of this task and add a Service with the same name of the port...
bool connectPeers(TaskContext *A, TaskContext *B)
Set up the Execution Flow (who knows who) between A and B in both directions.
virtual const std::string & getName() const
Returns the name of this TaskContext.
ExecutionThread
Users can choose if an operation's function is executed in the component's thread (OwnThread) or in t...
ServiceRequester::shared_ptr requires(const std::string &service_name)
Returns the object that manages which methods this Task requires to be implemented by another service...
boost::shared_ptr< ServiceType > getProvider(const std::string &name)
Use this method to be able to make OperationCaller calls to services provided by this component...