DUECA/DUSIME
Loading...
Searching...
No Matches
Public Member Functions | List of all members
dueca::DCOMetaFunctor Class Reference

Base class for key-based access to helper classes for DCO objects. More...

#include <DCOMetaFunctor.hxx>

Inheritance diagram for dueca::DCOMetaFunctor:
Inheritance graph
[legend]

Public Member Functions

 DCOMetaFunctor ()
 Constructor.
 
virtual ~DCOMetaFunctor ()
 Destructor.
 

Detailed Description

Base class for key-based access to helper classes for DCO objects.

These classes can be accessed through the DataClassRegistry. For typical use, decide on the following:

Create a class that derives from this DCOMetaFunctor. Give that class a set of virtual methods, or typically only define the operator(), that are const (i.e. the class may never be changed).

In the DCO opjects that you want to extend, add extra code (with the IncludeFile option). Another possibility is extending the code generator with a plugin to add this code. The extra code defines a class derived from the class defined in the previous step. This class can then access a specific dco object's meta information (since you don't have an actual object to work with).

If you want to work with data in a channel, and have access (or want to have, since you are making a generic module) to only the data class name, you can add a functor derived (directly or indirectly) from DCOFunctor. This functor can then be created through your DCOMetaFunctor, and once you have it, you can use it with a channel read token, or a channel write token.

Note that you can hand-write a metafunctor for a specific datatype, but that the most efficient (if you need this a lot), is extending the code generator with a plugin. This has been done for HDF5 functors.

Since this is all very theoretical, let's assume we want to write DCO objects to some SQL-type database. The derived metafunctor gets a call with a pointer to the database and the name for the table. It creates a derivative of DCOFunctor that can write its data in the table.

// the functor that writes sql, when given a pointer to the data
{
// constructor
{
// create a table in the database, and table entries for all
// my members!
}
// destructor
{
// properly close off the table
}
// override the operator definition from DCOFunctor, will be used by
// the channel code
bool operator() (const void* dpointer, const DataTimeSpec& ts)
{
// dpointer contains the data; convert and write another row
// to the table
return true;
}
};
// the generic MetaFunctor class for sql capable DCO objects,
// returns an sql-writing functor (defined elsewhere, for all DCO objects)
class DCOSQLMetaFunctor: public DCOMetaFunctor
{
// note that the arguments are basically those needed for the
// constructor of the DCOSQLFunctor
virtual DCOSQLFunctor* operator()
(sqlptrtype database, const std::string& tablename) const = 0;
};
// derived MetaFunctor class for this sql-capable DCO object
// typically in the extra (IncludeFile) code for the
// data type (possibly you can also template stuff??)
class DCOSQLMetaFunctor_MyData: public DCOSQLMetaFunctor
{
DCOSQLFunctor* operator()
(sqlptrtype database, std::string tablename) const
{
return new DCOSQLFunctor_MyData(database, tablename);
}
};
// we need to add one MetaFunctor to the DCO functortable
// this trick does it at loading time
load_sql_functor(functortable, "sql");
Base class for service objects that can handle DCO data in channels.
Definition DCOFunctor.hxx:27
DCOMetaFunctor()
Constructor.
This is a "light weight object" that enables you to read the latest set of data on a StreamChannelEnd...
Definition StreamReaderLatest.hxx:43

The documentation for this class was generated from the following file: