set a factory for generating a suitable data switch handler for the sepcified DataType and and associated type_id This will instantiate handlers and associate them with a string identifier. The DataType must be one of DataTypes of the main class. Call this function as required in the constructor of your inheriting class before calling init()
- Parameters
-
factory. | A method that produces a suitable handler given a DataExportStream configuration object. |
set_factory("channel_a", [](exporters::DataExportConfig const& config) { return MyHandler(static_cast<MyHandlerConfig&>(config)); } )
#ifndef SKA_CHEETAH_EXPORTERS_DATAEXPORTIMPL_H
#define SKA_CHEETAH_EXPORTERS_DATAEXPORTIMPL_H
#include "cheetah/exporters/DataExportConfig.h"
#include "cheetah/exporters/TestProbe.h"
#include "panda/DataSwitch.h"
#include "panda/TupleUtilities.h"
#include <tuple>
#include <map>
namespace cheetah {
namespace exporters {
class ExporterType;
template<typename DataExporterType, typename T> class ExportInitialiser;
template<typename... DataTypes>
class DataExport : public panda::DataSwitch<DataTypes...>
{
typedef panda::DataSwitch<DataTypes...> BaseT;
public:
DataExport(exporters::DataExportConfig const&);
virtual ~DataExport() = 0;
std::set<ExporterType>
const&
available()
const;
template<typename DataType>
protected:
template<typename DataType, typename FactoryType>
void set_factory(ExporterType const& type_id, FactoryType factory);
protected:
std::tuple<ExportInitialiser<DataExport<DataTypes...>, DataTypes>...> _initialisers;
DataExportConfig const& _config;
std::set<ExporterType> _types;
};
}
}
}
#include "cheetah/exporters/detail/DataExport.cpp"
#endif // SKA_CHEETAH_EXPORTERS_DATAEXPORTIMPL_H