MCPcopy Create free account
hub / github.com/PDAL/PDAL / checkInvariant

Method checkInvariant

plugins/e57/libE57Format/src/Node.cpp:62–262  ·  view source on GitHub ↗

Put this function first so we can reference the code in doxygen using @skip ! @brief Check whether Node class invariant is true @param [in] doRecurse If true, also check invariants of all children or sub-objects recursively. @param [in] doDowncast If true, also check any invariants of the actual derived type in addition to the generic node invariants. @details This function checks at least the a

Source from the content-addressed store, hash-verified

60StructureNode::checkInvariant, VectorNode::checkInvariant, CompressedVectorNode::checkInvariant
61*/
62void Node::checkInvariant( bool doRecurse, bool doDowncast )
63{
64 ImageFile imf = destImageFile();
65
66 // If destImageFile not open, can't test invariant (almost every call would throw)
67 if ( !imf.isOpen() )
68 {
69 return;
70 }
71
72 // Parent attachment state is same as this attachment state
73 if ( isAttached() != parent().isAttached() )
74 {
75 throw E57_EXCEPTION1( ErrorInvarianceViolation );
76 }
77
78 // Parent destination ImageFile is same as this
79 if ( imf != parent().destImageFile() )
80 {
81 throw E57_EXCEPTION1( ErrorInvarianceViolation );
82 }
83
84 // If this is the ImageFile root node
85 if ( *this == imf.root() )
86 {
87 // Must be attached
88 if ( !isAttached() )
89 {
90 throw E57_EXCEPTION1( ErrorInvarianceViolation );
91 }
92
93 // Must be is a root node
94 if ( !isRoot() )
95 {
96 throw E57_EXCEPTION1( ErrorInvarianceViolation );
97 }
98 }
99
100 // If this is a root node
101 if ( isRoot() )
102 {
103 // Absolute pathName is "/"
104 if ( pathName() != "/" )
105 {
106 throw E57_EXCEPTION1( ErrorInvarianceViolation );
107 }
108
109 // parent() returns this node
110 if ( *this != parent() )
111 {
112 throw E57_EXCEPTION1( ErrorInvarianceViolation );
113 }
114 }
115 else
116 {
117 // Non-root can't be own parent
118 if ( *this == parent() )
119 {

Callers

nothing calls this directly

Calls 11

typeFunction · 0.50
isOpenMethod · 0.45
isAttachedMethod · 0.45
destImageFileMethod · 0.45
rootMethod · 0.45
isRootMethod · 0.45
pathNameMethod · 0.45
typeMethod · 0.45
isDefinedMethod · 0.45
getMethod · 0.45
parentMethod · 0.45

Tested by

no test coverage detected