SingletonCreationPolicies.h
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // This file is part of FZIs ic_workspace.
5 //
6 // This program is free software licensed under the LGPL
7 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
8 // You can find a copy of this license in LICENSE folder in the top
9 // directory of the source code.
10 //
11 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
12 //
13 // -- END LICENSE BLOCK ------------------------------------------------
14 
15 //----------------------------------------------------------------------
29 //----------------------------------------------------------------------
30 #ifndef ICL_CORE_SINGLETON_CREATION_POLICIES_H_INCLUDED
31 #define ICL_CORE_SINGLETON_CREATION_POLICIES_H_INCLUDED
32 
33 #include <stdlib.h>
34 
35 namespace icl_core {
36 
38 template
39 <class T>
41 {
42 public:
43  static T *create()
44  {
45  return new T;
46  }
47 
48  static void destroy(T *object)
49  {
50  delete object;
51  }
52 };
53 
55 template
56 <class T>
58 {
59 public:
60  static T *create()
61  {
62  static T instance;
63  return &instance;
64  }
65 
66  static void destroy(T *object)
67  {
68  }
69 };
70 
72 template
73 <class T>
75 {
76 public:
77  static T *create()
78  {
79  return static_cast<T *>(malloc(sizeof(T)));
80  }
81 
82  static void destroy(T *object)
83  {
84  free(object);
85  }
86 };
87 
88 
89 }
90 
91 #endif
Creates and destroys objects using malloc() and free().
Creates and destroys objects using operator new and operator delete.
Creates objects as static function variables.


fzi_icl_core
Author(s):
autogenerated on Mon Jun 10 2019 13:17:58