CCA Nodes and Components can have an arbitrary number of input and output ports. Starting with CCA version 0.4 ports are named and can be references by their names. Input ports and output ports are typed and can be configured from outside.
class MyComponent : public cca::Component {
public:
MyComponent() : cca::Component("foo") {
...
IN = InputPort<int>::create();
registerPort("in", IN); // port is mandatory by default
...
OPTIONAL = InputPort<int>::create();
registerPort("opt", OPTIONAL, Port::OPTIONAL); // optional port
...
}
protected
InputPort<int>::Ptr IN, OPT;
...
}
After a component is created with its ports, it can be instantiated and its ports need to be configured to be working. Both, input and output ports, need to be configured the following has to be configured:
// only local transport enabled
mycomponent->configureInputPort("in", PortConfiguration::LOCAL("/dev/null"));
...
// only remote transport enabled
mycomponent->configureInputPort("in", PortConfiguration::REMOTE("/dev/null"))
...
// local and remote transport enabled
mycomponent->configureInputPort("in", PortConfiguration::LOCALREMOTE("/dev/null"))
...
// use default configuration (confiuration from :ref:"rsb <rsb>" by default)
mycomponent->configureInputPort("in", "/dev/null")
See Example: Ping Pong for an example on how to configure ports.
Input ports listen for data and trigger input-based Processing Strategies. See Example: Ping Pong for an example on how to create and use input ports.
Input ports additionally provide optional input-port-specific configuration, allowing to specify their buffering behavior:
// only local transport enabled
mycomponent->configureInputPort("in",
PortConfiguration::LOCAL("/dev/null",
11, // input queue of size 11
true)); // always keep the latest item in buffer