Back to index

salome-kernel  6.5.0
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends
DF_Label Class Reference

#include <DF_Label.hxx>

Collaboration diagram for DF_Label:
Collaboration graph
[legend]

List of all members.

Public Member Functions

Standard_EXPORT DF_Label ()
Standard_EXPORT DF_Label (const DF_Label &theLabel)
Standard_EXPORT DF_Label (DF_LabelNode *theNode)
Standard_EXPORT DF_Labeloperator= (const DF_Label &theLabel)
Standard_EXPORT ~DF_Label ()
Standard_EXPORT DF_DocumentGetDocument () const
Standard_EXPORT bool operator== (const DF_Label &theLabel)
Standard_EXPORT bool operator!= (const DF_Label &theLabel)
Standard_EXPORT int Tag () const
Standard_EXPORT bool IsAttached ()
Standard_EXPORT DF_AttributeFindAttribute (const std::string &theID) const
Standard_EXPORT bool IsAttribute (const std::string &theID) const
Standard_EXPORT bool AddAttribute (DF_Attribute *theAttribute) const
Standard_EXPORT bool ForgetAttribute (const std::string &theID) const
Standard_EXPORT bool ForgetAllAttributes (bool clearChildren=true) const
Standard_EXPORT DF_Label Father () const
Standard_EXPORT bool IsNull () const
Standard_EXPORT bool IsRoot () const
Standard_EXPORT bool HasAttributes () const
Standard_EXPORT std::vector
< DF_Attribute * > 
GetAttributes () const
Standard_EXPORT bool HasChild () const
Standard_EXPORT int NbChildren () const
Standard_EXPORT int Depth () const
Standard_EXPORT bool IsDescendant (const DF_Label &theLabel)
Standard_EXPORT DF_Label Root () const
Standard_EXPORT DF_Label FindChild (int theTag, bool isCreate=true)
Standard_EXPORT DF_Label NewChild ()
Standard_EXPORT std::string Entry () const
Standard_EXPORT bool IsEqual (const DF_Label &theLabel)
Standard_EXPORT void dump ()

Static Public Member Functions

static Standard_EXPORT DF_Label Label (const DF_Label &theLabel, const std::string &theEntry, bool isCreated=true)

Private Member Functions

void Nullify ()

Private Attributes

DF_LabelNode_node

Friends

class DF_Document
class DF_ChildIterator

Detailed Description

Definition at line 65 of file DF_Label.hxx.


Constructor & Destructor Documentation

Definition at line 78 of file DF_Label.cxx.

{
  _node = NULL;
}

Here is the caller graph for this function:

DF_Label::DF_Label ( const DF_Label theLabel)

Definition at line 84 of file DF_Label.cxx.

{
  _node = theLabel._node;
}

Definition at line 72 of file DF_Label.cxx.

  :_node(theNode)
{
}

Definition at line 96 of file DF_Label.cxx.

{
  _node = NULL;
}

Member Function Documentation

bool DF_Label::AddAttribute ( DF_Attribute theAttribute) const

Definition at line 159 of file DF_Label.cxx.

