46 using namespace detail;
60 if ( !
chkPtr(
"addPort",
"PortInterface", &port) )
return port;
67 log(
Warning) <<
"'addPort' "<< port.
getName() <<
": name already in use as Service. Replacing previous service with new one." <<endlog();
72 log(
Warning) <<
"'addPort' "<< port.
getName() <<
": DataFlowInterface not given to parent. Not adding Service." <<endlog();
83 for ( Ports::iterator it(
mports.begin());
86 if ( (*it)->getName() == port.
getName() ) {
87 log(
Warning) <<
"'addPort' "<< port.
getName() <<
": name already in use. Disconnecting and replacing previous port with new one." <<endlog();
98 if ( !
chkPtr(
"addEventPort",
"PortInterface", &port) )
return port;
105 log(
Warning) <<
"'addPort' "<< port.
getName() <<
": name already in use as Service. Replacing previous service with new one." <<endlog();
110 log(
Warning) <<
"'addPort' "<< port.
getName() <<
": DataFlowInterface not given to parent. Not adding Service." <<endlog();
119 #ifdef ORO_SIGNALLING_PORTS 120 void DataFlowInterface::setupHandles() {
121 for_each(handles.begin(), handles.end(), boost::bind(&
Handle::connect, _1));
124 void DataFlowInterface::cleanupHandles() {
139 log(
Error) <<
"addLocalEventPort "<< port.
getName() <<
": DataFlowInterface not part of a TaskContext. Will not trigger any TaskContext nor register callback." <<endlog();
143 #ifdef ORO_SIGNALLING_PORTS 145 Handle h = port.getNewDataOnPortEvent()->connect(boost::bind(&TaskContext::dataOnPort,
mservice->
getOwner(), _1) );
147 log(
Info) <<
mservice->
getName() <<
" will be triggered when new data is available on InputPort " << port.
getName() << endlog();
148 handles.push_back(h);
157 #ifndef ORO_SIGNALLING_PORTS 164 for ( Ports::iterator it(
mports.begin());
167 if ( (*it)->getName() == name ) {
178 (*it)->setInterface(0);
185 for ( Ports::iterator it(
mports.begin());
188 if ( (*it)->getName() == name ) {
190 (*it)->setInterface(0);
201 std::vector<std::string> res;
202 for ( Ports::const_iterator it(
mports.begin());
205 res.push_back( (*it)->getName() );
210 for ( Ports::const_iterator it(
mports.begin());
213 if ( (*it)->getName() == name )
219 for ( Ports::const_iterator it(
mports.begin());
222 if ( (*it)->getName() == name )
223 return (*it)->getDescription();
230 srv->doc(description);
246 to->
doc(
"No description set for this Port. Use .doc() to document it.");
254 for ( Ports::iterator it(
mports.begin());
266 log(
Error) <<
"You tried to add a null pointer in '"<< where <<
"' for the object '" << name <<
"'. Fix your code !"<< endlog();
const std::string & getName() const
Returns the name of this service instance.
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...
void removeLocalPort(const std::string &name)
Remove a locally added Port from this interface.
TaskContext * getOwner() const
The owner is the top-level TaskContext owning this service (indirectly).
Service::shared_ptr provides()
Returns this Service, unless no shared_ptr yet exists.
PortNames getPortNames() const
Get all port names of this interface.
virtual void removeService(std::string const &service_name)
Remove a previously added sub-service, potentially freeing it (and this) from memory.
base::PortInterface & addLocalPort(base::PortInterface &port)
Add a Port to this task without registering a service for it.
const std::string & getName() const
Get the name of this Port.
shared_ptr getService(const std::string &service_name)
Returns a shared pointer to strictly a sub-service of a null pointer if !hasService(service_name).
std::string getPortDescription(const std::string &name) const
Get the description of an added Port.
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...
Ports mports
All our ports.
base::InputPortInterface & addLocalEventPort(base::InputPortInterface &port, SlotFunction callback=SlotFunction())
Add an Event triggering Port to this task without registering a service for it.
boost::shared_ptr< Service > shared_ptr
This class allows storage and retrieval of operations, ports, attributes and properties provided by a...
bool disconnect()
Disconnect the slot from the signal.
base::PortInterface * getPort(const std::string &name) const
Get an added port.
void removePort(const std::string &name)
Remove a Port from this interface.
virtual Service * createPortObject()
Create accessor Object for this Port, for addition to a TaskContext Object interface.
const std::string & doc() const
Returns a descriptive text for this service.
virtual bool addService(shared_ptr obj)
Add a new sub-service to this Service.
bool connect()
(Re-)Connect the slot with the signal.
boost::function< void(base::PortInterface *)> SlotFunction
bool hasService(const std::string &service_name)
Check if this service has the sub-service service_name.
std::vector< base::PortInterface * > Ports
A sequence of pointers to ports.
bool setPortDescription(const std::string &name, const std::string description)
Sets the description for the service of an added port.
std::vector< std::string > PortNames
A sequence of names of ports.
void setInterface(DataFlowInterface *iface)
Once a port is added to a DataFlowInterface, it gets a pointer to that interface. ...
bool chkPtr(const std::string &where, const std::string &name, const void *ptr)
The TaskContext is the C++ representation of an Orocos component.
Ports getPorts() const
Get all ports of this interface.
Service * mservice
The parent Service.
void dataOnPort(base::PortInterface *port)
Used by the input ports to notify this class of new data.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
void clear()
Remove all added ports from this interface and all associated TaskObjects.
The base class of every data flow port.
DataFlowInterface(Service *parent=0)
Construct the DataFlow interface of a Service.
The Handle holds the information, and allows manipulation, of a connection between a internal::Signal...
TaskContext * getOwner() const
Returns the component this interface belongs to.
Service * createPortObject(const std::string &name)
Create a Service through which one can access a Port.