From 6123df30e2e3643556c78000f26542e353f5bbde Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 10 Mar 2016 23:27:58 +0100 Subject: [PATCH] [DEV] add basic memory interface --- ememory/debug.cpp | 15 +++++++++++++++ ememory/debug.h | 45 ++++++++++++++++++++++++++++++++++++++++++++ ememory/memory.h | 26 +++++++++++++++++++++++++ lutin_ememory.py | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 134 insertions(+) create mode 100644 ememory/debug.cpp create mode 100644 ememory/debug.h create mode 100644 ememory/memory.h create mode 100644 lutin_ememory.py diff --git a/ememory/debug.cpp b/ememory/debug.cpp new file mode 100644 index 0000000..7fc567c --- /dev/null +++ b/ememory/debug.cpp @@ -0,0 +1,15 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license APACHE v2.0 (see license file) + */ + +#include + +int32_t ememory::getLogId() { + static int32_t g_val = elog::registerInstance("ememory"); + return g_val; +} + diff --git a/ememory/debug.h b/ememory/debug.h new file mode 100644 index 0000000..7d820ec --- /dev/null +++ b/ememory/debug.h @@ -0,0 +1,45 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license APACHE v2.0 (see license file) + */ +#pragma once + +#include +#include + +namespace ememory { + int32_t getLogId(); +}; + +#define EMEMORY_BASIC(info,data) EMEMORY_BASE(ememory::getLogId(),info,data) + +#define EMEMORY_PRINT(data) EMEMORY_BASIC(-1, data) +#define EMEMORY_CRITICAL(data) EMEMORY_BASIC(1, data) +#define EMEMORY_ERROR(data) EMEMORY_BASIC(2, data) +#define EMEMORY_WARNING(data) EMEMORY_BASIC(3, data) +#ifdef DEBUG + #define EMEMORY_INFO(data) EMEMORY_BASIC(4, data) + #define EMEMORY_DEBUG(data) EMEMORY_BASIC(5, data) + #define EMEMORY_VERBOSE(data) EMEMORY_BASIC(6, data) + #define EMEMORY_TODO(data) EMEMORY_BASIC(4, "TODO : " << data) +#else + #define EMEMORY_INFO(data) do { } while(false) + #define EMEMORY_DEBUG(data) do { } while(false) + #define EMEMORY_VERBOSE(data) do { } while(false) + #define EMEMORY_TODO(data) do { } while(false) +#endif + +#define EMEMORY_HIDDEN(data) do { } while(false) + +#define EMEMORY_ASSERT(cond,data) \ + do { \ + if (!(cond)) { \ + EMEMORY_CRITICAL(data); \ + assert(!#cond); \ + } \ + } while (0) + + diff --git a/ememory/memory.h b/ememory/memory.h new file mode 100644 index 0000000..4fabc8a --- /dev/null +++ b/ememory/memory.h @@ -0,0 +1,26 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license APACHE v2.0 (see license file) + */ +#pragma once + +#include +#include +#include + +namespace ememory { + template + using SharedPtr = std::shared_ptr; + template + using WeakPtr = std::weak_ptr; + template + using EnableSharedFromThis = std::enable_shared_from_this; + /* + template + using DynamicPointerCastZZ = std::dynamic_pointer_cast; + */ +} + diff --git a/lutin_ememory.py b/lutin_ememory.py new file mode 100644 index 0000000..f32bf7e --- /dev/null +++ b/lutin_ememory.py @@ -0,0 +1,48 @@ +#!/usr/bin/python +import lutin.module as module +import lutin.tools as tools + + +def get_type(): + return "LIBRARY" + +def get_desc(): + return "Ewol memory basic interface (have a thread safe shared_ptr with constness)" + +def get_licence(): + return "APACHE-2" + +def get_compagny_type(): + return "com" + +def get_compagny_name(): + return "atria-soft" + +def get_maintainer(): + return ["Mr DUPIN Edouard "] + +def get_version(): + return [0,1,"dev"] + +def create(target, module_name): + my_module = module.Module(__file__, module_name, get_type()) + my_module.add_extra_compile_flags() + # add the file to compile: + my_module.add_src_file([ + 'ememory/debug.cpp' + ]) + + my_module.add_header_file([ + 'ememory/memory.h', + ]) + + # build in C++ mode + my_module.compile_version("c++", 2011) + # add dependency of the generic C++ library: + my_module.add_module_depend('cxx') + my_module.add_optionnal_module_depend('elog') + + my_module.add_path(tools.get_current_path(__file__)) + return my_module + +