ACF $AcfVersion:0$
TCopySerializedWrap.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// ACF includes
6#include <istd/IChangeable.h>
7
8
9namespace iser
10{
11
12
14
19extern bool CopyByArchive(const istd::IChangeable& object, istd::IChangeable& result);
25extern bool CompareByArchive(const istd::IChangeable& object1, const istd::IChangeable& object2);
27
28
29template <class Base>
30class TCopySerializedWrap: public Base
31{
32public:
33 typedef Base BaseClass;
34
35 // pseudo-reimplemented (istd::IChangeable)
36 virtual int GetSupportedOperations() const override;
38 virtual bool IsEqual(const istd::IChangeable& object) const override;
39};
40
41
42// public methods
43
44// pseudo-reimplemented (istd::IChangeable)
45
46template <class Base>
48{
49 return BaseClass::GetSupportedOperations() | istd::IChangeable::SO_COPY | istd::IChangeable::SO_COMPARE;
50}
51
52
53template <class Base>
55{
56 if (BaseClass::CopyFrom(object, mode)){
57 return true;
58 }
59 else if (mode == BaseClass::CM_WITHOUT_REFS){
60 return CopyByArchive(object, *this);
61 }
62 else{
63 return false;
64 }
65}
66
67
68template <class Base>
70{
71 if ((BaseClass::GetSupportedOperations() & istd::IChangeable::SO_COMPARE) != 0){
72 return BaseClass::IsEqual(object);
73 }
74
75 return CompareByArchive(object, *this);
76}
77
78
79} // namespace iser
80
81
82
83
virtual bool IsEqual(const istd::IChangeable &object) const override
virtual int GetSupportedOperations() const override
virtual bool CopyFrom(const istd::IChangeable &object, istd::IChangeable::CompatibilityMode mode=istd::IChangeable::CM_WITHOUT_REFS) override
Common interface for data model objects, which can be changed.
Definition IChangeable.h:28
CompatibilityMode
Control how relationship betweeen objects are interpreted.
@ CM_WITHOUT_REFS
External references are simple ignored.
@ SO_COPY
Copying from other object.
@ SO_COMPARE
Comparison with another object.
Contains general persistence mechanism with basic archives implementations.