Public Types | Public Member Functions | Private Attributes

creaImageIO::tree::Tree Class Reference
[Attributed tree management]

An attributed Tree structure. More...

#include <creaImageIOTree.h>

Inheritance diagram for creaImageIO::tree::Tree:
Inheritance graph
[legend]
Collaboration diagram for creaImageIO::tree::Tree:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::map< std::string,
std::string > 
AttributeMapType
typedef std::vector< Node * > ChildrenListType
 The type of children container.

Public Member Functions

 Tree ()
 Ctor.
virtual ~Tree ()
 Virtual destructor.
virtual TreeGetTree ()
 Returns the descriptor of the tree.
virtual const TreeGetTree () const
 Returns the tree to which the node belongs.
virtual int GetLevel () const
 Returns the level of the node in the tree.
const DescriptorGetDescriptor () const
 Returns the Descriptor of the tree (const).
DescriptorGetDescriptor ()
 Returns the descriptor of the tree.
unsigned int GetNumberOfLevels ()
 Returns the number of levels of the tree.
const LevelDescriptorGetLevelDescriptor (int level) const
 Returns the LevelDescriptor of a given level (const ref).
const
LevelDescriptor::AttributeDescriptorListType
GetAttributeDescriptorList (int level, int type=0) const
virtual void Print () const
 Print the node.
void CopyAttributeDescriptorList (int level)
 Copy descriptor list without ID tag.
const std::string isAttributeExist (const std::string i_attr)
 Test if this attribute is available in this tree description.
void InitializeAttributeMap ()
 Initializes the attribute map i.e. creates the entries.
const LevelDescriptorGetLevelDescriptor () const
 Returns the level descriptor of the node.
NodeGetParent () const
 Returns the parent of the node.
unsigned int GetNumberOfChildren () const
bool GetChildrenLoaded () const
 Returns true iff the node's children are loaded.
void SetChildrenLoaded (bool l)
 Sets the node's children.
ChildrenListTypeGetChildrenList ()
 Returns the list of children.
const ChildrenListTypeGetChildrenList () const
 Returns the list of children (const).
int RemoveChildrenFromList (Node *)
 Remove the given children from the children list.
AttributeMapTypeGetAttributeMap ()
 Get the Attributes Map.
const AttributeMapTypeGetAttributeMap () const
 Get the Attributes Map.
const std::string & GetAttribute (const std::string &k) const
 Get the Attribute for a specific key.
const std::string & GetCleanAttribute (const std::string &k) const
 Get the Attribute for a specific key without OS dependance (not implemented).
void SetAttribute (const std::string &k, const std::string &v)
 Set an Attribute for a specific key.
void UnsafeSetAttribute (const std::string &k, const std::string &v)
 Set an Attribute for a specific key(unsafe mode).
const AttributeDescriptorGetAttributeDescriptor (const std::string &k) const
 Get Descriptor for an Attribute.
bool Matches (const AttributeMapType &) const
 Returns true if the KEY attributes of the node match those of the map provided.
template<class T >
GetData () const
 Returns the node data casted into the type T.
void SetData (boost::shared_ptr< NodeData > d)
 Sets the node data. Deletes existing data if any.
void SortChildren (const LexicographicalComparator &)
 Sorts the children of the node.
std::string GetLabel () const
 Get the Label of the node.

Private Attributes

Descriptor mDescriptor

Detailed Description

An attributed Tree structure.

Definition at line 27 of file creaImageIOTree.h.


Member Typedef Documentation

typedef std::map<std::string,std::string> creaImageIO::tree::Node::AttributeMapType [inherited]

Definition at line 39 of file creaImageIOTreeNode.h.

typedef std::vector<Node*> creaImageIO::tree::Node::ChildrenListType [inherited]

The type of children container.

Definition at line 80 of file creaImageIOTreeNode.h.


Constructor & Destructor Documentation

creaImageIO::tree::Tree::Tree (  ) 

Ctor.

Definition at line 10 of file creaImageIOTree.cpp.

References GimmickMessage.

      : Node(0)
    {
      GimmickMessage(5,"Default Tree constructor"
                     << std::endl);
    
    }

creaImageIO::tree::Tree::~Tree (  )  [virtual]

