SingletonCreationPolicies.h
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 
00003 // -- BEGIN LICENSE BLOCK ----------------------------------------------
00004 // This file is part of FZIs ic_workspace.
00005 //
00006 // This program is free software licensed under the LGPL
00007 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
00008 // You can find a copy of this license in LICENSE folder in the top
00009 // directory of the source code.
00010 //
00011 // © Copyright 2014 FZI Forschungszentrum Informatik, Karlsruhe, Germany
00012 //
00013 // -- END LICENSE BLOCK ------------------------------------------------
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


schunk_svh_driver
Author(s): Georg Heppner
autogenerated on Fri Aug 28 2015 12:59:19