ArcGIS Procedural Runtime  3.2.10650
Singleton.h
1 /*
2  COPYRIGHT (c) 2012-2024 Esri R&D Center Zurich
3  TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
4  Unpublished material - all rights reserved under the
5  Copyright Laws of the United States and applicable international
6  laws, treaties, and conventions.
7 
8  For additional information, contact:
9  Environmental Systems Research Institute, Inc.
10  Attn: Contracts and Legal Services Department
11  380 New York Street
12  Redlands, California, 92373
13  USA
14 
15  email: contracts@esri.com
16 */
17 
18 #ifndef PRTX_SINGLETON_H_
19 #define PRTX_SINGLETON_H_
20 
21 namespace prtx {
22 
23 
31 template<typename S> class Singleton {
32 public:
33  static S* instance() {
34  if (!mInstance)
35  mInstance = S::createInstance();
36  return mInstance;
37  }
38 
44  static S* createInstance();
45 
46 protected:
47  Singleton() { }
48  Singleton(const Singleton&) = delete;
49  Singleton& operator=(const Singleton&) = delete;
50  ~Singleton() { }
51 
52 private:
53  static S* mInstance;
54 };
55 
56 template<typename S> S* Singleton<S>::mInstance = 0;
57 
58 
59 } // namespace prtx
60 
61 
62 #endif /* PRTX_SINGLETON_H_ */
static S * createInstance()
The Procedural Runtime eXtension namespace. The prtx namespace contains the tools to extend the Proce...
Definition: AnnotationBuilder.h:35
Definition: Singleton.h:31