31 #ifndef GRT_CONTEXT_HEADER
32 #define GRT_CONTEXT_HEADER
42 contextType =
"NOT_SET";
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->contextType = context->contextType;
72 this->initialized = context->initialized;
73 this->okToContinue = context->okToContinue;
74 this->numInputDimensions = context->numInputDimensions;
75 this->numOutputDimensions = context->numOutputDimensions;
76 this->data = context->data;
77 this->debugLog = context->debugLog;
78 this->errorLog = context->errorLog;
79 this->warningLog = context->warningLog;
84 virtual bool process(
VectorFloat inputVector){
return false; }
86 virtual bool reset(){
return false; }
88 virtual bool updateContext(
bool value){
return false; }
91 std::string getContextType()
const {
return contextType; }
94 bool getInitialized()
const {
return initialized; }
95 bool getOK()
const {
return okToContinue; }
96 VectorFloat getProcessedData()
const {
return data; }
109 static Context* createInstanceFromString(
const std::string &contextType);
116 Context* createNewInstance()
const;
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;
156 template<
typename T >
Context *newContextModuleInstance() {
return new T; }
158 template<
typename T >
162 getMap()->insert( std::pair< std::string,
Context*(*)() >(newContextModuleName, &newContextModuleInstance< T > ) );
168 #endif //GRT_CONTEXT_HEADER
UINT getNumOutputDimensions() const
std::map< std::string, Context *(*)() > StringContextMap
This is the main base class that all GRT machine learning algorithms should inherit from...
bool copyGRTBaseVariables(const GRTBase *GRTBase)
UINT getNumInputDimensions() const