20 #ifndef ESSENTIA_ALGORITHMFACTORY_H
21 #define ESSENTIA_ALGORITHMFACTORY_H
41 template <
typename BaseAlgorithm>
44 typedef BaseAlgorithm* (*AlgorithmCreator)();
57 template <
typename BaseAlgorithm>
86 static BaseAlgorithm*
create(
const std::string&
id) {
87 return instance().create_i(
id);
94 static void free(BaseAlgorithm* algo) {
103 static std::vector<std::string> keys();
114 template <
typename ConcreteProduct,
typename ReferenceConcreteProduct = ConcreteProduct>
123 entry.
name = ReferenceConcreteProduct::name;
124 entry.
description = ReferenceConcreteProduct::description;
125 entry.
category = ReferenceConcreteProduct::category;
129 if (algoMap.find(entry.
name) != algoMap.end()) {
130 E_WARNING(
"Overwriting registered algorithm " << entry.
name);
131 algoMap[entry.
name] = entry;
140 return new ConcreteProduct;
152 BaseAlgorithm* create_i(
const std::string&
id)
const;
161 #define CREATE static BaseAlgorithm* create(const std::string& id
162 #define CBEG ) { return instance().create_i(id
163 #define P(n) , const std::string& name##n, const Parameter& value##n
164 #define AP(n) , name##n, value##n
215 #define CREATEI BaseAlgorithm* create_i(const std::string& id
216 #define CENDI ) const;
270 namespace streaming {
#define CEND
Definition: algorithmfactory.h:165
#define CREATE
Definition: algorithmfactory.h:161
#define CREATEI
Definition: algorithmfactory.h:215
#define AP(n)
Definition: algorithmfactory.h:164
#define P(n)
Definition: algorithmfactory.h:163
#define CENDI
Definition: algorithmfactory.h:216
#define CBEG
Definition: algorithmfactory.h:162
Definition: algorithmfactory.h:42
std::string description
Definition: algorithmfactory.h:48
AlgorithmCreator create
Definition: algorithmfactory.h:46
std::string name
Definition: algorithmfactory.h:47
std::string category
Definition: algorithmfactory.h:49
Definition: algorithmfactory.h:115
Registrar()
Definition: algorithmfactory.h:118
static BaseAlgorithm * create()
Definition: algorithmfactory.h:139
Definition: algorithmfactory.h:58
EssentiaFactory()
Definition: algorithmfactory.h:149
static void shutdown()
Definition: algorithmfactory.h:70
static const AlgorithmInfo< BaseAlgorithm > & getInfo(const std::string &id)
Definition: algorithmfactory.h:109
static void free(BaseAlgorithm *algo)
Definition: algorithmfactory.h:94
static BaseAlgorithm * create(const std::string &id)
Definition: algorithmfactory.h:86
EssentiaFactory(EssentiaFactory &)
static EssentiaFactory & instance()
Definition: algorithmfactory_impl.h:26
static EssentiaFactory< BaseAlgorithm > * _instance
Definition: algorithmfactory.h:60
EssentiaMap< std::string, AlgorithmInfo< BaseAlgorithm >, string_cmp > CreatorMap
Definition: algorithmfactory.h:154
static void init()
Definition: algorithmfactory.h:64
CreatorMap _map
Definition: algorithmfactory.h:155
std::pair< typename BaseClass::iterator, bool > insert(const KeyType &key, const ValueType &value)
Definition: types.h:219
#define E_DEBUG(module, msg)
Definition: debugging.h:157
#define E_WARNING(msg)
Definition: debugging.h:164
EssentiaFactory< Algorithm > AlgorithmFactory
Definition: algorithmfactory.h:267
EssentiaFactory< Algorithm > AlgorithmFactory
Definition: algorithmfactory.h:271
Definition: algorithm.h:28
@ EFactory
Definition: debugging.h:44