Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00029 
00030 #ifndef ICL_CORE_SINGLETON_CREATION_POLICIES_H_INCLUDED
00031 #define ICL_CORE_SINGLETON_CREATION_POLICIES_H_INCLUDED
00032 
00033 #include <stdlib.h>
00034 
00035 namespace icl_core {
00036 
00038 template
00039 <class T>
00040 class SCPCreateUsingNew
00041 {
00042 public:
00043   static T *create()
00044   {
00045     return new T;
00046   }
00047 
00048   static void destroy(T *object)
00049   {
00050     delete object;
00051   }
00052 };
00053 
00055 template
00056 <class T>
00057 class SCPCreateStatic
00058 {
00059 public:
00060   static T *create()
00061   {
00062     static T instance;
00063     return &instance;
00064   }
00065 
00066   static void destroy(T *object)
00067   {
00068   }
00069 };
00070 
00072 template
00073 <class T>
00074 class SCPCreateUsingMalloc
00075 {
00076 public:
00077   static T *create()
00078   {
00079     return static_cast<T *>(malloc(sizeof(T)));
00080   }
00081 
00082   static void destroy(T *object)
00083   {
00084     free(object);
00085   }
00086 };
00087 
00088 
00089 }
00090 
00091 #endif