1 #include <creaImageIOTreeNode.h>
2 #include <creaImageIOTree.h>
3 #include <creaMessageManager.h>
11 //=============================================================
13 Node::Node(Node* parent)
16 mChildrenLoaded(false)
20 // Insert into parent's children list
21 parent->GetChildrenList().push_back(this);
22 // Initialize attributes
23 LevelDescriptor::AttributeDescriptorListType::const_iterator a;
24 for (a = GetTree()->GetAttributeDescriptorList(GetLevel()).begin();
25 a!= GetTree()->GetAttributeDescriptorList(GetLevel()).end();
28 UnsafeSetAttribute( a->GetKey(), "" );
32 //=============================================================
34 //=============================================================
35 /// Ctor with parent and attributes map
36 Node::Node(Node* parent, const AttributeMapType& attr)
39 mChildrenLoaded(false)
43 // Insert into parent's children list
44 parent->GetChildrenList().push_back(this);
45 // Initialize attributes
46 LevelDescriptor::AttributeDescriptorListType::const_iterator a;
47 for (a = GetTree()->GetAttributeDescriptorList(GetLevel()).begin();
48 a!= GetTree()->GetAttributeDescriptorList(GetLevel()).end();
51 UnsafeSetAttribute( a->GetKey(), attr[a->GetKey()] );
56 //=============================================================
59 //=============================================================
62 ChildrenListType::iterator i;
63 for (i=GetChildrenList().begin(); i!=GetChildrenList().end(); i++)
73 //=============================================================
75 //=============================================================
76 void Node::RemoveChildrenFromList(Node* node)
78 ChildrenListType::iterator i = find(GetChildrenList().begin(),
79 GetChildrenList().end(),
81 if (i != GetChildrenList().end())
83 GetChildrenList().erase(i);
86 //=============================================================
88 //=============================================================
89 const std::string& Node::GetAttribute(const std::string& k) const
91 // std::cout << "this = "<<(void*)this<<std::endl;
92 // std::cout << "mFieldValueMap="<<(void*)(&mFieldValueMap)<<std::endl;
93 AttributeMapType::const_iterator i = mAttributeMap.find(k);
94 if (i == mAttributeMap.end())
96 static std::string def("");
98 // CREAIMAGEIO_ERROR("DicomNode::GetFieldValue : no field with key '"<<k<<"'");
102 //=============================================================
104 //=============================================================
105 void Node::SetAttribute(const std::string& k,
106 const std::string& v)
108 AttributeMapType::iterator i = mAttributeMap.find(k);
109 if (i==mAttributeMap.end())
111 std::cout<<"[Gimmick!] Node::SetAttribute : no attribute with key '"
113 creaError( "[Gimmick!] Node::SetAttribute : no attribute with key '"
118 //=============================================================
120 //=============================================================
121 bool Node::Matches( const AttributeMapType& ) const
126 //=============================================================