MachineIntelligenceCore:Toolchain
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ApplicationFactory.cpp
Go to the documentation of this file.
1 
24 
25 namespace mic {
26 namespace application {
27 
28 // Init application instance - as NULL.
29 boost::atomic<ApplicationFactory*> ApplicationFactory::instance_(NULL);
30 
31 // Initilize mutex.
33 
34 
35 
37  // Try to load the instance - first check.
38  ApplicationFactory* tmp = instance_.load(boost::memory_order_consume);
39  // If instance does not exist.
40  if (!tmp) {
41  // Enter critical section.
42  boost::mutex::scoped_lock guard(instantiation_mutex);
43  // Try to load the instance - second check.
44  tmp = instance_.load(boost::memory_order_consume);
45  // If still does not exist - create new instance.
46  if (!tmp) {
47  tmp = new ApplicationFactory;
48  instance_.store(tmp, boost::memory_order_release);
49  }//: if
50  // Exit critical section.
51  }//: if
52  // Return instance.
53  return tmp;
54 }
55 
56 
58  // NULL pointer - important!
59  internal_factory = nullptr;
60 }
61 
63  // TODO Auto-generated destructor stub
64 }
65 
66 } /* namespace application */
67 } /* namespace mic */
Contains declaration of application factory, used by common main files for initialization of applicat...
FactoryInterface * internal_factory
"Internal factory", responsible for returning of classes of different objects (applications).
static boost::atomic< ApplicationFactory * > instance_
static ApplicationFactory * getInstance()
Application factory, class responsible for generation of an application object. Defined in the form o...