CMS 3D CMS Logo

DDSingleton.h
Go to the documentation of this file.
1 #ifndef DETECTOR_DESCRIPTION_DD_SINGLETON_H
2 #define DETECTOR_DESCRIPTION_DD_SINGLETON_H
3 
4 #include <memory>
5 
6 namespace cms {
7 
8  template< typename T, typename CONTEXT >
9  class DDSingleton
10  {
11  public:
12  T* operator->() { return m_instance.get(); }
13  const T* operator->() const { return m_instance; }
14  T& operator*() { return *m_instance; }
15  const T& operator*() const { return *m_instance; }
16 
17  static T *getInstance()
18  {
19  static bool static_init __attribute__(( unused )) = []()->bool {
20  m_instance = std::make_unique<T>();
21  return true;
22  }();
23  return m_instance.get();
24  }
25 
26  protected:
28  static bool static_init __attribute__(( unused )) = []()->bool {
29  m_instance = std::make_unique<T>();
30  return true;
31  }();
32  }
33 
34  DDSingleton( int ) {
35  static bool static_init __attribute__(( unused )) = []()->bool {
37  return true;
38  }();
39  }
40 
41  private:
42  static std::unique_ptr<T> m_instance;
43  };
44 }
45 
46 template < typename T, typename CONTEXT >
48 
49 #endif
int init
Definition: HydjetWrapper.h:67
float __attribute__((vector_size(8))) cms_float32x2_t
Definition: ExtVec.h:12
const T & operator*() const
Definition: DDSingleton.h:15
static std::unique_ptr< T > m_instance
Definition: DDSingleton.h:42
Namespace of DDCMS conversion namespace.
const T * operator->() const
Definition: DDSingleton.h:13
long double T
static T * getInstance()
Definition: DDSingleton.h:17