Virtual destructor.

Definition at line 18 of file creaImageIOTree.cpp.

    {
      
    }


Member Function Documentation

void creaImageIO::tree::Tree::CopyAttributeDescriptorList ( int  level  )  [inline]

Copy descriptor list without ID tag.

Definition at line 68 of file creaImageIOTree.h.

References creaImageIO::tree::Descriptor::CopyAttributeDescriptorList(), and GetDescriptor().

Referenced by creaImageIO::SQLiteTreeHandler::DBCreate(), and creaImageIO::SQLiteTreeHandler::DBImportTreeDescription().

          {
                  GetDescriptor().CopyAttributeDescriptorList(level);
          }

Here is the call graph for this function:

Here is the caller graph for this function:

const std::string & creaImageIO::tree::Node::GetAttribute ( const std::string &  k  )  const [inherited]

Get the Attribute for a specific key.

Definition at line 145 of file creaImageIOTreeNode.cpp.

References creaImageIO::tree::Node::mAttributeMap.

Referenced by creaImageIO::SQLiteTreeHandler::DBGraftToParent(), creaImageIO::SQLiteTreeHandler::DBLoadChildren(), creaImageIO::SQLiteTreeHandler::DBRecursiveRemoveNode(), creaImageIO::SQLiteTreeHandler::DBSetAttribute(), creaImageIO::TreeHandlerImageAdder::FindNode(), creaImageIO::TreeHandlerImageAdder::FindNodePartial(), creaImageIO::SQLiteTreeHandler::GetNumberOfChildren(), creaImageIO::WxEditFieldsPanel::OnComboChange(), creaImageIO::WxTreeView::OnDumpTags(), creaImageIO::TreeHandlerImageAdder::remove(), creaImageIO::TimestampDatabaseHandler::RemoveNode(), creaImageIO::GimmickView::RequestReading(), and creaImageIO::WxEditFieldsPanel::WxEditFieldsPanel().

    {
      //    std::cout << "this = "<<(void*)this<<std::endl;
      //    std::cout << "mFieldValueMap="<<(void*)(&mFieldValueMap)<<std::endl;
      AttributeMapType::const_iterator i = mAttributeMap.find(k);
      if (i == mAttributeMap.end())
        {
          static std::string def("");
          return def;
          //    CREAIMAGEIO_ERROR("DicomNode::GetFieldValue : no field with key '"<<k<<"'");
        }
      return i->second;
  }

Here is the caller graph for this function:

const AttributeDescriptor & creaImageIO::tree::Node::GetAttributeDescriptor ( const std::string &  k  )  const [inherited]

Get Descriptor for an Attribute.

Returns the attribute descriptor of the passed parameter.

Definition at line 112 of file creaImageIOTreeNode.cpp.

References GetAttributeDescriptorList(), creaImageIO::tree::Node::GetLevel(), and creaImageIO::tree::Node::GetTree().

