#include #include #include #include namespace creaImageIO { namespace tree { //============================================================= /// Ctor with parent Node::Node(Node* parent) : mParent(parent), mData(0), mChildrenLoaded(false) { if (parent) { // Insert into parent's children list parent->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(), "" ); } } } //============================================================= //============================================================= /// Ctor with parent and attributes map Node::Node(Node* parent, const AttributeMapType& attr) : mParent(parent), mData(0), mChildrenLoaded(false) { if (parent) { // Insert into parent's children list parent->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(), attr[a->GetKey()] ); } } } //============================================================= //============================================================= Node::~Node() { ChildrenListType::iterator i; for (i=GetChildrenList().begin(); i!=GetChildrenList().end(); i++) { delete *i; } if (mData) { delete mData; mData = 0; } } //============================================================= //============================================================= void Node::RemoveChildrenFromList(Node* node) { ChildrenListType::iterator i = find(GetChildrenList().begin(), GetChildrenList().end(), node); if (i != GetChildrenList().end()) { GetChildrenList().erase(i); } } //============================================================= //============================================================= const std::string& Node::GetAttribute(const std::string& k) const { // std::cout << "this = "<<(void*)this<second; } //============================================================= //============================================================= void Node::SetAttribute(const std::string& k, const std::string& v) { AttributeMapType::iterator i = mAttributeMap.find(k); if (i==mAttributeMap.end()) { std::cout<<"[Gimmick!] Node::SetAttribute : no attribute with key '" <second = v; } //============================================================= //============================================================= bool Node::Matches( const AttributeMapType& ) const { // TO DO return false; } //============================================================= } }