@@ -24,6 +24,10 @@ class HdfObject {
24
24
: endFunction(endFunction)
25
25
, id(id) {
26
26
}
27
+ HdfDestroyer (const HdfDestroyer& other)
28
+ : endFunction(other.endFunction)
29
+ , id(other.id) {
30
+ }
27
31
~HdfDestroyer () {
28
32
endFunction (id);
29
33
}
@@ -38,14 +42,24 @@ class HdfObject {
38
42
// / then the destructor of the destroyer will call the end access function.
39
43
class HdfDestroyerChain {
40
44
public:
41
- HdfDestroyerChain () {
42
- }
43
- HdfDestroyerChain (const HdfDestroyerChain &other)
45
+ HdfDestroyerChain () = default ;
46
+ HdfDestroyerChain (const HdfDestroyerChain &other) noexcept
44
47
: chain(other.chain) {
45
48
}
49
+ HdfDestroyerChain (HdfDestroyerChain &&other) noexcept
50
+ : chain(std::move(other.chain)) {
51
+ }
52
+ HdfDestroyerChain &operator =(const HdfDestroyerChain &other) noexcept {
53
+ chain = other.chain ; // copy
54
+ return *this ;
55
+ }
56
+ HdfDestroyerChain &operator =(HdfDestroyerChain &&other) noexcept {
57
+ chain = std::move (other.chain );
58
+ return *this ;
59
+ }
46
60
47
- void pushBack (HdfDestroyer *destroyer ) {
48
- chain.push_back (std::shared_ptr< HdfDestroyer>(destroyer ));
61
+ void emplaceBack ( const std::function<int32(int32)> &endFunction, int32 id ) {
62
+ chain.emplace_back ( new HdfDestroyer (endFunction, id ));
49
63
}
50
64
51
65
private:
@@ -54,12 +68,12 @@ class HdfObject {
54
68
55
69
public:
56
70
// / \returns the type of the object
57
- virtual Type getType () const {
71
+ virtual Type getType () const noexcept {
58
72
return type;
59
73
}
60
74
61
75
// / \returns the class type of the object
62
- virtual ClassType getClassType () const {
76
+ virtual ClassType getClassType () const noexcept {
63
77
return classType;
64
78
}
65
79
@@ -69,16 +83,21 @@ class HdfObject {
69
83
, classType(classType)
70
84
, chain(chain) {
71
85
}
86
+ HdfObject (const Type &type, const ClassType &classType, HdfDestroyerChain &&chain)
87
+ : type(type)
88
+ , classType(classType)
89
+ , chain(std::move(chain)) {
90
+ }
72
91
HdfObject (const HdfObject *object)
73
92
: type(object->getType ())
74
93
, classType(object->getClassType ())
75
94
, chain(object->chain) {
76
95
}
77
96
78
- virtual void setType (const Type &type) {
97
+ virtual void setType (const Type &type) noexcept {
79
98
this ->type = type;
80
99
}
81
- virtual void setClassType (const ClassType &classType) {
100
+ virtual void setClassType (const ClassType &classType) noexcept {
82
101
this ->classType = classType;
83
102
}
84
103
0 commit comments