31 #ifndef GRT_CONTEXT_HEADER 32 #define GRT_CONTEXT_HEADER 41 Context(
const std::string &
id =
"" ) :
MLBase(
id, MLBase::CONTEXT )
45 numInputDimensions = 0;
46 numOutputDimensions = 0;
47 numContextInstances++;
51 if( --numContextInstances == 0 ){
52 delete stringContextMap;
53 stringContextMap = NULL;
58 virtual bool deepCopyFrom(
const Context *rhs){
return false; }
60 bool copyBaseVariables(
const Context *context){
62 if( context == NULL ){
63 errorLog <<
"copyBaseVariables(const Context *context) - context pointer is NULL!" << std::endl;
71 this->initialized = context->initialized;
72 this->okToContinue = context->okToContinue;
73 this->numInputDimensions = context->numInputDimensions;
74 this->numOutputDimensions = context->numOutputDimensions;
75 this->data = context->data;
76 this->debugLog = context->debugLog;
77 this->errorLog = context->errorLog;
78 this->warningLog = context->warningLog;
83 virtual bool process(
VectorFloat inputVector){
return false; }
85 virtual bool reset()
override {
return false; }
87 virtual bool updateContext(
bool value){
return false; }
90 std::string getContextType()
const {
return contextType; }
91 bool getInitialized()
const {
return initialized; }
92 bool getOK()
const {
return okToContinue; }
93 VectorFloat getProcessedData()
const {
return data; }
106 static Context* create( std::string
const &
id );
116 GRT_DEPRECATED_MSG(
"createInstanceFromString is deprecated, use create instead.",
static Context* createInstanceFromString(
const std::string &
id ) );
131 bool saveContextSettingsToFile( std::fstream &file )
const;
138 bool loadContextSettingsFromFile( std::fstream &file );
140 std::string contextType;
145 static StringContextMap *getMap(){
146 if( !stringContextMap ){ stringContextMap =
new StringContextMap; }
147 return stringContextMap;
151 static StringContextMap *stringContextMap;
152 static UINT numContextInstances;
161 template<
typename T >
165 getMap()->insert( std::pair< std::string,
Context*(*)() >(newContextModuleName, &createNewContextModuleInstance< T > ) );
171 #endif //GRT_CONTEXT_HEADER virtual bool reset() override
MLBase(const std::string &id="", const BaseType type=BASE_TYPE_NOT_SET)
std::map< std::string, Context *(*)() > StringContextMap
Context * createNewContextModuleInstance()
Returns a pointer to a new instance of the template class, the caller is responsible for deleting the...
This class provides an interface for classes to register themselves with the Context base class...
GRT_DEPRECATED_MSG("saveModelToFile(std::string filename) is deprecated, use save(const std::string &filename) instead", virtual bool saveModelToFile(const std::string &filename) const )
bool copyGRTBaseVariables(const GRTBase *GRTBase)
This is the main base class that all GRT machine learning algorithms should inherit from...