22 #ifndef CRNOBJECT_HEADER
23 #define CRNOBJECT_HEADER
44 UObject
Clone(
const UCObject &obj);
45 UObject
Clone(
const SCObject &obj);
47 std::unique_ptr<Int>
Clone(
int i);
49 std::unique_ptr<Real>
Clone(
double d);
51 std::unique_ptr<Prop3>
Clone(
bool b);
53 template<
typename T,
typename U>
inline std::unique_ptr<T>
CloneAs(
const U &obj) {
return std::unique_ptr<T>(
dynamic_cast<T*
>(
Clone(obj).release())); }
61 void Deserialize(
const UObject &obj, xml::Element &el);
62 void Deserialize(
const SObject &obj, xml::Element &el);
64 xml::Element
Serialize(
const Object &obj, xml::Element &parent);
65 xml::Element
Serialize(
const UCObject &obj, xml::Element &parent);
66 xml::Element
Serialize(
const SCObject &obj, xml::Element &parent);
69 double Distance(
const Object &o1,
const Object &o2);
71 double Distance(
const UCObject &o1,
const UCObject &o2);
73 double Distance(
const SCObject &o1,
const SCObject &o2);
82 template<
typename T>
struct IsPOSet:
public std::integral_constant<bool, traits::HasLT<T>::value && traits::HasGT<T>::value && traits::HasLE<T>::value && traits::HasGE<T>::value> {};
88 template<
typename T>
struct IsMetric:
public std::integral_constant<bool, std::is_arithmetic<T>::value> {};
90 template<>
struct IsMetric<UObject>:
public std::true_type {};
91 template<>
struct IsMetric<SObject>:
public std::true_type {};
97 template<
typename T>
struct IsMagma:
public std::integral_constant<bool, traits::HasEquals<T>::value && traits::HasPlus<T>::value> {};
103 template<
typename T>
struct IsGroup:
public std::integral_constant<bool, IsMagma<T>::value && traits::HasMinus<T>::value> {};
110 template<
typename T>
struct IsRing:
public std::integral_constant<bool, IsGroup<T>::value && traits::HasInnerMult<T>::value> {};
118 template<
typename T>
struct IsVectorOverR:
public std::integral_constant<bool, IsGroup<T>::value && traits::HasRightOuterMult<T>::value && traits::HasLeftOuterMult<T>::value> {};
127 template<
typename T>
struct IsAlgebra:
public std::integral_constant<bool, IsRing<T>::value && IsVectorOverR<T>::value> {};
137 template<
typename T>
struct IsField:
public std::integral_constant<bool, IsAlgebra<T>::value && traits::HasDivide<T>::value> {};
150 template<
typename T>
struct IsClonable:
public std::false_type {};
158 template<
typename T>
struct IsSavable:
public std::false_type {};
165 #define CRN_SERIALIZATION_CONSTRUCTOR(classname) public: classname(crn::xml::Element &el) { Deserialize(el); }
173 #define CRN_DECLARE_CLASS_CONSTRUCTOR(classname) public:\
174 static void Initialize();\
176 struct Init { Init() { classname::Initialize(); } };\
185 #define CRN_BEGIN_CLASS_CONSTRUCTOR(classname) void classname::Initialize()\
187 static bool init_done = false;\
198 #define CRN_END_CLASS_CONSTRUCTOR(classname) }\
200 classname::Init classname::init;
xml::Element Serialize(const Object &obj, xml::Element &parent)
Writes an object to XML if possible.
virtual ~Object()=default
Interface class for the metric real number class.
double Distance(const Int &i1, const Int &i2) noexcept
Interface class for the metric real number class.
CRN_ALIAS_SMART_PTR(ImageBW)
void Deserialize(Object &obj, xml::Element &el)
Reads an object from XML if possible.
UObject Clone(const Object &obj)
Clones an object if possible.
std::unique_ptr< T > CloneAs(const U &obj)