Back to index

salome-kernel  6.5.0
DF_Attribute.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "DF_definitions.hxx"
00021 #include "DF_Label.hxx"
00022 #include "DF_Attribute.hxx"
00023 
00024 //Class DF_Attribute is used to store some data defined by the DF_Attribute type
00025 
00026 //Constructor
00027 DF_Attribute::DF_Attribute()
00028 {
00029   _node = NULL;
00030 }
00031 
00032 DF_Attribute::~DF_Attribute()
00033 {
00034   //Remove an attribute from a map of the node's attributes to 
00035   //avoid double deletion on the node destruction
00036   if(_node) {
00037          std::map<std::string, DF_Attribute*>::iterator mi;
00038     for(mi =_node->_attributes.begin(); mi != _node->_attributes.end(); mi++) {
00039        if(mi->second == this) {
00040          _node->_attributes.erase(mi);
00041          return;
00042        } 
00043     }
00044   }
00045 }
00046 
00047  //Returns a Label on which this Attribute is located.
00048 DF_Label DF_Attribute::Label() const
00049 {
00050    return DF_Label(_node);
00051 }
00052 
00053  //Searches an Attribute with given ID located on the same Label as this Attribute.
00054 DF_Attribute* DF_Attribute::FindAttribute(const std::string& theID) const
00055 {
00056   if(!_node) return NULL;
00057   return Label().FindAttribute(theID);
00058 }
00059 
00060