{
  if(!_node) return false;

  if(_node->_attributes.find(theAttribute->ID()) != _node->_attributes.end()) return false;
  theAttribute->_node = _node;
  _node->_attributes[theAttribute->ID()] = theAttribute;
  theAttribute->AfterAddition();    

  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int DF_Label::Depth ( ) const

Definition at line 281 of file DF_Label.cxx.

{
  if(!_node) return -1;

  return _node->_depth;
}

Here is the caller graph for this function:

void DF_Label::dump ( )

Definition at line 421 of file DF_Label.cxx.

{
  if(!_node) std::cout << "DF_Label addr : " << this << " NULL " << std::endl;
  else {
    std::cout << "DF_Label addr : " << this->_node << " entry : " << Entry() << std::endl;
    if(_node->_father) std::cout << " Father : " << _node->_father << " entry : " << Father().Entry() << std::endl;
    else std::cout << " Father : NULL " << std::endl;

    if(_node->_firstChild) std::cout << " FirstChild : " << _node->_firstChild << " entry : " << DF_Label(_node->_firstChild).Entry() << std::endl;
    else std::cout << " FirstChild : NULL " << std::endl;

    if(_node->_lastChild) std::cout << " LastChild : " << _node->_lastChild << " entry : " << DF_Label(_node->_lastChild).Entry() << std::endl;
    else std::cout << " LastChild : NULL " << std::endl;

    if(_node->_previous) std::cout << " Previous : " << _node->_previous << " entry : " << DF_Label(_node->_previous).Entry() << std::endl;
    else std::cout << " Previous : NULL " << std::endl;

    if(_node->_next) std::cout << " Next : " << _node->_next << " entry : " << DF_Label(_node->_next).Entry() << std::endl;
    else std::cout << " Next : NULL " << std::endl;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

std::string DF_Label::Entry ( ) const

Definition at line 378 of file DF_Label.cxx.

{
  DF_LabelNode* father = this->_node;
  if(!father->_father)return "0:";
  int tag;
  char buff[128];
  char* wstr= buff;
  char* str = buff;

  while(father)
    {
      tag=father->_tag;
      do{
         // Conversion. Number is reversed.
         *wstr++ = '0' + (tag % 10);
      }while(tag /= 10);
      father = father->_father;
      if(father)*wstr++ = ':';
    }
  *wstr-- = '\0';

  //reverse the buffer
  char aux;
  while (wstr > str)
    aux = *wstr, *wstr-- = *str, *str++ = aux;

  return buff;
}

Here is the caller graph for this function:

Definition at line 208 of file DF_Label.cxx.

{
  if(!_node) return DF_Label();

  return _node->_father;
}

Here is the call graph for this function:

Here is the caller graph for this function:

DF_Attribute * DF_Label::FindAttribute ( const std::string &  theID) const

Definition at line 139 of file DF_Label.cxx.

{
  if(!_node) return NULL;

  std::map< std::string, DF_Attribute* >::iterator it=_node->_attributes.find(theID);
  if(it == _node->_attributes.end()) return NULL;
  return it->second;

}

Here is the caller graph for this function:

DF_Label DF_Label::FindChild ( int  theTag,
bool  isCreate = true 
)

Definition at line 314 of file DF_Label.cxx.

{
  if(!_node || IsNull()) return DF_Label();

  DF_LabelNode *aLabel = NULL, *aPrevious = NULL, *aNext = NULL;
  if(!_node->_firstChild && !isCreate) return DF_Label();

  if(_node->_firstChild && _node->_firstChild->_tag == theTag)
    return DF_Label(_node->_firstChild);
 
  if(_node->_lastChild) {
    if(_node->_lastChild->_tag == theTag) return DF_Label(_node->_lastChild);
    if(_node->_lastChild->_tag < theTag) aPrevious = _node->_lastChild;
  }
  
  if(!aPrevious) { 
    aLabel = _node->_firstChild;
    while(aLabel) {
      if(aLabel->_tag == theTag) return DF_Label(aLabel);
      if(aLabel->_tag > theTag) {
        aNext = aLabel;
        break;
      }
      if(aLabel->_tag < theTag) aPrevious = aLabel;
      aLabel = aLabel->_next;
    }
  }
  
  if(!isCreate) return DF_Label();

  DF_LabelNode* aChild = new DF_LabelNode();
  aChild->_father = this->_node;
  aChild->_document = _node->_document;
  aChild->_tag = theTag;
  aChild->_depth = _node->_depth+1;
  if(aNext) {
    aChild->_previous = aNext->_previous;
    aChild->_next = aNext;
    aNext->_previous = aChild;
  }
  if(aPrevious) {
    aChild->_previous = aPrevious;
    aChild->_next = aPrevious->_next;
    aPrevious->_next = aChild;
  }
    
  if(!_node->_firstChild || (aNext && aNext == _node->_firstChild) ) _node->_firstChild = aChild;
  if(!_node->_lastChild || !aNext) _node->_lastChild = aChild;
  
  return aChild;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool DF_Label::ForgetAllAttributes ( bool  clearChildren = true) const

Definition at line 186 of file DF_Label.cxx.

{
  if(!_node) return false;

  std::vector<DF_Attribute*> va = GetAttributes();
  _node->_attributes.clear();

  for(int i = 0, len = va.size(); i<len; i++) {
    va[i]->BeforeForget();
    delete va[i];
  }

  if(clearChildren) {
    DF_ChildIterator CI(*this, true);
    for(; CI.More(); CI.Next()) 
      CI.Value().ForgetAllAttributes(true);
  }

  return true;
}

Here is the call graph for this function:

bool DF_Label::ForgetAttribute ( const std::string &  theID) const

Definition at line 172 of file DF_Label.cxx.

{
  if(!_node) return false;

  if(_node->_attributes.find(theID) == _node->_attributes.end()) return false;
  DF_Attribute* attr = _node->_attributes[theID];
  attr->BeforeForget();
  _node->_attributes.erase(theID);
  delete attr;

  return true;
}

Here is the call graph for this function:

std::vector< DF_Attribute * > DF_Label::GetAttributes ( ) const

Definition at line 238 of file DF_Label.cxx.

{
  std::vector<DF_Attribute*> attributes;
  if(!_node) return attributes;
  
  typedef std::map<std::string, DF_Attribute*>::const_iterator AI;
  std::vector<std::string> sorted;
  for(AI p = _node->_attributes.begin(); p!=_node->_attributes.end(); p++)
    sorted.push_back(p->first);
    
  sort(sorted.begin(), sorted.end());
  int len = sorted.size();    
  for(int i = 0; i<len; i++)
    attributes.push_back(_node->_attributes[sorted[i]]);

  return attributes;
}

Here is the caller graph for this function:

Definition at line 102 of file DF_Label.cxx.

{
  if(!_node) return NULL;
  return _node->_document;
}

Here is the caller graph for this function:

Definition at line 230 of file DF_Label.cxx.

{
  if(!_node) return false;

  return !(_node->_attributes.empty());
}

Definition at line 257 of file DF_Label.cxx.

{
  if(!_node) return false;

  return _node->_firstChild != 0;
}

Definition at line 131 of file DF_Label.cxx.

{
  if(!_node) return false;
  return _node->_document != 0;
}
bool DF_Label::IsAttribute ( const std::string &  theID) const

Definition at line 150 of file DF_Label.cxx.

{
  if(!_node) return false;

  return (_node->_attributes.find(theID) != _node->_attributes.end());
}
bool DF_Label::IsDescendant ( const DF_Label theLabel)

Definition at line 289 of file DF_Label.cxx.

{
  if(!_node) return false;

  DF_LabelNode* father = _node->_father;
  if(!father) return false;

  while(father) {
    if(father == theLabel._node) return true;
    father = father->_father;
  }

  return false;
}
bool DF_Label::IsEqual ( const DF_Label theLabel)

Definition at line 407 of file DF_Label.cxx.

{
  if(theLabel.IsNull() || IsNull()) return false;
  DF_Label L(theLabel);
  return (L.Entry() == Entry());
}

Here is the call graph for this function:

Definition at line 216 of file DF_Label.cxx.

{
  return (!_node || (_node->_document == NULL));
}

Here is the caller graph for this function:

Definition at line 222 of file DF_Label.cxx.

{
  if(IsNull() || Father().IsNull()) return true;
  return false;
}

Here is the call graph for this function:

DF_Label DF_Label::Label ( const DF_Label theLabel,
const std::string &  theEntry,
bool  isCreated = true 
) [static]

Definition at line 37 of file DF_Label.cxx.

{
  if(theLabel.IsNull()) return DF_Label();
  
  DF_Label aLabel = theLabel.Root();
  if(theEntry == "0:") return aLabel;
  if(theEntry == "0:1") return theLabel.GetDocument()->Main();

  char* cc = (char*)theEntry.c_str();
  int n = 0;
  int i=0;

  while (*cc != '\0') {
    while ( *cc >= '0' && *cc <= '9') {
      n = 10*n + (*cc - '0');
      ++cc;
    }
    if (*cc == ':' || *cc == '\0') {
      if(i>0)
        {
          if(aLabel.IsNull())break;
          aLabel = aLabel.FindChild(n, isCreated);
        }
      i++;
      n = 0;
      if (*cc != '\0') ++cc;
    }
    else {
      return DF_Label();
    }
  }

  return aLabel;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int DF_Label::NbChildren ( ) const

Definition at line 265 of file DF_Label.cxx.

{
  if(!_node) return -1;

  if(!_node->_firstChild) return 0;
  int nb = 1;
  DF_LabelNode* next = _node->_firstChild->_next;
  while(next) {
    nb++;
    next = next->_next;
  }

  return nb;
}

Definition at line 367 of file DF_Label.cxx.

{
  if(!_node || IsNull()) return DF_Label();

  int tag = 1;
  if(_node->_lastChild) tag = _node->_lastChild->_tag+1;
  
  return FindChild(tag, true);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void DF_Label::Nullify ( ) [private]

Definition at line 415 of file DF_Label.cxx.

{
  delete _node;
  _node = NULL;
}

Here is the caller graph for this function:

bool DF_Label::operator!= ( const DF_Label theLabel)

Definition at line 116 of file DF_Label.cxx.

{
  if(IsNull() || theLabel.IsNull()) return true;
  return (theLabel.Entry() != Entry());
}

Here is the call graph for this function:

DF_Label & DF_Label::operator= ( const DF_Label theLabel)

Definition at line 89 of file DF_Label.cxx.

{
  _node = theLabel._node;
  return *this;
}
bool DF_Label::operator== ( const DF_Label theLabel)

Definition at line 109 of file DF_Label.cxx.

{
  if(IsNull() || theLabel.IsNull()) return false;
  return (theLabel.Entry() == Entry());
}

Here is the call graph for this function:

Definition at line 305 of file DF_Label.cxx.

{
  if(!_node) return DF_Label();

  return _node->_document->Main().Father();
}

Here is the call graph for this function:

Here is the caller graph for this function:

int DF_Label::Tag ( ) const

Definition at line 124 of file DF_Label.cxx.

{
  if(!_node) return -1;
  return _node->_tag;
}

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class DF_ChildIterator [friend]

Definition at line 168 of file DF_Label.hxx.

friend class DF_Document [friend]

Definition at line 167 of file DF_Label.hxx.


Member Data Documentation

Definition at line 171 of file DF_Label.hxx.


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