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

Method checkInvariant

plugins/e57/libE57Format/src/StructureNode.cpp:42–86  ·  view source on GitHub ↗

Put this function first so we can reference the code in doxygen using @skip ! @brief Check whether StructureNode class invariant is true @copydetails IntegerNode::checkInvariant() */

Source from the content-addressed store, hash-verified

40@copydetails IntegerNode::checkInvariant()
41*/
42void StructureNode::checkInvariant( bool doRecurse, bool doUpcast ) const
43{
44 // If destImageFile not open, can't test invariant (almost every call would throw)
45 if ( !destImageFile().isOpen() )
46 {
47 return;
48 }
49
50 // If requested, call Node::checkInvariant
51 if ( doUpcast )
52 {
53 static_cast<Node>( *this ).checkInvariant( false, false );
54 }
55
56 // Check each child
57 for ( int64_t i = 0; i < childCount(); i++ )
58 {
59 Node child = get( i );
60
61 // If requested, check children recursively
62 if ( doRecurse )
63 {
64 child.checkInvariant( doRecurse, true );
65 }
66
67 // Child's parent must be this
68 if ( static_cast<Node>( *this ) != child.parent() )
69 {
70 throw E57_EXCEPTION1( ErrorInvarianceViolation );
71 }
72
73 // Child's elementName must be defined
74 if ( !isDefined( child.elementName() ) )
75 {
76 throw E57_EXCEPTION1( ErrorInvarianceViolation );
77 }
78
79 // Getting child by element name must yield same child
80 Node n = get( child.elementName() );
81 if ( n != child )
82 {
83 throw E57_EXCEPTION1( ErrorInvarianceViolation );
84 }
85 }
86}
87
88/*!
89@class e57::StructureNode

Callers

nothing calls this directly

Calls 4

getFunction · 0.50
isOpenMethod · 0.45
parentMethod · 0.45
elementNameMethod · 0.45

Tested by

no test coverage detected