MachineIntelligenceCore:Toolchain
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mic::application::ApplicationState Class Reference

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>

Inheritance diagram for mic::application::ApplicationState:
Collaboration diagram for mic::application::ApplicationState:

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_)
 
- Public Member Functions inherited from mic::configuration::PropertyTree
 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 ()
 
PropertyInterfacegetProperty (const std::string &name)
 

Static Public Member Functions

static ApplicationStategetInstance ()
 

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::Applicationapplication
 

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
 

Detailed Description

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.

Author
tkornuta

Definition at line 53 of file ApplicationState.hpp.

Constructor & Destructor Documentation

mic::application::ApplicationState::ApplicationState ( )
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().

Here is the call graph for this function:

Member Function Documentation

boost::mutex& mic::application::ApplicationState::dataSynchronizationMutex ( )
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.

Here is the call graph for this function:

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.

Parameters
d_Divisor.

Definition at line 239 of file ApplicationState.cpp.

References application_sleep_interval, internal_data_synchronization_mutex, LOG, and LSTATUS.

ApplicationState * mic::application::ApplicationState::getInstance ( )
static

Method for accessing the object instance, with double-checked locking optimization.

Returns
Instance of ApplicationState singleton.

Definition at line 45 of file ApplicationState.cpp.

References ApplicationState(), instance_, and instantiation_mutex.

Here is the call graph for this function:

double mic::application::ApplicationState::getSleepInterval ( )

Returns current value of time interval. Access secured with scoped lock.

Returns
Sleep interval

Definition at line 210 of file ApplicationState.cpp.

References application_sleep_interval, and internal_data_synchronization_mutex.

virtual void mic::application::ApplicationState::initializePropertyDependentVariables ( )
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.

Returns
learning_mode state.

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.

Returns
Pause_mode state.

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.

Returns
single_step_mode state.

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.

Parameters
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.

Returns
Quit flag state.

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.

void mic::application::ApplicationState::setSleepInterval ( double  sleep_interval_)
private

Sets new value of sleep interval. Access secured with scoped lock.

Parameters
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).

Parameters
sleep_interval_in_milisecondsNew value of sleep interval [ms].

Definition at line 219 of file ApplicationState.cpp.

References setSleepInterval().

Here is the call graph for this function:

void mic::application::ApplicationState::setSleepIntervalS ( double  sleep_interval_in_seconds)

Sets new value of sleep interval (in s).

Parameters
sleep_interval_in_secondsNew value of sleep interval [s].

Definition at line 215 of file ApplicationState.cpp.

References setSleepInterval().

Here is the call graph for this function:

void mic::application::ApplicationState::setSleepIntervalUS ( double  sleep_interval_in_microseconds)

Sets new value of sleep interval (in us).

Parameters
sleep_interval_in_microsecondsNew value of sleep interval [us].

Definition at line 223 of file ApplicationState.cpp.

References setSleepInterval().

Here is the call graph for this function:

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.

Returns
using_ncurses state.

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.

Returns
using_opengl state.

Definition at line 181 of file ApplicationState.cpp.

References internal_data_synchronization_mutex, and using_opengl.

Member Data Documentation

mic::application::Application* mic::application::ApplicationState::application
private

Pointer to the currently executed application.

Definition at line 304 of file ApplicationState.hpp.

Referenced by displayStatus(), and setApplication().

mic::configuration::Property<double> mic::application::ApplicationState::application_sleep_interval
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().

boost::mutex mic::application::ApplicationState::external_data_synchronization_mutex
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().

boost::atomic< ApplicationState * > mic::application::ApplicationState::instance_
staticprivate

Private instance - accessed as atomic operation.

Definition at line 245 of file ApplicationState.hpp.

Referenced by getInstance().

boost::mutex mic::application::ApplicationState::instantiation_mutex
staticprivate

Mutex used for instantiation of the instance.

Definition at line 250 of file ApplicationState.hpp.

Referenced by getInstance().

boost::mutex mic::application::ApplicationState::internal_data_synchronization_mutex
staticprivate
mic::configuration::Property<bool> mic::application::ApplicationState::learning_mode
private

Property: learning/testing mode.

Definition at line 273 of file ApplicationState.hpp.

Referenced by ApplicationState(), displayStatus(), isLearningModeOn(), pressLearning(), setLearningModeOff(), and setLearningModeOn().

mic::configuration::Property<bool> mic::application::ApplicationState::pause_mode
private

Property: pause application mode.

Definition at line 267 of file ApplicationState.hpp.

Referenced by ApplicationState(), displayStatus(), isPaused(), and pressPause().

bool mic::application::ApplicationState::quit_flag
private

Quit application flag.

Definition at line 264 of file ApplicationState.hpp.

Referenced by ApplicationState(), displayStatus(), Quit(), resetQuit(), and setQuit().

mic::configuration::Property<bool> mic::application::ApplicationState::single_step_mode
private

Property: single step mode.

Definition at line 270 of file ApplicationState.hpp.

Referenced by ApplicationState(), displayStatus(), isSingleStepModeOn(), and pressSingleStep().

bool mic::application::ApplicationState::using_ncurses
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().

bool mic::application::ApplicationState::using_opengl
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().


The documentation for this class was generated from the following files: