??? use visitor?
| 48 | |
| 49 | //??? use visitor? |
| 50 | bool StructureNodeImpl::isTypeEquivalent( NodeImplSharedPtr ni ) |
| 51 | { |
| 52 | // don't checkImageFileOpen |
| 53 | |
| 54 | // Same node type? |
| 55 | if ( ni->type() != TypeStructure ) |
| 56 | { |
| 57 | return ( false ); |
| 58 | } |
| 59 | |
| 60 | // Downcast to shared_ptr<StructureNodeImpl> |
| 61 | std::shared_ptr<StructureNodeImpl> si( std::static_pointer_cast<StructureNodeImpl>( ni ) ); |
| 62 | |
| 63 | // Same number of children? |
| 64 | if ( childCount() != si->childCount() ) |
| 65 | { |
| 66 | return ( false ); |
| 67 | } |
| 68 | |
| 69 | // Check each child is equivalent |
| 70 | for ( unsigned i = 0; i < childCount(); i++ ) |
| 71 | { //??? vector iterator? |
| 72 | ustring myChildsFieldName = children_.at( i )->elementName(); |
| 73 | // Check if matching field name is in same position (to speed things up) |
| 74 | if ( myChildsFieldName == si->children_.at( i )->elementName() ) |
| 75 | { |
| 76 | if ( !children_.at( i )->isTypeEquivalent( si->children_.at( i ) ) ) |
| 77 | { |
| 78 | return ( false ); |
| 79 | } |
| 80 | } |
| 81 | else |
| 82 | { |
| 83 | // Children in different order, so lookup by name and check if equal to our child |
| 84 | if ( !si->isDefined( myChildsFieldName ) ) |
| 85 | { |
| 86 | return ( false ); |
| 87 | } |
| 88 | if ( !children_.at( i )->isTypeEquivalent( si->lookup( myChildsFieldName ) ) ) |
| 89 | { |
| 90 | return ( false ); |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | // Types match |
| 96 | return ( true ); |
| 97 | } |
| 98 | |
| 99 | bool StructureNodeImpl::isDefined( const ustring &pathName ) |
| 100 | { |
nothing calls this directly
no test coverage detected