39 #ifndef ORO_TASK_CONTEXT_HPP 40 #define ORO_TASK_CONTEXT_HPP 49 #include <boost/make_shared.hpp> 128 virtual const std::string&
getName()
const {
return tcservice->getName(); }
180 virtual void clear();
190 virtual bool ready();
192 virtual bool start();
209 virtual bool addPeer(
TaskContext* peer, std::string alias =
"" );
214 virtual void removePeer(
const std::string& name );
231 virtual void disconnect();
236 virtual void disconnectPeers(
const std::string& name );
242 virtual PeerList getPeerList()
const;
247 virtual bool hasPeer(
const std::string& peer_name )
const;
253 virtual TaskContext* getPeer(
const std::string& peer_name )
const;
288 return tcrequests->requires(service_name);
308 template<
class ServiceType>
309 boost::shared_ptr<ServiceType>
getProvider(
const std::string& name) {
310 if (!prepareProvide(name))
return boost::shared_ptr<ServiceType>();
311 LocalServices::iterator it = localservs.find(name);
312 if ( it != localservs.end() ) {
313 return boost::dynamic_pointer_cast<ServiceType>(it->second);
315 boost::shared_ptr<ServiceType> st = boost::make_shared<ServiceType>(
this);
316 st->connectTo( provides(name) );
317 localservs[name] = st;
326 bool loadService(
const std::string& service_name);
346 template<
class Signature>
349 return tcservice->addOperation(op);
356 template<
class Func,
class Service>
360 return tcservice->addOperation(name,func, serv, et);
367 template<
class Signature>
371 return tcservice->addOperation(name, func, et);
385 return tcservice->getOperation(name);
412 return tcservice->addAttribute(name, attr);
425 return tcservice->addConstant(name, attr);
439 return tcservice->addAttribute(a);
452 return tcservice->getAttribute(name);
480 return tcservice->addProperty(name, attr);
488 return tcservice->addProperty(pb);
500 return tcservice->getProperty(name);
525 return ports()->addPort(port);
534 return ports()->addPort(port);
549 return ports()->addEventPort(port,callback);
561 return ports()->addEventPort(port,callback);
570 return ports()->getPort(name);
578 return tcservice.get();
585 return tcservice.get();
621 typedef std::map< std::string, TaskContext* > PeerMap;
622 typedef std::vector< TaskContext* > Users;
647 typedef std::map<base::PortInterface*, SlotFunction > UserCallbacks;
648 UserCallbacks user_callbacks;
660 bool dataOnPortSize(
unsigned int max);
674 void prepareUpdateHook();
683 bool prepareProvide(
const std::string& name);
685 typedef std::map<std::string, boost::shared_ptr<ServiceRequester> > LocalServices;
686 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.
This object represents the default Multi-Writer, Single-Reader queue implementation used by Orocos ob...
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...