1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2020] [HCL Technologies Ltd.] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /* This file constains a singleton class template */
21 #ifndef __SINGLETON_HPP__
22 #define __SINGLETON_HPP__
29 static T *instancePtr();
39 /* Define and initialize the static instance pointer */
41 T* Singleton<T>::mPtr = 0;
44 /**********************************************************************
45 Description : Check if instance already exists.
46 Create a new instance if none exists
48 Return : Reference to the instance
49 ***********************************************************************/
51 T& Singleton<T>::instance()
61 /**********************************************************************
62 Description : Check if instance already exists.
63 Create a new instance if none exists
65 Return : Pointer to the instance
66 ***********************************************************************/
68 T *Singleton<T>::instancePtr()
75 /**********************************************************************
77 **********************************************************************/