Ports and Port Configuration

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.

Ports

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;
  ...
}

Port Configuration

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:

  1. The scope, where to listen to data (input port) or where to publish data (output port)
  2. Optional: The kind of transports to use, usually you decide if you want only local transport (fast, high performance) or remote transport (possibly over the network).
// 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 Port-specific Configuration

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:

  1. Queue-size: Specifies the size of the input buffer, determining, how many of the latest input items to keep. Default is 1 (high performance), but can be any size.
  2. Keep-latest: Specifies, if the buffer keeps the latest item available, even if it was already read from the buffer.
// 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

Table of Contents

Related Documentation

This Page