ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvSingleton.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
11 template <class T>
12 struct ecvSingleton {
14  ecvSingleton() : instance(nullptr) {}
18  inline void release() {
19  if (instance) {
20  delete instance;
21  instance = nullptr;
22  }
23  }
24 
27 };
Generic singleton encapsulation structure.
Definition: ecvSingleton.h:12
void release()
Releases the current instance.
Definition: ecvSingleton.h:18
T * instance
Current instance.
Definition: ecvSingleton.h:26
~ecvSingleton()
Destructor.
Definition: ecvSingleton.h:16
ecvSingleton()
Default constructor.
Definition: ecvSingleton.h:14