memory.hpp
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <vector>
9 #include <mutex>
10 #include <ememory/SharedPtr.hpp>
11 #include <ememory/WeakPtr.hpp>
13 
17 namespace ememory {
23  template<class EMEMORY_TYPE, typename... EMEMORY_ARGS>
24  static ememory::SharedPtr<EMEMORY_TYPE> makeShared(EMEMORY_ARGS && ..._args) {
25  return ememory::SharedPtr<EMEMORY_TYPE>(new EMEMORY_TYPE(std::forward<EMEMORY_ARGS>(_args)...));
26  }
32  template<class EMEMORY_TYPE_CAST, class EMEMORY_TYPE>
34  return ememory::SharedPtr<EMEMORY_TYPE_CAST>(dynamic_cast<EMEMORY_TYPE_CAST*>(_obj.get()), _obj.getCounter());
35  }
41  template<class EMEMORY_TYPE_CAST, class EMEMORY_TYPE>
43  return ememory::SharedPtr<EMEMORY_TYPE_CAST>(dynamic_cast<EMEMORY_TYPE_CAST*>(const_cast<EMEMORY_TYPE*>(_obj.get())), _obj.getCounter());
44  }
50  template<class EMEMORY_TYPE_CAST, class EMEMORY_TYPE>
52  return ememory::SharedPtr<EMEMORY_TYPE_CAST>(static_cast<EMEMORY_TYPE_CAST*>(_obj.get()), _obj.getCounter());
53  }
59  template<class EMEMORY_TYPE_CAST, class EMEMORY_TYPE>
61  return ememory::SharedPtr<EMEMORY_TYPE_CAST>(static_cast<EMEMORY_TYPE_CAST*>(const_cast<EMEMORY_TYPE*>(_obj.get())), _obj.getCounter());
62  }
68  template<class EMEMORY_TYPE_CAST, class EMEMORY_TYPE>
70  return ememory::SharedPtr<EMEMORY_TYPE_CAST>(reinterpret_cast<EMEMORY_TYPE_CAST*>(_obj.get()), _obj.getCounter());
71  }
77  template<class EMEMORY_TYPE_CAST, class EMEMORY_TYPE>
79  return ememory::SharedPtr<EMEMORY_TYPE_CAST>(reinterpret_cast<EMEMORY_TYPE_CAST*>(const_cast<EMEMORY_TYPE*>(_obj.get())), _obj.getCounter());
80  }
86  template<class EMEMORY_TYPE_CAST, class EMEMORY_TYPE>
88  return ememory::SharedPtr<EMEMORY_TYPE_CAST>(const_cast<EMEMORY_TYPE*>(_obj.get()), _obj.getCounter());
89  }
90 }
ememory::SharedPtr< EMEMORY_TYPE_CAST > staticPointerCast(ememory::SharedPtr< EMEMORY_TYPE > &_obj)
Cast in static the input SharedPtr into an other type like static_cast on pointer.
Definition: memory.hpp:51
ememory::Counter * getCounter() const
Get Counter pointer.
Definition: SharedPtr.hpp:190
const EMEMORY_TYPE * get() const
Get a const pointer on the data.
ememory::SharedPtr< EMEMORY_TYPE_CAST > dynamicPointerCast(ememory::SharedPtr< EMEMORY_TYPE > &_obj)
Cast in Dynamic the input SharedPtr into an other type like dynamic_cast on pointer.
Definition: memory.hpp:33
Ememory is a namespace to represent the.
Definition: Counter.hpp:14
ememory::SharedPtr< EMEMORY_TYPE_CAST > reinterpretPointerCast(ememory::SharedPtr< EMEMORY_TYPE > &_obj)
Cast in reinterpret the input SharedPtr into an other type like reinterpret_cast on pointer...
Definition: memory.hpp:69
ememory::SharedPtr is a smart pointer that retains shared ownership of an object through a pointer...
Definition: SharedPtr.hpp:34
ememory::SharedPtr< EMEMORY_TYPE_CAST > constPointerCast(const ememory::SharedPtr< EMEMORY_TYPE > &_obj)
Cast in const the input SharedPtr into an other type like const_cast on pointer (remove constness) ...
Definition: memory.hpp:87