Salome HOME
DCQ: update msg file
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_TargetAttribute.cxx
1 //  SALOME SALOMEDS : data structure of SALOME and sources of Salome data server 
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SALOMEDS_TargetAttribute.cxx
25 //  Author : Yves FRICAUD
26 //  Module : SALOME
27 //  $Header$
28
29 using namespace std;
30 #include "SALOMEDS_TargetAttribute.ixx"
31 #include <TDF_Reference.hxx>
32 #include <TDF_ListIteratorOfAttributeList.hxx>
33 #include "utilities.h"
34
35 //=======================================================================
36 //function : GetID
37 //purpose  : 
38 //=======================================================================
39
40 const Standard_GUID& SALOMEDS_TargetAttribute::GetID () 
41 {
42   static Standard_GUID SALOMEDS_TargetAttributeID ("12837197-8F52-11d6-A8A3-0001021E8C7F");
43   return SALOMEDS_TargetAttributeID;
44 }
45
46
47
48 //=======================================================================
49 //function : Set
50 //purpose  : 
51 //=======================================================================
52
53 Handle(SALOMEDS_TargetAttribute) SALOMEDS_TargetAttribute::Set (const TDF_Label& L) 
54 {
55   Handle(SALOMEDS_TargetAttribute) A;
56   if (!L.FindAttribute(SALOMEDS_TargetAttribute::GetID(),A)) {
57     A = new  SALOMEDS_TargetAttribute(); 
58     L.AddAttribute(A);
59   }
60   return A;
61 }
62
63
64 //=======================================================================
65 //function : constructor
66 //purpose  : 
67 //=======================================================================
68 SALOMEDS_TargetAttribute::SALOMEDS_TargetAttribute()
69 {}
70
71 //=======================================================================
72 //function : Append
73 //purpose  : 
74 //=======================================================================
75
76 void SALOMEDS_TargetAttribute::Append(TDF_Label& theReferencedObject) {
77   Backup();
78   Handle(TDF_Reference) aReference;
79   if (theReferencedObject.FindAttribute(TDF_Reference::GetID(),aReference)) {
80     GetVariables().Append(aReference);
81   } else {
82     MESSAGE("SALOMEDS_TargetAttribute::Append: can't append referenced object");
83   }
84 }
85
86 //=======================================================================
87 //function : Get
88 //purpose  : 
89 //=======================================================================
90 void SALOMEDS_TargetAttribute::Get(TDF_LabelList& theReferencedObjects) {
91   theReferencedObjects.Clear();
92   TDF_ListIteratorOfAttributeList anIter(GetVariables());
93   for(;anIter.More();anIter.Next()) {
94     theReferencedObjects.Append(anIter.Value()->Label());
95   }
96 }
97
98 //=======================================================================
99 //function : Remove
100 //purpose  : 
101 //=======================================================================
102 void SALOMEDS_TargetAttribute::Remove(TDF_Label& theReferencedObject) {
103   Backup();
104   TDF_ListIteratorOfAttributeList anIter(GetVariables());
105   for(;anIter.More();anIter.Next()) {
106     if (anIter.Value()->Label() == theReferencedObject) {
107       GetVariables().Remove(anIter);
108       return;
109     }
110   }  
111   MESSAGE("SALOMEDS_TargetAttribute::Remove: nothing to remove");
112 }
113
114 //=======================================================================
115 //function : ID
116 //purpose  : 
117 //=======================================================================
118
119 const Standard_GUID& SALOMEDS_TargetAttribute::ID () const { return GetID(); }
120