Bayeux  3.4.1
Core Foundation library for SuperNEMO
Classes
my Namespace Reference

User namespace for the algo class. More...

Classes

class  algo
 A simple configurable algorithm class. More...
 

Detailed Description

User namespace for the algo class.

This is a tutorial for adding OCD support to a class

This tutorial illustrates the programming techniques used to add object configuration description (OCD) support to a class, using dedicated macros available from the Bayeux/datatools library.

A simple class my::algo is provided with its my::algo::initialize method which is dedicated to the initialization of any instance of type my::algo through a container of configuration parameters (see the datatools::properties class from the Bayeux/datatools library). In this example, only four parameters of various type are used to configure any instance of the my::algo type:

The process implies adding specific code at two levels:

  1. From the header file my/algo.h (declaration of the class):

    The DOCD_CLASS_DECLARATION(my::algo) macro (from the datatools/ocd_macros.h header file) is used to declare the OCD support for the my::algo class,

  2. From the source file my/algo.cc (definition of the class):

    The DOCD_CLASS_IMPLEMENT_LOAD_BEGIN() and DOCD_CLASS_IMPLEMENT_LOAD_END() macros define a block of instructions that describes the class and its configuration parameters (name, type, default value...), filling a datatools::object_configuration_description object (from the datatools/object_configuration_description.h header).

    Finally, the DOCD_CLASS_SYSTEM_REGISTRATION() macro is used to register the OCD support data in the Bayeux OCD system registry.