ROOT logo
// $Id: NewDelFunctions.h 2134 2007-11-30 18:07:51Z pcanal $

#ifndef Reflex_NewDelFunctions
#define Reflex_NewDelFunctions

/**
 * @file  NewDelFunctions.h
 */


namespace Reflex {

   typedef void* (*NewFunc_t)( void* );
   typedef void* (*NewArrFunc_t)( long size, void *arena );
   typedef void  (*DelFunc_t)( void* );
   typedef void  (*DelArrFunc_t)( void* );
   typedef void  (*DesFunc_t)( void* ); 

   struct RFLX_API NewDelFunctions {
      NewFunc_t    fNew;             //pointer to a function newing one object.
      NewArrFunc_t fNewArray;        //pointer to a function newing an array of objects.
      DelFunc_t    fDelete;          //pointer to a function deleting one object.
      DelArrFunc_t fDeleteArray;     //pointer to a function deleting an array of objects.
      DesFunc_t    fDestructor;      //pointer to a function call an object's destructor.
   };

   template <class T>  struct NewDelFunctionsT : public NewDelFunctions {
      static void* new_T(void* p) { return p ? new(p) T : new T; }
      static void* new_p_T(void* p) { return p ? new(p) T : ::new T; }
      static void* new_np_T(void* p) { return p ? ::new(p) T : new T; }
      static void* newArray_T(long size, void* p) { return p ? new (p) T[size] : new T[size]; }
      static void* newArray_p_T(long size, void* p) { return p ? new (p) T[size] : ::new T[size]; }
      static void* newArray_np_T(long size, void* p) { return p ? ::new (p) T[size] : new T[size]; }
      static void  delete_T(void *p) { delete (T*)p; }
      static void  deleteArray_T(void* p) { delete [] (T*)p; }
      static void  destruct_T(void* p) { ((T*)p)->~T(); }
      NewDelFunctionsT() {
         fNew         = new_T;
         fNewArray    = newArray_T;
         fDelete      = delete_T;
         fDeleteArray = deleteArray_T;
         fDestructor  = destruct_T;
      }      
   };


} // namespace reflex

#endif
 NewDelFunctions.h:1
 NewDelFunctions.h:2
 NewDelFunctions.h:3
 NewDelFunctions.h:4
 NewDelFunctions.h:5
 NewDelFunctions.h:6
 NewDelFunctions.h:7
 NewDelFunctions.h:8
 NewDelFunctions.h:9
 NewDelFunctions.h:10
 NewDelFunctions.h:11
 NewDelFunctions.h:12
 NewDelFunctions.h:13
 NewDelFunctions.h:14
 NewDelFunctions.h:15
 NewDelFunctions.h:16
 NewDelFunctions.h:17
 NewDelFunctions.h:18
 NewDelFunctions.h:19
 NewDelFunctions.h:20
 NewDelFunctions.h:21
 NewDelFunctions.h:22
 NewDelFunctions.h:23
 NewDelFunctions.h:24
 NewDelFunctions.h:25
 NewDelFunctions.h:26
 NewDelFunctions.h:27
 NewDelFunctions.h:28
 NewDelFunctions.h:29
 NewDelFunctions.h:30
 NewDelFunctions.h:31
 NewDelFunctions.h:32
 NewDelFunctions.h:33
 NewDelFunctions.h:34
 NewDelFunctions.h:35
 NewDelFunctions.h:36
 NewDelFunctions.h:37
 NewDelFunctions.h:38
 NewDelFunctions.h:39
 NewDelFunctions.h:40
 NewDelFunctions.h:41
 NewDelFunctions.h:42
 NewDelFunctions.h:43
 NewDelFunctions.h:44
 NewDelFunctions.h:45
 NewDelFunctions.h:46
 NewDelFunctions.h:47
 NewDelFunctions.h:48
 NewDelFunctions.h:49