X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src2%2FcreaImageIOTreeNode.cpp;h=4335dfe05b365e30de98d43ee5c4737e014854fd;hb=f08880c40f6304be640c7f8702bbbe96f8d50b40;hp=6bb7d3a7d8bc42ce3d0eda23e3ef8332691f2171;hpb=9bcef355910f147e16a71ae068c1dcb99c1686de;p=creaImageIO.git diff --git a/src2/creaImageIOTreeNode.cpp b/src2/creaImageIOTreeNode.cpp index 6bb7d3a..4335dfe 100644 --- a/src2/creaImageIOTreeNode.cpp +++ b/src2/creaImageIOTreeNode.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -17,16 +18,16 @@ namespace creaImageIO { if (parent) { + GimmickMessage(5,"Default Node constructor (level "<GetChildrenList().push_back(this); - // Initialize attributes - LevelDescriptor::AttributeDescriptorListType::const_iterator a; - for (a = GetTree()->GetAttributeDescriptorList(GetLevel()).begin(); - a!= GetTree()->GetAttributeDescriptorList(GetLevel()).end(); - ++a) - { - UnsafeSetAttribute( a->GetKey(), "" ); - } + InitializeAttributeMap(); + } + else + { + GimmickMessage(5,"Default Node constructor without parent" + << std::endl); } } //============================================================= @@ -38,7 +39,9 @@ namespace creaImageIO mData(0), mChildrenLoaded(false) { - if (parent) + GimmickMessage(5,"Node constructor (level "<GetChildrenList().push_back(this); @@ -48,7 +51,15 @@ namespace creaImageIO a!= GetTree()->GetAttributeDescriptorList(GetLevel()).end(); ++a) { - UnsafeSetAttribute( a->GetKey(), attr[a->GetKey()] ); + std::string v; + AttributeMapType::const_iterator i = attr.find(a->GetKey()); + if ( i != attr.end() ) + { + v = i->second; + } + GimmickMessage(5,"Setting attribute '"<GetName()<<"' = '" + <GetKey(), v ); } } @@ -59,6 +70,8 @@ namespace creaImageIO //============================================================= Node::~Node() { + GimmickMessage(5,"Node destructor" + << std::endl); ChildrenListType::iterator i; for (i=GetChildrenList().begin(); i!=GetChildrenList().end(); i++) { @@ -72,7 +85,31 @@ namespace creaImageIO } //============================================================= - //============================================================= + + //============================================================= + /// Initializes the attribute map i.e. creates the entries + void Node::InitializeAttributeMap() + { + // Initialize attributes + LevelDescriptor::AttributeDescriptorListType::const_iterator a; + for (a = GetTree()->GetAttributeDescriptorList(GetLevel()).begin(); + a!= GetTree()->GetAttributeDescriptorList(GetLevel()).end(); + ++a) + { + UnsafeSetAttribute( a->GetKey(), "" ); + } + } + //============================================================= + + //============================================================= + /// Returns the level descriptor of the node + const LevelDescriptor& Node::GetLevelDescriptor() const + { + return GetTree()->GetLevelDescriptor(GetLevel()); + } + //============================================================= + + //============================================================= void Node::RemoveChildrenFromList(Node* node) { ChildrenListType::iterator i = find(GetChildrenList().begin(), @@ -118,12 +155,70 @@ namespace creaImageIO //============================================================= //============================================================= - bool Node::Matches( const AttributeMapType& ) const + bool Node::Matches( const AttributeMapType& m ) const { - // TO DO - return false; + GimmickMessage(2,"'"<& id + = GetLevelDescriptor().GetIdentifierList(); + std::vector::const_iterator i; + for (i = id.begin(); i != id.end(); ++i) + { + if (mAttributeMap.find(*i)->second != m.find(*i)->second ) + { + GimmickMessage(2,"IDENTIFIER '"<<*i<<"' values do not match"<Print(); + } } //============================================================= + + //============================================================= + std::string Node::GetLabel() const + { + std::string l; + const std::vector& label + = GetLevelDescriptor().GetLabelList(); + + std::vector::const_iterator i; + for (i = label.begin(); i != label.end(); ) + { + GimmickMessage(3,"LABEL '"<<*i<<"'"<second; + ++i; + if (i != label.end()) l += "|"; + } + else + { + GimmickError("Node::GetLabel() : LABEL attribute '" + <<*i + <<"' is not in node attribute map (should be!)" ); + } + } + if (l.size()==0) l="?"; + return l; + } + //============================================================= + } }