MachineIntelligenceCore:Toolchain
|
Class storing the state of the application (modes, sleep interval etc.). Defined in the form of a singleton, with double-checked locking pattern (DCLP) based access to instance. More...
#include <ApplicationState.hpp>
Public Member Functions | |
double | Quit () |
void | setQuit () |
void | resetQuit () |
double | isPaused () |
void | pressPause () |
double | isSingleStepModeOn () |
void | pressSingleStep () |
double | isLearningModeOn () |
void | pressLearning () |
void | setLearningModeOn () |
void | setLearningModeOff () |
double | usingNCURSES () |
void | startUsingNCURSES () |
void | stopUsingNCURSES () |
double | usingOpenGL () |
void | startUsingOpenGL () |
void | stopUsingOpenGL () |
double | getSleepInterval () |
void | setSleepIntervalS (double sleep_interval_in_seconds) |
void | setSleepIntervalMS (double sleep_interval_in_miliseconds) |
void | setSleepIntervalUS (double sleep_interval_in_microseconds) |
void | multiplySleepInterval (double m_=1.5) |
void | divideSleepInterval (double d_=1.5) |
void | displayStatus () |
boost::mutex & | dataSynchronizationMutex () |
void | setApplication (mic::application::Application *application_) |
![]() | |
PropertyTree (std::string node_name_) | |
virtual | ~PropertyTree () |
void | registerProperty (PropertyInterface &prop) |
std::string | getNodeName () const |
void | loadPropertiesFromConfigNode (boost::property_tree::ptree const &pt_) |
void | printProperties () |
void | printPropertiesWithValues () |
PropertyInterface * | getProperty (const std::string &name) |
Static Public Member Functions | |
static ApplicationState * | getInstance () |
Private Member Functions | |
ApplicationState () | |
void | setSleepInterval (double sleep_interval_) |
virtual void | initializePropertyDependentVariables () |
Private Attributes | |
bool | quit_flag |
Quit application flag. More... | |
mic::configuration::Property < bool > | pause_mode |
Property: pause application mode. More... | |
mic::configuration::Property < bool > | single_step_mode |
Property: single step mode. More... | |
mic::configuration::Property < bool > | learning_mode |
Property: learning/testing mode. More... | |
bool | using_ncurses |
Flag denoting whether application is using NCurses-based CLI. More... | |
bool | using_opengl |
Flag denoting whether application is using OpenGL-based visualization. More... | |
mic::configuration::Property < double > | application_sleep_interval |
mic::application::Application * | application |
Static Private Attributes | |
static boost::atomic < ApplicationState * > | instance_ |
static boost::mutex | instantiation_mutex |
static boost::mutex | internal_data_synchronization_mutex |
static boost::mutex | external_data_synchronization_mutex |
Class storing the state of the application (modes, sleep interval etc.). Defined in the form of a singleton, with double-checked locking pattern (DCLP) based access to instance.
Definition at line 53 of file ApplicationState.hpp.
|
private |
Private constructor. Sets default values of all flags (FALSE).
Definition at line 66 of file ApplicationState.cpp.
References application_sleep_interval, learning_mode, pause_mode, quit_flag, mic::configuration::PropertyTree::registerProperty(), single_step_mode, using_ncurses, and using_opengl.
Referenced by getInstance().
|
inline |
Grants access to data synchronization mutex.
Definition at line 232 of file ApplicationState.hpp.
References external_data_synchronization_mutex.
void mic::application::ApplicationState::displayStatus | ( | ) |
Displays (with the use of logger) current status of AppState variables.
Definition at line 248 of file ApplicationState.cpp.
References application, application_sleep_interval, mic::application::Application::displayStatus(), learning_mode, LOG, LSTATUS, pause_mode, quit_flag, single_step_mode, using_ncurses, and using_opengl.
void mic::application::ApplicationState::divideSleepInterval | ( | double | d_ = 1.5 | ) |
Decreases the sleep interval by dividing it by a given value. Access secured with scoped lock.
d_ | Divisor. |
Definition at line 239 of file ApplicationState.cpp.
References application_sleep_interval, internal_data_synchronization_mutex, LOG, and LSTATUS.
|
static |
Method for accessing the object instance, with double-checked locking optimization.
Definition at line 45 of file ApplicationState.cpp.
References ApplicationState(), instance_, and instantiation_mutex.
double mic::application::ApplicationState::getSleepInterval | ( | ) |
Returns current value of time interval. Access secured with scoped lock.
Definition at line 210 of file ApplicationState.cpp.
References application_sleep_interval, and internal_data_synchronization_mutex.
|
inlineprivatevirtual |
Method responsible for initialization of all variables that are property-dependent - here not required, yet empty.
Implements mic::configuration::PropertyTree.
Definition at line 304 of file ApplicationState.hpp.
double mic::application::ApplicationState::isLearningModeOn | ( | ) |
Returns learning_mode flag state. Access secured with scoped lock.
Definition at line 137 of file ApplicationState.cpp.
References internal_data_synchronization_mutex, and learning_mode.
double mic::application::ApplicationState::isPaused | ( | ) |
Returns pause_mode flag state. Access secured with scoped lock.
Definition at line 109 of file ApplicationState.cpp.
References internal_data_synchronization_mutex, and pause_mode.
double mic::application::ApplicationState::isSingleStepModeOn | ( | ) |
Returns single_step_mode flag state. Access secured with scoped lock.
Definition at line 123 of file ApplicationState.cpp.
References internal_data_synchronization_mutex, and single_step_mode.
void mic::application::ApplicationState::multiplySleepInterval | ( | double | m_ = 1.5 | ) |
Increases the sleep interval by multiplying it by a given value. Access secured with scoped lock.
m_ | Multiplier. |
Definition at line 227 of file ApplicationState.cpp.
References application_sleep_interval, internal_data_synchronization_mutex, LOG, and LSTATUS.
void mic::application::ApplicationState::pressLearning | ( | ) |
Change the state of learning_mode flag, as flag is "bimodal", then acts as pressing "pause" button in e.g. VCR (turns it on/off). Access secured with scoped lock.
Definition at line 142 of file ApplicationState.cpp.
References internal_data_synchronization_mutex, and learning_mode.
void mic::application::ApplicationState::pressPause | ( | ) |
Change the state of pause_mode flag, as flag is "bimodal", then acts as pressing "pause" button in e.g. VCR (turns it on/off). Access secured with scoped lock.
Definition at line 114 of file ApplicationState.cpp.
References internal_data_synchronization_mutex, and pause_mode.
void mic::application::ApplicationState::pressSingleStep | ( | ) |
Change the state of single_step_mode flag, as flag is "bimodal", then acts as pressing "pause" button in e.g. VCR (turns it on/off). Access secured with scoped lock.
Definition at line 128 of file ApplicationState.cpp.
References internal_data_synchronization_mutex, and single_step_mode.
double mic::application::ApplicationState::Quit | ( | ) |
Returns quit flag state. Access secured with scoped lock.
Definition at line 91 of file ApplicationState.cpp.
References internal_data_synchronization_mutex, and quit_flag.
void mic::application::ApplicationState::resetQuit | ( | ) |
Change the state of quit flag to false. Access secured with scoped lock.
Definition at line 101 of file ApplicationState.cpp.
References internal_data_synchronization_mutex, and quit_flag.
void mic::application::ApplicationState::setApplication | ( | mic::application::Application * | application_ | ) |
Registers application in APP_STATE.
Definition at line 273 of file ApplicationState.cpp.
References application.
void mic::application::ApplicationState::setLearningModeOff | ( | ) |
Change the state of learning_mode to false. Access secured with scoped lock.
Definition at line 152 of file ApplicationState.cpp.
References internal_data_synchronization_mutex, and learning_mode.
void mic::application::ApplicationState::setLearningModeOn | ( | ) |
Change the state of learning_mode to true. Access secured with scoped lock.
Definition at line 147 of file ApplicationState.cpp.
References internal_data_synchronization_mutex, and learning_mode.
void mic::application::ApplicationState::setQuit | ( | ) |
Change the state of quit flag to true. Access secured with scoped lock.
Definition at line 96 of file ApplicationState.cpp.
References internal_data_synchronization_mutex, and quit_flag.
|
private |
Sets new value of sleep interval. Access secured with scoped lock.
sleep_interval_ | New value of sleep interval (in ms). |
Definition at line 202 of file ApplicationState.cpp.
References application_sleep_interval, and internal_data_synchronization_mutex.
Referenced by setSleepIntervalMS(), setSleepIntervalS(), and setSleepIntervalUS().
void mic::application::ApplicationState::setSleepIntervalMS | ( | double | sleep_interval_in_miliseconds | ) |
Sets new value of sleep interval (in ms).
sleep_interval_in_miliseconds | New value of sleep interval [ms]. |
Definition at line 219 of file ApplicationState.cpp.
References setSleepInterval().
void mic::application::ApplicationState::setSleepIntervalS | ( | double | sleep_interval_in_seconds | ) |
Sets new value of sleep interval (in s).
sleep_interval_in_seconds | New value of sleep interval [s]. |
Definition at line 215 of file ApplicationState.cpp.
References setSleepInterval().
void mic::application::ApplicationState::setSleepIntervalUS | ( | double | sleep_interval_in_microseconds | ) |
Sets new value of sleep interval (in us).
sleep_interval_in_microseconds | New value of sleep interval [us]. |
Definition at line 223 of file ApplicationState.cpp.
References setSleepInterval().
void mic::application::ApplicationState::startUsingNCURSES | ( | ) |
Sets using_ncurses flag. Access secured with scoped lock.
Definition at line 167 of file ApplicationState.cpp.
References internal_data_synchronization_mutex, and using_ncurses.
void mic::application::ApplicationState::startUsingOpenGL | ( | ) |
Sets using_opengl flag. Access secured with scoped lock.
Definition at line 186 of file ApplicationState.cpp.
References internal_data_synchronization_mutex, and using_opengl.
void mic::application::ApplicationState::stopUsingNCURSES | ( | ) |
Resets using_ncurses flag. Access secured with scoped lock.
Definition at line 172 of file ApplicationState.cpp.
References internal_data_synchronization_mutex, and using_ncurses.
void mic::application::ApplicationState::stopUsingOpenGL | ( | ) |
Resets using_opengl flag. Access secured with scoped lock.
Definition at line 192 of file ApplicationState.cpp.
References internal_data_synchronization_mutex, and using_opengl.
double mic::application::ApplicationState::usingNCURSES | ( | ) |
Returns using_ncurses flag state. Access secured with scoped lock.
Definition at line 161 of file ApplicationState.cpp.
References internal_data_synchronization_mutex, and using_ncurses.
double mic::application::ApplicationState::usingOpenGL | ( | ) |
Returns using_opengl flag state. Access secured with scoped lock.
Definition at line 181 of file ApplicationState.cpp.
References internal_data_synchronization_mutex, and using_opengl.
|
private |
Pointer to the currently executed application.
Definition at line 304 of file ApplicationState.hpp.
Referenced by displayStatus(), and setApplication().
|
private |
Property: sleep interval in [ms], used for slowing/fastening the computations. The interval belongs to the range between <1ms, 10s>. Set to 1000.0 (1s) by default.
Definition at line 287 of file ApplicationState.hpp.
Referenced by ApplicationState(), displayStatus(), divideSleepInterval(), getSleepInterval(), multiplySleepInterval(), and setSleepInterval().
|
staticprivate |
Mutex used synchronization of external data (e.g. access to data from different threads such as processing and visualization threads).
Definition at line 260 of file ApplicationState.hpp.
Referenced by dataSynchronizationMutex().
|
staticprivate |
Private instance - accessed as atomic operation.
Definition at line 245 of file ApplicationState.hpp.
Referenced by getInstance().
|
staticprivate |
Mutex used for instantiation of the instance.
Definition at line 250 of file ApplicationState.hpp.
Referenced by getInstance().
|
staticprivate |
Mutex used synchronization of data access stored in application state (flags, internal variabies etc.).
Definition at line 255 of file ApplicationState.hpp.
Referenced by divideSleepInterval(), getSleepInterval(), isLearningModeOn(), isPaused(), isSingleStepModeOn(), multiplySleepInterval(), pressLearning(), pressPause(), pressSingleStep(), Quit(), resetQuit(), setLearningModeOff(), setLearningModeOn(), setQuit(), setSleepInterval(), startUsingNCURSES(), startUsingOpenGL(), stopUsingNCURSES(), stopUsingOpenGL(), usingNCURSES(), and usingOpenGL().
|
private |
Property: learning/testing mode.
Definition at line 273 of file ApplicationState.hpp.
Referenced by ApplicationState(), displayStatus(), isLearningModeOn(), pressLearning(), setLearningModeOff(), and setLearningModeOn().
|
private |
Property: pause application mode.
Definition at line 267 of file ApplicationState.hpp.
Referenced by ApplicationState(), displayStatus(), isPaused(), and pressPause().
|
private |
Quit application flag.
Definition at line 264 of file ApplicationState.hpp.
Referenced by ApplicationState(), displayStatus(), Quit(), resetQuit(), and setQuit().
|
private |
Property: single step mode.
Definition at line 270 of file ApplicationState.hpp.
Referenced by ApplicationState(), displayStatus(), isSingleStepModeOn(), and pressSingleStep().
|
private |
Flag denoting whether application is using NCurses-based CLI.
Definition at line 276 of file ApplicationState.hpp.
Referenced by ApplicationState(), displayStatus(), startUsingNCURSES(), stopUsingNCURSES(), and usingNCURSES().
|
private |
Flag denoting whether application is using OpenGL-based visualization.
Definition at line 279 of file ApplicationState.hpp.
Referenced by ApplicationState(), displayStatus(), startUsingOpenGL(), stopUsingOpenGL(), and usingOpenGL().