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

Method checkInvariant

plugins/e57/libE57Format/src/ImageFile.cpp:57–162  ·  view source on GitHub ↗

Put this function first so we can reference the code in doxygen using @skip ! @brief Check whether ImageFile class invariant is true @param [in] doRecurse If true, also check invariants of all children or sub-objects recursively. @details This function checks at least the assertions in the documented class invariant description (see class reference page for this object). Other internal invariant

Source from the content-addressed store, hash-verified

55@see Node::checkInvariant
56*/
57void ImageFile::checkInvariant( bool doRecurse ) const
58{
59 // If this ImageFile is not open, can't test invariant (almost every call
60 // would throw)
61 if ( !isOpen() )
62 {
63 return;
64 }
65
66 // root() node must be a root node
67 if ( !root().isRoot() )
68 {
69 throw E57_EXCEPTION1( ErrorInvarianceViolation );
70 }
71
72 // Can't have empty fileName
73 if ( fileName().empty() )
74 {
75 throw E57_EXCEPTION1( ErrorInvarianceViolation );
76 }
77
78 int wCount = writerCount();
79 int rCount = readerCount();
80
81 // Can't have negative number of readers
82 if ( rCount < 0 )
83 {
84 throw E57_EXCEPTION1( ErrorInvarianceViolation );
85 }
86
87 // Can't have negative number of writers
88 if ( wCount < 0 )
89 {
90 throw E57_EXCEPTION1( ErrorInvarianceViolation );
91 }
92
93 // Can't have more than one writer
94 if ( 1 < wCount )
95 {
96 throw E57_EXCEPTION1( ErrorInvarianceViolation );
97 }
98
99 // If have writer
100 if ( wCount > 0 )
101 {
102 // Must be in write-mode
103 if ( !isWritable() )
104 {
105 throw E57_EXCEPTION1( ErrorInvarianceViolation );
106 }
107
108 // Can't have any readers
109 if ( rCount > 0 )
110 {
111 throw E57_EXCEPTION1( ErrorInvarianceViolation );
112 }
113 }
114

Callers

nothing calls this directly

Calls 3

isOpenFunction · 0.85
isRootMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected