ImagingTools Core SDK
TIdentifiableWrap.h
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ImtCore-Commercial
2#pragma once
3
4
5// ACF includes
6#include <istd/CChangeGroup.h>
7
8// ImtCore includes
9#include <imtbase/CIdentifiable.h>
10
11
12namespace imtbase
13{
14
15
16template<class Base>
17class TIdentifiableWrap: public Base, public CIdentifiable
18{
19public:
20 typedef CIdentifiable BaseClass;
21
22 // reimplemented (iser::ISerializable)
23 virtual bool Serialize(iser::IArchive& archive) override;
24
25 // reimplemented (istd::IChangeable)
26 virtual int GetSupportedOperations() const override;
27 virtual bool CopyFrom(const IChangeable& object, CompatibilityMode mode = CM_WITHOUT_REFS) override;
28 virtual bool IsEqual(const istd::IChangeable& object) const override;
29 virtual istd::IChangeableUniquePtr CloneMe(CompatibilityMode mode = CM_WITHOUT_REFS) const override;
30 virtual bool ResetData(CompatibilityMode mode = CM_WITHOUT_REFS) override;
31};
32
33
34// public methods
35
36// reimplemented (iser::ISerializable)
37
38template<class Base>
39bool TIdentifiableWrap<Base>::Serialize(iser::IArchive& archive)
40{
41 bool retVal = BaseClass::Serialize(archive);
42
43 retVal = retVal && Base::Serialize(archive);
44
45 return retVal;
46}
47
48
49// reimplemented (IChangeable)
50
51template<class Base>
52int TIdentifiableWrap<Base>::GetSupportedOperations() const
53{
54 return Base::GetSupportedOperations();
55}
56
57
58template<class Base>
59bool TIdentifiableWrap<Base>::CopyFrom(const istd::IChangeable& object, CompatibilityMode mode)
60{
61 istd::CChangeGroup changeGroup(this);
62
63 bool retVal = Base::CopyFrom(object, mode);
64 retVal = retVal && BaseClass::CopyFrom(object, mode);
65
66 return retVal;
67}
68
69
70template<class Base>
71bool TIdentifiableWrap<Base>::IsEqual(const istd::IChangeable& object) const
72{
73 bool retVal = Base::IsEqual(object);
74 retVal = retVal && BaseClass::IsEqual(object);
75
76 return retVal;
77}
78
79
80template<class Base>
81istd::IChangeableUniquePtr TIdentifiableWrap<Base>::CloneMe(CompatibilityMode mode) const
82{
83 istd::IChangeableUniquePtr clonePtr(new TIdentifiableWrap<Base>());
84 if (clonePtr->CopyFrom(*this, mode)){
85 return clonePtr;
86 }
87
88 return nullptr;
89}
90
91
92template<class Base>
93bool TIdentifiableWrap<Base>::ResetData(CompatibilityMode mode)
94{
95 istd::CChangeGroup changeGroup(this);
96
97 bool retVal = Base::ResetData(mode);
98 retVal = retVal && BaseClass::ResetData(mode);
99
100 return retVal;
101}
102
103
104} // namespace imtbase
105
106