Cascading Functional Block Plugin (CFB)

From MARIEWiki

Jump to: navigation, search

bocmonta

Contents

What's a Cascading Functional Block (CFB)?

CFB are components that transform, filter or use data before passing it to another components. It's very similar to the Pipe-And-Filter architectural pattern but adapted to MARIE dataflow.


CFB.jpg


CFB are mainly use to customize Ports data operations depending on the communication or application requirements.

Communication Interfaces

Each CFB implements the following interfaces :

CommReceiverIF

bool recvData(const char* data, const unsigned int length)
bool recvData(const DataAbstract& data)
bool recvPullSignal()
bool recvPeekSignal()
CommSenderIF

bool sendData(const char* data, const unsigned int length)
bool sendData(const DataAbstract& data)
bool sendPullSignal()
bool sendPeekSignal()


Each CFB must define how it supports those interfaces and how it can be used. Normally CFB are used in Ports where they generally are cascades one after the other. In this case, CFB need to make sure they are not stoping the data flow, unless specified.

Dynamic Loading

CFB's instances are created by a factory object called CFBFactory. Each CFB must be able to produce instances of itself and register itself to the factory as a CFB producer. This process is achieve using dynamic loading and it's executed when the factory is first instanciated. Each CFB must then follow some rules to be loaded and used correcly:

  • Each CFB must be linked in an independant shared object (.so) named with the prefix "libmariecfb_"
  • Each directory containing CFB shared object to be loaded must be included in an environment variable called "MARIE_CFB_PATH" (except for MARIE installation lib directory which is included automatically).
  • Each CFB must instanciates a static variable named "TYPE" which contains a unique ID name.
  • Each CFB must implements the following creation/deletion functions :
extern "C" 
{
   CFBAbstract* create(ConfigElementType& config);
   void destroy(CFBAbstract* cfb);
}
  • Each CFB must registers itself to the factory as a CFB producer by implementing and instanciating a static proxy class like this :
extern "C" 
{
   class proxy 
   { 
      public:
         proxy()
         {
            (CFBFactory::getInstance()).registerCFB(CFB_X::TYPE, CFBFactory::CFBFuncMap(create, destroy));
         }
   };
    
   // our one instance of the proxy
   proxy p;
}

Notes on CFB creation and deletion

  • At creation, each CFB is responsable to parse and validate the configuration object
  • CFB instances cannot be deleted directly once created (using delete on the instance name). A call to CFBFactory's deleteInstance() function must be used instead.

How to know which CS are available

In MARIE 0.5, you can compile and use the utilitary program marie-info to know which CFB are available.

Configuration

Each CFB have its own configuration requirements. Please refer to each CFB documentation for details.


Personal tools