/////////////////////////////////////////////////////////////////////////////////////////
//
// Please refer to "COPYRIGHT.md" for the relevant copyright statement of this software.
//
/////////////////////////////////////////////////////////////////////////////////////////
//
#ifndef GC_DBBOILER_H
#define GC_DBBOILER_H

#include "rxboiler.h"
#include "GcDbCore2dDefs.h"

class GcDbSystemInternals;

#define GCDB_DECLARE_HEAP_OPERATORS_COMMON(CLASSNAME, EXPIMP) \
  EXPIMP static void* operator new(std::size_t size);         \
  EXPIMP static void operator delete(void* ptr);

#if defined(_DEBUG) && __cplusplus > 201402
#  define GCDB_DECLARE_HEAP_OPERATORS(CLASSNAME, EXPIMP)                            \
    GCDB_DECLARE_HEAP_OPERATORS_COMMON(CLASSNAME, EXPIMP)                           \
    static void* operator new(std::size_t size, std::align_val_t, const char*, int) \
    {                                                                               \
      return CLASSNAME::operator new(size);                                         \
    }                                                                               \
    static void operator delete(void* p, std::align_val_t, const char*, int)        \
    {                                                                               \
      CLASSNAME::operator delete(p);                                                \
    }

#else
#  define GCDB_DECLARE_HEAP_OPERATORS(CLASSNAME, EXPIMP) GCDB_DECLARE_HEAP_OPERATORS_COMMON(CLASSNAME, EXPIMP)
#endif

#define GCDB_DECLARE_MEMBERS_ABSTRACT_EXPIMP(CLASSNAME, EXPIMP) \
private:                                                        \
  friend class GcDbSystemInternals;                             \
                                                                \
protected:                                                      \
  CLASSNAME(GcDbSystemInternals*);                              \
                                                                \
public:                                                         \
  GCRX_DECLARE_MEMBERS_EXPIMP(CLASSNAME, EXPIMP)

#define GCDB_DECLARE_MEMBERS_EXPIMP(CLASSNAME, EXPIMP)    \
  GCDB_DECLARE_MEMBERS_ABSTRACT_EXPIMP(CLASSNAME, EXPIMP) \
  GCDB_DECLARE_HEAP_OPERATORS(CLASSNAME, EXPIMP)

#define GCDB_DECLARE_MEMBERS(CLASSNAME) GCDB_DECLARE_MEMBERS_EXPIMP(CLASSNAME, GCRX_EMPTY)
#define GCDB_DECLARE_MEMBERS_ABSTRACT(CLASSNAME) GCDB_DECLARE_MEMBERS_ABSTRACT_EXPIMP(CLASSNAME, GCRX_EMPTY)
#define GCDBCORE2D_DECLARE_MEMBERS(CLASSNAME) GCDB_DECLARE_MEMBERS_EXPIMP(CLASSNAME, GCDB_PORT)

#if defined(_GSOFT_IOS_) || defined(_GSOFT_WEB_) || defined(_GSOFT_ANDROID_)
#  define GEOMENT_DECLARE_MEMBERS(CLASSNAME) GCDBCORE2D_DECLARE_MEMBERS(CLASSNAME);
#else
#  define GEOMENT_DECLARE_MEMBERS(CLASSNAME) GCDB_DECLARE_MEMBERS_EXPIMP(CLASSNAME, GCRX_EMPTY);
#endif

#endif