Singleton.h
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // This file is part of FZIs ic_workspace.
5 //
6 // This program is free software licensed under the LGPL
7 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
8 // You can find a copy of this license in LICENSE folder in the top
9 // directory of the source code.
10 //
11 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
12 //
13 // -- END LICENSE BLOCK ------------------------------------------------
14 
15 //----------------------------------------------------------------------
26 //----------------------------------------------------------------------
27 #ifndef ICL_CORE_SINGLETON_H_INCLUDED
28 #define ICL_CORE_SINGLETON_H_INCLUDED
29 
33 
34 namespace icl_core {
35 
50 template
51 <class T,
52  template <class> class TCreationPolicy = SCPCreateUsingNew,
53  template <class> class TLifetimePolicy = SLPDefaultLifetime,
54  template <class> class TThreadingModel = STMSingleThreaded>
55 class Singleton
56 {
57 public:
59  static T& instance();
60 
61 private:
63  Singleton();
65  ~Singleton();
67  Singleton(const Singleton&);
70 
72  static void destroySingleton();
74  static T *m_instance;
76  static bool m_destroyed;
78  static typename TThreadingModel<T>::Lock m_lock;
79 };
80 
81 }
82 
83 #endif
static TThreadingModel< T >::Lock m_lock
The lock for synchronizing instantiation. Must be default-constructable.
Definition: Singleton.h:78
Contains lifetime policies for icl_core::Singleton.
Singleton()
Forbid creation.
static bool m_destroyed
Indicates whether the instance has been destroyed.
Definition: Singleton.h:76
Singleton & operator=(const Singleton &)
Forbid assignment.
Contains a basic threading model for icl_core::Singleton.
static void destroySingleton()
Helper for destroying the instance.
Definition: Singleton.hpp:64
~Singleton()
Forbid deletion.
static T & instance()
Provide access to the singleton instance.
Definition: Singleton.hpp:37
static T * m_instance
The singleton instance.
Definition: Singleton.h:74
Contains creation policies for icl_core::Singleton.


fzi_icl_core
Author(s):
autogenerated on Mon Jun 10 2019 13:17:58