39 #ifndef ORO_TASK_CONTEXT_HPP 40 #define ORO_TASK_CONTEXT_HPP 43 #include "rtt-config.h" 49 #include <boost/make_shared.hpp> 117 virtual const std::string&
getName()
const {
return tcservice->getName(); }
170 virtual void clear();
180 virtual bool ready();
182 virtual bool start();
199 virtual bool addPeer(
TaskContext* peer, std::string alias =
"" );
204 virtual void removePeer(
const std::string& name );
221 virtual void disconnect();
226 virtual void disconnectPeers(
const std::string& name );
232 virtual PeerList getPeerList()
const;
237 virtual bool hasPeer(
const std::string& peer_name )
const;
243 virtual TaskContext* getPeer(
const std::string& peer_name )
const;
278 return tcrequests->requires(service_name);
298 template<
class ServiceType>
299 boost::shared_ptr<ServiceType>
getProvider(
const std::string& name) {
300 if (!prepareProvide(name))
return boost::shared_ptr<ServiceType>();
301 LocalServices::iterator it = localservs.find(name);
302 if ( it != localservs.end() ) {
303 return boost::dynamic_pointer_cast<ServiceType>(it->second);
305 boost::shared_ptr<ServiceType> st = boost::make_shared<ServiceType>(
this);
306 st->connectTo( provides(name) );
307 localservs[name] = st;
316 bool loadService(
const std::string& service_name);
336 template<
class Signature>
339 return tcservice->addOperation(op);
346 template<
class Func,
class Service>
350 return tcservice->addOperation(name,func, serv, et);
357 template<
class Signature>
361 return tcservice->addOperation(name, func, et);
375 return tcservice->getOperation(name);
402 return tcservice->addAttribute(name, attr);
415 return tcservice->addConstant(name, attr);
429 return tcservice->addAttribute(a);
442 return tcservice->getAttribute(name);
470 return tcservice->addProperty(name, attr);
478 return tcservice->addProperty(pb);
490 return tcservice->getProperty(name);
515 return ports()->addPort(port);
524 return ports()->addPort(port);
539 return ports()->addEventPort(port,callback);
551 return ports()->addEventPort(port,callback);
560 return ports()->getPort(name);
568 return tcservice.get();
575 return tcservice.get();
627 typedef std::map< std::string, TaskContext* >
PeerMap;
628 typedef std::vector< TaskContext* >
Users;
678 bool prepareProvide(
const std::string& name);
680 typedef std::map<std::string, boost::shared_ptr<ServiceRequester> >
LocalServices;
PeerMap _task_map
map of the tasks we are using
Property< T > & addProperty(const std::string &name, T &attr)
std::map< std::string, TaskContext * > PeerMap
std::vector< TaskContext * > Users
UserCallbacks user_callbacks
const DataFlowInterface * ports() const
base::PortInterface * getPort(const std::string &name) const
Service::shared_ptr provides()
ConfigurationInterface * attributes()
base::InputPortInterface & addEventPort(const std::string &name, base::InputPortInterface &port, SlotFunction callback=SlotFunction())
Users musers
map of the tasks that are using us.
Operation< Signature > & addOperation(const std::string name, Signature *func, ExecutionThread et=ClientThread)
bool addProperty(base::PropertyBase &pb)
OperationInterface * operations()
bool addConstant(const std::string &name, const T &attr)
boost::shared_ptr< ServiceRequester > shared_ptr
Operation< typename internal::GetSignature< Func >::Signature > & addOperation(const std::string name, Func func, Service *serv, ExecutionThread et=ClientThread)
A container for holding references to properties.
bool addAttribute(base::AttributeBase &a)
base::InputPortInterface & addEventPort(base::InputPortInterface &port, SlotFunction callback=SlotFunction())
boost::shared_ptr< Service > shared_ptr
ServiceRequester::shared_ptr requires()
boost::function< void(base::PortInterface *)> SlotFunction
DataFlowInterface * ports()
boost::shared_ptr< ActivityInterface > shared_ptr
Service::shared_ptr provides(const std::string &service_name)
Interface to start/stop and query a Activity.
Service::shared_ptr tcservice
base::PortInterface & addPort(const std::string &name, base::PortInterface &port)
A property represents a named value of any type with a description.
ServiceRequester::shared_ptr tcrequests
base::AttributeBase * getAttribute(const std::string &name) const
std::vector< std::string > PeerList
std::map< base::PortInterface *, SlotFunction > UserCallbacks
bool setName(const std::string &name)
A class for keeping track of Attribute, Constant and Property objects of a TaskContext. It allows plugins and remote components to browse the attributes and properties of a TaskContext.
bool addAttribute(const std::string &name, T &attr)
PropertyBag * properties()
OperationInterfacePart * getOperation(std::string name)
base::PropertyBase * getProperty(const std::string &name) const
base::ActivityInterface::shared_ptr our_act
std::map< std::string, boost::shared_ptr< ServiceRequester > > LocalServices
An object oriented wrapper around a non recursive mutex.
bool connectPorts(TaskContext *A, TaskContext *B)
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Operation< Signature > & addOperation(Operation< Signature > &op)
Holds all exported operations of a component and is able to produce callers for these operations...
base::PortInterface & addPort(base::PortInterface &port)
bool connectPeers(TaskContext *A, TaskContext *B)
virtual const std::string & getName() const
ServiceRequester::shared_ptr requires(const std::string &service_name)
boost::shared_ptr< ServiceType > getProvider(const std::string &name)