Arquivos
Onboard-SDK/osdk-core/utility/inc/dji_singleton.hpp
T
Rohit Sant 4c8d43f615 OSDK 3.3
2017-06-15 15:46:01 -07:00

68 linhas
920 B
C++

/** @file dji_singleton.hpp
* @version 3.3
* @date Jun 2017
*
* @brief Singleton Template Class implementation for use with the DJI OSDK
*
* @copyright 2017 DJI. All rights reserved.
*
*/
#ifndef SINGLETON_H
#define SINGLETON_H
namespace DJI
{
namespace OSDK
{
template <class T>
class Singleton
{
public:
typedef T type;
protected:
Singleton();
public:
virtual ~Singleton()
{
}
public:
static T& instance();
static T* instancePTR();
protected:
static T* singleInstance;
}; // class Singleton<T>
// template implementation
template <class T>
Singleton<T>::Singleton()
{
}
template <class T>
T&
Singleton<T>::instance()
{
return *Singleton<T>::singleInstance;
}
template <class T>
T*
Singleton<T>::instancePTR()
{
return Singleton<T>::singleInstance;
}
template <class T>
T* Singleton<T>::singleInstance = new T();
} // namespace OSDK
} // namespace DJI
#endif // SINGLETON_H