ArcGIS Procedural Runtime  3.4.12206
Singleton.h
1 /*
2  COPYRIGHT (c) 2012-2026 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 #pragma once
19 
20 namespace prtx {
21 
22 
30 template<typename S>
31 class Singleton {
32 public:
37  static S* instance() {
38  if (!mInstance)
39  mInstance = S::createInstance();
40  return mInstance;
41  }
42 
43 protected:
44  Singleton() = default;
45  Singleton(const Singleton&) = delete;
46  Singleton& operator=(const Singleton&) = delete;
47  ~Singleton() = default;
48 
49 private:
50  static S* mInstance;
51 };
52 
53 template<typename S> S* Singleton<S>::mInstance = nullptr;
54 
55 
56 } // namespace prtx
static S * instance()
Definition: Singleton.h:37
The Procedural Runtime eXtension namespace. The prtx namespace contains the tools to extend the Proce...
Definition: AnnotationBuilder.h:35
Definition: Singleton.h:31