6#define MIN(A,B) (((A) < (B)) ? (A) : (B))
7#define MAX(A,B) (((A) > (B)) ? (A) : (B))
8#define BLIM(input,min,max) (input = (input>max)?max:((input<min)?min:input))
9#define LLIM(input,min) (input = (input<min)?min:input)
10#define ULIM(input,max) (input = (input>max)?max:input)
11#define LIMIT(A,B,C) (((A) < (B)) ? (B) : (((A) > (C)) ? (C) : (A)))
14inline size_t _Hash_value(_InIt _Begin, _InIt _End)
16 size_t _Val = 2166136261U;
18 while (_Begin != _End)
19 _Val = 16777619U * _Val ^ (size_t)*_Begin++;
35#define DEFINE_STATIC_STRING(name) static constexpr char const* name = #name;
36#define DEFINE_STATIC_STRING_EX(name,value) static constexpr char const* name = #value;
38#define SAFE_DELETE(obj) {delete obj; obj=nullptr;}
39#define SAFE_DELETE_VECTOR(vec) {for(auto i:vec) delete i; vec.clear();}
40#define SAFE_DELETE_ARRAY(ary) {delete [] ary; *ary=nullptr;}
42#define INVALIDATE_PROPERTY(name) \
46#define FORCE_INVALIDATE_PROPERTY(name) \
48 name->ForceInvalidate();
50#define ZERO_SCALAR(name) \
51 if(name!=nullptr && name->IsValid()) \
54#define ZERO_UNIT_SCALAR(name) \
55 if(name!=nullptr && name->IsValid()) \
56 name->SetValue(0,*name->GetUnit());
58#define COPY_PROPERTY(name) \
59 if(from.Has##name()) \
60 Get##name().Set(*from.m_##name);
62#define MERGE_CHILD_SUBS(name, subMgr) \
63 if(from.Has##name()) \
64 Get##name().Merge(*from.m_##name, subMgr);
66#define MERGE_CHILD(name) \
67 if(from.Has##name()) \
68 Get##name().Merge(*from.m_##name);
70#define CDM_COPY(clazz, from, to) \
72 auto* bind = clazz ::Unload(*from); \
73 clazz ::Load(*bind,*to); \
78inline void Copy(
const std::vector<T*>& from, std::vector<T*>& to)
81 to.resize(from.size());
82 std::copy(from.begin(), from.end(), to.begin());
86inline void Copy(
const std::vector<T>& from, std::vector<T>& to)
89 to.resize(from.size());
90 std::copy(from.begin(), from.end(), to.begin());
94inline bool Contains(
const std::vector<T*>& v, T& item)
96 return std::find(v.begin(), v.end(), &item) != v.end();
100inline void Remove(std::vector<T*>& v, T* item)
102 v.erase(std::remove(v.begin(), v.end(), item), v.end());
106inline void Copy(
const std::vector<T*>& from, std::vector<const T*>& to)
114inline void DELETE_VECTOR(std::vector<T>& vec)
116 for(
unsigned int i=0; i<vec.size(); i++)
123template<
class T,
class K>
124inline void DELETE_MAP_SECOND(std::map<T,K>& map)
126 for(
typename std::map<T,K>::iterator it=map.begin(); it != map.end(); ++it)
133template <
typename valueType>
134bool SameSign(valueType x, valueType y)
136 return (x >= 0) ^ (y < 0);