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
| 60 | StructureNode::checkInvariant, VectorNode::checkInvariant, CompressedVectorNode::checkInvariant |
| 61 | */ |
| 62 | void 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 | { |