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

Method isTypeEquivalent

plugins/e57/libE57Format/src/StructureNodeImpl.cpp:50–97  ·  view source on GitHub ↗

??? use visitor?

Source from the content-addressed store, hash-verified

48
49//??? use visitor?
50bool 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
99bool StructureNodeImpl::isDefined( const ustring &pathName )
100{

Callers

nothing calls this directly

Calls 6

atMethod · 0.80
typeMethod · 0.45
childCountMethod · 0.45
elementNameMethod · 0.45
isDefinedMethod · 0.45
lookupMethod · 0.45

Tested by

no test coverage detected