MachineIntelligenceCore:Toolchain
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ApplicationState.hpp
Go to the documentation of this file.
1 
23 #ifndef SRC_CONFIGURATION_APPLICATIONSTATE_HPP_
24 #define SRC_CONFIGURATION_APPLICATIONSTATE_HPP_
25 
26 #include <boost/atomic.hpp>
27 #include <boost/thread/mutex.hpp>
28 
30 #ifdef _WIN32
31 #include <system_utils/windows_extras.hpp> // extra windows stuff
32 #endif
33 
34 namespace mic {
35 
41 namespace application {
42 
46 class Application;
47 
54 public:
59  static ApplicationState* getInstance();
60 
61  // ---------------------- Quit flag MANAGEMENT.
62 
68  double Quit();
69 
74  void setQuit();
75 
80  void resetQuit();
81 
82  // ---------------------- Single step flag MANAGEMENT.
83 
89  double isPaused();
90 
95  void pressPause();
96 
97  // ---------------------- Single step mode MANAGEMENT.
98 
104  double isSingleStepModeOn();
105 
110  void pressSingleStep();
111 
112  // ---------------------- Learning mode MANAGEMENT.
113 
119  double isLearningModeOn();
120 
125  void pressLearning();
126 
131  void setLearningModeOn();
132 
137  void setLearningModeOff();
138 
139  // ---------------------- Using NCURSES mode MANAGEMENT.
140 
146  double usingNCURSES();
147 
152  void startUsingNCURSES();
153 
158  void stopUsingNCURSES();
159 
160 
161  // ---------------------- Using OpenGL mode MANAGEMENT.
162 
168  double usingOpenGL();
169 
174  void startUsingOpenGL();
175 
180  void stopUsingOpenGL();
181 
182 
183  // ---------------------- SLEEP INTERVAL MANAGEMENT.
184 
190  double getSleepInterval();
191 
196  void setSleepIntervalS(double sleep_interval_in_seconds);
197 
202  void setSleepIntervalMS(double sleep_interval_in_miliseconds);
203 
208  void setSleepIntervalUS(double sleep_interval_in_microseconds);
209 
215  void multiplySleepInterval(double m_ = 1.5);
216 
222  void divideSleepInterval(double d_ = 1.5);
223 
227  void displayStatus();
228 
232  boost::mutex & dataSynchronizationMutex() {
234  }
235 
239  void setApplication(mic::application::Application *application_);
240 
241 private:
245  static boost::atomic<ApplicationState*> instance_;
246 
250  static boost::mutex instantiation_mutex;
251 
256 
261 
262 
264  bool quit_flag;
265 
268 
271 
274 
277 
280 
281 
288 
293 
299  void setSleepInterval(double sleep_interval_);
300 
305 
310 
311 };
312 
317 #define APP_STATE mic::application::ApplicationState::getInstance()
318 
319 
324 #define APP_SLEEP() usleep(APP_STATE->getSleepInterval())
325 
326 
331 #define APP_DATA_SYNCHRONIZATION_SCOPED_LOCK() boost::mutex::scoped_lock lock(APP_STATE->dataSynchronizationMutex())
332 
333 } /* namespace application */
334 } /* namespace mic */
335 
336 
337 
338 
339 #endif /* SRC_CONFIGURATION_APPLICATIONSTATE_HPP_ */
Contains declaration of the PropertyTree class.
static ApplicationState * getInstance()
Parent class for all classes possessing properties. Contains methods useful for their management...
Class storing the state of the application (modes, sleep interval etc.). Defined in the form of a sin...
void setSleepIntervalUS(double sleep_interval_in_microseconds)
Base class for all applications.
Definition: Application.hpp:38
mic::configuration::Property< double > application_sleep_interval
void setSleepInterval(double sleep_interval_)
mic::configuration::Property< bool > pause_mode
Property: pause application mode.
void setApplication(mic::application::Application *application_)
mic::configuration::Property< bool > learning_mode
Property: learning/testing mode.
void setSleepIntervalS(double sleep_interval_in_seconds)
mic::application::Application * application
bool using_ncurses
Flag denoting whether application is using NCurses-based CLI.
static boost::atomic< ApplicationState * > instance_
static boost::mutex external_data_synchronization_mutex
mic::configuration::Property< bool > single_step_mode
Property: single step mode.
bool quit_flag
Quit application flag.
void setSleepIntervalMS(double sleep_interval_in_miliseconds)
bool using_opengl
Flag denoting whether application is using OpenGL-based visualization.
static boost::mutex internal_data_synchronization_mutex