MachineIntelligenceCore:Toolchain
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Application.cpp
Go to the documentation of this file.
1 
24 
25 namespace mic {
26 namespace application {
27 
28 Application::Application(std::string node_name_) : PropertyTree(node_name_),
29  number_of_iterations("number_of_iterations",0)
30 {
31  // Register properties.
33 
34  // Reset iteration counter.
35  iteration = 0;
36 
37  // Register application in APP_STATE.
38  APP_STATE->setApplication(this);
39 }
40 
41 
43  // Iteration number.
44  LOG(LSTATUS) << "Iteration:\t\t" << iteration;
45 }
46 
47 
49 
50  // Main application loop.
51  while (!APP_STATE->Quit()) {
52 
53  // If not paused.
54  if (!APP_STATE->isPaused()) {
55  // If single step mode - pause after the step.
56  if (APP_STATE->isSingleStepModeOn())
57  APP_STATE->pressPause();
58 
59  // Enter critical section - with the use of scoped lock from AppState!
61 
62  // Perform single step and - if required - break the loop.
63  iteration++;
64  if (!performSingleStep()) {
65  LOG(LINFO) << "Terminating application...";
66  APP_STATE->setQuit();
67  break;
68  } else if (((long)number_of_iterations > 0) && ( (long)iteration >= (long) number_of_iterations)) {
69  LOG(LINFO) << "Reached last Iteration. Terminating application...";
70  APP_STATE->setQuit();
71  break;
72  }//: else if
73 
74  } //: if! is paused & end of critical section
75 
76  // Sleep.
77  APP_SLEEP();
78  }//: while
79 }
80 
81 } /* namespace application */
82 } /* namespace mic */
#define APP_SLEEP()
Macro which sleeps the application for a time specified by the sleep_interval variable stored in APP_...
virtual bool performSingleStep()=0
#define LINFO
Definition: LoggerAux.hpp:55
Contains declaration of a base class for all applications.
#define APP_STATE
Macro returning application state instance.
Application(std::string node_name_)
Definition: Application.cpp:28
#define APP_DATA_SYNCHRONIZATION_SCOPED_LOCK()
Macro creating a scoped lock with the use of data_synchronizaton_mutex stored by WindowManager.
mic::configuration::Property< long > number_of_iterations
Definition: Application.hpp:77
unsigned long iteration
Iteration counter.
Definition: Application.hpp:72
#define LSTATUS
Definition: LoggerAux.hpp:56
#define LOG(level)
Macro for message printing.
Definition: Log.hpp:39
void registerProperty(PropertyInterface &prop)