GestureRecognitionToolkit  Version: 0.2.5
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
GRTBase.cpp
1 /*
2 GRT MIT License
3 Copyright (c) <2012> <Nicholas Gillian, Media Lab, MIT>
4 
5 Permission is hereby granted, free of charge, to any person obtaining a copy of this software
6 and associated documentation files (the "Software"), to deal in the Software without restriction,
7 including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
9 subject to the following conditions:
10 
11 The above copyright notice and this permission notice shall be included in all copies or substantial
12 portions of the Software.
13 
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15 LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
18 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 */
20 
21 #define GRT_DLL_EXPORTS
22 #include "GRTBase.h"
23 
24 GRT_BEGIN_NAMESPACE
25 
26 GRTBase::GRTBase(const std::string &id):classId(id){
27  if( classId == "" ){
28  infoLog.setKey("[" + classId + "]");
29  debugLog.setKey("[DEBUG " + classId + "]");
30  errorLog.setKey("[ERROR " + classId + "]");
31  warningLog.setKey("[WARNING " + classId + "]");
32  }else{
33  infoLog.setKey("[INFO]");
34  debugLog.setKey("[DEBUG]");
35  errorLog.setKey("[ERROR]");
36  warningLog.setKey("[WARNING]");
37  }
38 }
39 
41 }
42 
44 
45  if( base == NULL ){
46  errorLog << "copyBaseVariables(const GRTBase *base) - base pointer is NULL!" << std::endl;
47  return false;
48  }
49 
50  this->classId = base->classId;
51  this->debugLog = base->debugLog;
52  this->errorLog = base->errorLog;
53  this->infoLog = base->infoLog;
54  this->warningLog = base->warningLog;
55 
56  return true;
57 }
58 
59 std::string GRTBase::getLastWarningMessage() const {
60  return warningLog.getLastMessage();
61 }
62 
63 std::string GRTBase::getLastErrorMessage() const {
64  return errorLog.getLastMessage();
65 }
66 
67 std::string GRTBase::getLastInfoMessage() const {
68  return infoLog.getLastMessage();
69 }
70 
71 std::string GRTBase::getGRTVersion(bool returnRevision){
72  std::string version = GRT_VERSION;
73  if( returnRevision ) version += " revision: " + getGRTRevison();
74  return version;
75 }
76 
77 std::string GRTBase::getGRTRevison(){
78  return GRT_REVISION;
79 }
80 
81 std::string GRTBase::getClassType() const{
82  return getId();
83 }
84 
85 std::string GRTBase::getId() const{
86  return classId;
87 }
88 
90  return this;
91 }
92 
94  return this;
95 }
96 
97 bool GRTBase::setInfoLoggingEnabled(const bool loggingEnabled){
98  return infoLog.setInstanceLoggingEnabled( loggingEnabled );
99 }
100 
101 bool GRTBase::setWarningLoggingEnabled(const bool loggingEnabled){
102  return warningLog.setInstanceLoggingEnabled( loggingEnabled );
103 }
104 
105 bool GRTBase::setErrorLoggingEnabled(const bool loggingEnabled){
106  return errorLog.setInstanceLoggingEnabled( loggingEnabled );
107 }
108 
109 bool GRTBase::setDebugLoggingEnabled(const bool loggingEnabled){
110  return debugLog.setInstanceLoggingEnabled( loggingEnabled );
111 }
112 
113 GRT_END_NAMESPACE
std::string getId() const
Definition: GRTBase.cpp:85
GRTBase * getGRTBasePointer()
Definition: GRTBase.cpp:89
bool setDebugLoggingEnabled(const bool loggingEnabled)
Definition: GRTBase.cpp:109
virtual ~GRTBase(void)
Definition: GRTBase.cpp:40
virtual std::string getLastMessage() const
returns the last message written by the log
Definition: Log.h:157
static std::string getGRTRevison()
Definition: GRTBase.cpp:77
virtual bool setKey(const std::string &key)
sets the key that gets written at the start of each message, this will be written in the format &#39;key ...
Definition: Log.h:166
bool setErrorLoggingEnabled(const bool loggingEnabled)
Definition: GRTBase.cpp:105
std::string getLastErrorMessage() const
Definition: GRTBase.cpp:63
std::string getLastWarningMessage() const
Definition: GRTBase.cpp:59
GRTBase(const std::string &id="")
Definition: GRTBase.cpp:26
virtual bool setInstanceLoggingEnabled(const bool loggingEnabled)
sets if logging is enabled for this specific instance
Definition: Log.h:201
std::string getLastInfoMessage() const
Definition: GRTBase.cpp:67
bool setInfoLoggingEnabled(const bool loggingEnabled)
Definition: GRTBase.cpp:97
This file contains the GRTBase class. This is the core base class for all the GRT modules...
bool copyGRTBaseVariables(const GRTBase *GRTBase)
Definition: GRTBase.cpp:43
bool setWarningLoggingEnabled(const bool loggingEnabled)
Definition: GRTBase.cpp:101
static std::string getGRTVersion(bool returnRevision=true)
Definition: GRTBase.cpp:71
std::string classId
Stores the name of the class (e.g., MinDist)
Definition: GRTBase.h:197