Salome HOME
updated copyright message
[modules/kernel.git] / src / DF / DF_Attribute.cxx
1 // Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "DF_definitions.hxx"
21 #include "DF_Label.hxx"
22 #include "DF_Attribute.hxx"
23
24 //Class DF_Attribute is used to store some data defined by the DF_Attribute type
25
26 //Constructor
27 DF_Attribute::DF_Attribute()
28 {
29   _node = NULL;
30 }
31
32 DF_Attribute::~DF_Attribute()
33 {
34   //Remove an attribute from a map of the node's attributes to 
35   //avoid double deletion on the node destruction
36   if(_node) {
37           std::map<std::string, DF_Attribute*>::iterator mi;
38     for(mi =_node->_attributes.begin(); mi != _node->_attributes.end(); mi++) {
39        if(mi->second == this) {
40          _node->_attributes.erase(mi);
41          return;
42        } 
43     }
44   }
45 }
46
47  //Returns a Label on which this Attribute is located.
48 DF_Label DF_Attribute::Label() const
49 {
50    return DF_Label(_node);
51 }
52
53  //Searches an Attribute with given ID located on the same Label as this Attribute.
54 DF_Attribute* DF_Attribute::FindAttribute(const std::string& theID) const
55 {
56   if(!_node) return NULL;
57   return Label().FindAttribute(theID);
58 }
59
60