Referenced by creaImageIO::WxTreeView::SortLevel().

        {
                LevelDescriptor::AttributeDescriptorListType::const_iterator a;
      for (a = GetTree()->GetAttributeDescriptorList(GetLevel()).begin();
           a!= GetTree()->GetAttributeDescriptorList(GetLevel()).end();
           ++a)
                {
                
                        if(a->GetKey()==k)
                        {
                                return *a;
                        }
                
                }
                return *a;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

const LevelDescriptor::AttributeDescriptorListType& creaImageIO::tree::Tree::GetAttributeDescriptorList ( int  level,
int  type = 0 
) const [inline]
AttributeMapType& creaImageIO::tree::Node::GetAttributeMap (  )  [inline, inherited]

Get the Attributes Map.

Definition at line 91 of file creaImageIOTreeNode.h.

References creaImageIO::tree::Node::mAttributeMap.

Referenced by creaImageIO::SQLiteTreeHandler::SQLAppendAttributesValues().

{ return mAttributeMap; }

Here is the caller graph for this function:

const AttributeMapType& creaImageIO::tree::Node::GetAttributeMap (  )  const [inline, inherited]

Get the Attributes Map.

Definition at line 94 of file creaImageIOTreeNode.h.

References creaImageIO::tree::Node::mAttributeMap.

{ return mAttributeMap; }

ChildrenListType& creaImageIO::tree::Node::GetChildrenList (  )  [inline, inherited]
const ChildrenListType& creaImageIO::tree::Node::GetChildrenList (  )  const [inline, inherited]

Returns the list of children (const).

Definition at line 84 of file creaImageIOTreeNode.h.

References creaImageIO::tree::Node::mChildren.

{ return mChildren; }

bool creaImageIO::tree::Node::GetChildrenLoaded (  )  const [inline, inherited]

Returns true iff the node's children are loaded.

Definition at line 74 of file creaImageIOTreeNode.h.

References creaImageIO::tree::Node::mChildrenLoaded.

Referenced by creaImageIO::SQLiteTreeHandler::DBLoadChildren().

{ return mChildrenLoaded; }

Here is the caller graph for this function:

const std::string& creaImageIO::tree::Node::GetCleanAttribute ( const std::string &  k  )  const [inherited]

Get the Attribute for a specific key without OS dependance (not implemented).

template<class T >
T creaImageIO::tree::Node::GetData (  )  const [inline, inherited]

Returns the node data casted into the type T.

Definition at line 117 of file creaImageIOTreeNode.h.

References creaImageIO::tree::Node::mData.

      { if (mData!=0) return dynamic_cast<T>(mData); return 0; }

Descriptor& creaImageIO::tree::Tree::GetDescriptor (  )  [inline]

Returns the descriptor of the tree.

Definition at line 47 of file creaImageIOTree.h.

References mDescriptor.

{ return mDescriptor; }

const Descriptor& creaImageIO::tree::Tree::GetDescriptor (  )  const [inline]
std::string creaImageIO::tree::Node::GetLabel (  )  const [inherited]

Get the Label of the node.

Definition at line 212 of file creaImageIOTreeNode.cpp.

References creaImageIO::tree::LevelDescriptor::GetLabelList(), creaImageIO::tree::Node::GetLevelDescriptor(), GimmickDebugMessage, GimmickError, and creaImageIO::tree::Node::mAttributeMap.

Referenced by creaImageIO::SQLiteTreeHandler::DBInsert(), creaImageIO::SQLiteTreeHandler::DBLoadChildren(), creaImageIO::SQLiteTreeHandler::DBSetAttribute(), creaImageIO::WxGimmickView::DumpTags(), creaImageIO::tree::Node::Matches(), creaImageIO::tree::Node::Print(), and Print().

    {
      std::string l;
      const std::vector<std::string>& label 
        = GetLevelDescriptor().GetLabelList();
      
      std::vector<std::string>::const_iterator i;
      for (i = label.begin(); i != label.end(); )
        {
          GimmickDebugMessage(9,"LABEL '"<<*i<<"'"<<std::endl);
          AttributeMapType::const_iterator j = mAttributeMap.find(*i);
          if (j != mAttributeMap.end())
            {
              l += j->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;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

virtual int creaImageIO::tree::Tree::GetLevel (  )  const [inline, virtual]

Returns the level of the node in the tree.

Reimplemented from creaImageIO::tree::Node.

Definition at line 42 of file creaImageIOTree.h.

{ return 0; }

const LevelDescriptor & creaImageIO::tree::Node::GetLevelDescriptor (  )  const [inherited]

Returns the level descriptor of the node.

Definition at line 103 of file creaImageIOTreeNode.cpp.

References creaImageIO::tree::Node::GetLevel(), GetLevelDescriptor(), and creaImageIO::tree::Node::GetTree().

Referenced by creaImageIO::tree::Node::GetLabel(), and creaImageIO::tree::Node::Matches().

    { 
      return GetTree()->GetLevelDescriptor(GetLevel()); 
    }

Here is the call graph for this function:

Here is the caller graph for this function:

const LevelDescriptor& creaImageIO::tree::Tree::GetLevelDescriptor ( int  level  )  const [inline]
unsigned int creaImageIO::tree::Node::GetNumberOfChildren (  )  const [inline, inherited]

Returns the number of children of the node. Warning : if the children are not loaded then might return 0 even if the node has children ! see TreeHandler::GetNumberOfChildren

Definition at line 71 of file creaImageIOTreeNode.h.

References creaImageIO::tree::Node::mChildren.

Referenced by creaImageIO::SQLiteTreeHandler::DBRecursiveRemoveNode(), creaImageIO::TreeHandlerImageAdder::RemoveFile(), and creaImageIO::TimestampDatabaseHandler::RemoveNode().

{ return mChildren.size(); }

Here is the caller graph for this function:

unsigned int creaImageIO::tree::Tree::GetNumberOfLevels (  )  [inline]
Node* creaImageIO::tree::Node::GetParent (  )  const [inline, inherited]

Returns the parent of the node.

Definition at line 65 of file creaImageIOTreeNode.h.

References creaImageIO::tree::Node::mParent.

Referenced by creaImageIO::SQLiteTreeHandler::Remove().

{ return mParent; }

Here is the caller graph for this function:

virtual Tree* creaImageIO::tree::Tree::GetTree (  )  [inline, virtual]

Returns the descriptor of the tree.

Returns the tree to which the node belongs

Reimplemented from creaImageIO::tree::Node.

Definition at line 38 of file creaImageIOTree.h.

Referenced by creaImageIO::SQLiteTreeHandler::DBGetParent(), creaImageIO::SQLiteTreeHandler::LoadChildren(), and creaImageIO::SQLiteTreeHandler::SetAttribute().

{ return this; }

Here is the caller graph for this function:

virtual const Tree* creaImageIO::tree::Tree::GetTree (  )  const [inline, virtual]

Returns the tree to which the node belongs.

Reimplemented from creaImageIO::tree::Node.

Definition at line 40 of file creaImageIOTree.h.

{ return this; }

void creaImageIO::tree::Node::InitializeAttributeMap (  )  [inherited]

Initializes the attribute map i.e. creates the entries.

Definition at line 88 of file creaImageIOTreeNode.cpp.

References GetAttributeDescriptorList(), creaImageIO::tree::Node::GetLevel(), creaImageIO::tree::Node::GetTree(), and creaImageIO::tree::Node::UnsafeSetAttribute().

Referenced by creaImageIO::SQLiteTreeHandler::DBCreate(), and creaImageIO::tree::Node::Node().

    {
      // Initialize attributes
      LevelDescriptor::AttributeDescriptorListType::const_iterator a;
      for (a = GetTree()->GetAttributeDescriptorList(GetLevel()).begin();
           a!= GetTree()->GetAttributeDescriptorList(GetLevel()).end();
           ++a)
        {
          UnsafeSetAttribute( a->GetKey(), "" );
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

const std::string creaImageIO::tree::Tree::isAttributeExist ( const std::string  i_attr  )  [inline]

Test if this attribute is available in this tree description.

Definition at line 74 of file creaImageIOTree.h.

References creaImageIO::tree::Descriptor::isExist(), and mDescriptor.

Referenced by creaImageIO::TreeHandlerImageAdder::isAttributeExist().

          {
                  return mDescriptor.isExist(i_attr);
          }

Here is the call graph for this function:

Here is the caller graph for this function:

bool creaImageIO::tree::Node::Matches ( const AttributeMapType m  )  const [inherited]

Returns true if the KEY attributes of the node match those of the map provided.

Definition at line 177 of file creaImageIOTreeNode.cpp.

References creaImageIO::tree::LevelDescriptor::GetIdentifierList(), creaImageIO::tree::Node::GetLabel(), creaImageIO::tree::Node::GetLevelDescriptor(), GimmickDebugMessage, and creaImageIO::tree::Node::mAttributeMap.

    {
      GimmickDebugMessage(2,"'"<<GetLabel()<<"' matching..."<<std::endl);
      const std::vector<std::string>& id 
        = GetLevelDescriptor().GetIdentifierList();
      std::vector<std::string>::const_iterator i;
      for (i = id.begin(); i != id.end(); ++i)
        {
          if (mAttributeMap.find(*i)->second != m.find(*i)->second ) 
            {
              GimmickDebugMessage(2,"IDENTIFIER '"<<*i<<"' values do not match"<<std::endl);
              return false;
            }
          GimmickDebugMessage(2,"IDENTIFIER '"<<*i<<"' values match"<<std::endl);
        }
      return true;
    }

Here is the call graph for this function:

void creaImageIO::tree::Tree::Print (  )  const [virtual]

Print the node.

Reimplemented from creaImageIO::tree::Node.

Definition at line 23 of file creaImageIOTree.cpp.

References creaImageIO::tree::Node::GetChildrenList(), creaImageIO::tree::Node::GetLabel(), and GimmickMessage.

Referenced by creaImageIO::Gimmick::Print().

    {
      GimmickMessage(1,GetLabel()<<std::endl);
      ChildrenListType::const_iterator i;
      for (i=GetChildrenList().begin(); i!=GetChildrenList().end(); i++)
        {
          (*i)->Print();
        }
      
    }

Here is the call graph for this function:

Here is the caller graph for this function:

int creaImageIO::tree::Node::RemoveChildrenFromList ( Node node  )  [inherited]

Remove the given children from the children list.

Definition at line 131 of file creaImageIOTreeNode.cpp.

References creaImageIO::tree::Node::GetChildrenList().

Referenced by creaImageIO::SQLiteTreeHandler::Remove().

    {
      ChildrenListType::iterator i = find(GetChildrenList().begin(),
                                          GetChildrenList().end(),
                                          node);
      if (i != GetChildrenList().end())
        {
          GetChildrenList().erase(i);
        }
        return GetChildrenList().size();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::tree::Node::SetAttribute ( const std::string &  k,
const std::string &  v 
) [inherited]

Set an Attribute for a specific key.

Definition at line 161 of file creaImageIOTreeNode.cpp.

References creaImageIO::tree::Node::mAttributeMap.

Referenced by creaImageIO::SQLiteTreeHandler::DBGraftToParent(), creaImageIO::SQLiteTreeHandler::DBInsert(), creaImageIO::SQLiteTreeHandler::DBSetAttribute(), and creaImageIO::TreeHandlerImageAdder::EditField().

  {
    AttributeMapType::iterator i = mAttributeMap.find(k);
    if (i==mAttributeMap.end())
      {
        std::cout<<"[Gimmick!] Node::SetAttribute : no attribute with key '"
                 <<k<<"'"<<std::endl;
        creaError( "[Gimmick!] Node::SetAttribute : no attribute with key '"
                   <<k<<"'");
      }
    i->second = v;
  }

Here is the caller graph for this function:

void creaImageIO::tree::Node::SetChildrenLoaded ( bool  l  )  [inline, inherited]

Sets the node's children.

Definition at line 77 of file creaImageIOTreeNode.h.

References creaImageIO::tree::Node::mChildrenLoaded.

Referenced by creaImageIO::SQLiteTreeHandler::DBCreate(), creaImageIO::SQLiteTreeHandler::DBGraftToParent(), and creaImageIO::SQLiteTreeHandler::DBLoadChildren().

{ mChildrenLoaded = l; }

Here is the caller graph for this function:

void creaImageIO::tree::Node::SetData ( boost::shared_ptr< NodeData d  )  [inline, inherited]

Sets the node data. Deletes existing data if any.

Definition at line 121 of file creaImageIOTreeNode.h.

References creaImageIO::tree::Node::mData.

{mData.reset(); mData = d; }//{ if (mData) delete mData; mData = d; }

void creaImageIO::tree::Node::SortChildren ( const LexicographicalComparator  )  [inherited]

Sorts the children of the node.

void creaImageIO::tree::Node::UnsafeSetAttribute ( const std::string &  k,
const std::string &  v 
) [inline, inherited]

Set an Attribute for a specific key(unsafe mode).

Definition at line 107 of file creaImageIOTreeNode.h.

References creaImageIO::tree::Node::mAttributeMap.

Referenced by creaImageIO::SQLiteTreeHandler::DBImportTreeDescription(), creaImageIO::SQLiteTreeHandler::DBLoadChildren(), creaImageIO::tree::Node::InitializeAttributeMap(), and creaImageIO::tree::Node::Node().

      { mAttributeMap[k] = v; }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 80 of file creaImageIOTree.h.

Referenced by GetDescriptor(), and isAttributeExist().


The documentation for this class was generated from the following files: