Salome HOME
NRI : Remove dependence with VISU.
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_TargetAttribute.cxx
1 using namespace std;
2 //  File      : SALOMEDS_TargetAttribute.cxx
3 //  Created   : Fri Aug 16 10:20:05 2002
4 //  Author    : Yves FRICAUD
5 //  Project   : SALOME
6 //  Module    : SALOMEDS
7 //  Copyright : Open CASCADE 2001
8 //  $Header:  
9
10 #include "SALOMEDS_TargetAttribute.ixx"
11 #include <TDF_Reference.hxx>
12 #include <TDF_ListIteratorOfAttributeList.hxx>
13 #include "utilities.h"
14
15 //=======================================================================
16 //function : GetID
17 //purpose  : 
18 //=======================================================================
19
20 const Standard_GUID& SALOMEDS_TargetAttribute::GetID () 
21 {
22   static Standard_GUID SALOMEDS_TargetAttributeID ("12837197-8F52-11d6-A8A3-0001021E8C7F");
23   return SALOMEDS_TargetAttributeID;
24 }
25
26
27
28 //=======================================================================
29 //function : Set
30 //purpose  : 
31 //=======================================================================
32
33 Handle(SALOMEDS_TargetAttribute) SALOMEDS_TargetAttribute::Set (const TDF_Label& L) 
34 {
35   Handle(SALOMEDS_TargetAttribute) A;
36   if (!L.FindAttribute(SALOMEDS_TargetAttribute::GetID(),A)) {
37     A = new  SALOMEDS_TargetAttribute(); 
38     L.AddAttribute(A);
39   }
40   return A;
41 }
42
43
44 //=======================================================================
45 //function : constructor
46 //purpose  : 
47 //=======================================================================
48 SALOMEDS_TargetAttribute::SALOMEDS_TargetAttribute()
49 {}
50
51 //=======================================================================
52 //function : Append
53 //purpose  : 
54 //=======================================================================
55
56 void SALOMEDS_TargetAttribute::Append(TDF_Label& theReferencedObject) {
57   Backup();
58   Handle(TDF_Reference) aReference;
59   if (theReferencedObject.FindAttribute(TDF_Reference::GetID(),aReference)) {
60     GetVariables().Append(aReference);
61   } else {
62     MESSAGE("SALOMEDS_TargetAttribute::Append: can't append referenced object");
63   }
64 }
65
66 //=======================================================================
67 //function : Get
68 //purpose  : 
69 //=======================================================================
70 void SALOMEDS_TargetAttribute::Get(TDF_LabelList& theReferencedObjects) {
71   theReferencedObjects.Clear();
72   TDF_ListIteratorOfAttributeList anIter(GetVariables());
73   for(;anIter.More();anIter.Next()) {
74     theReferencedObjects.Append(anIter.Value()->Label());
75   }
76 }
77
78 //=======================================================================
79 //function : Remove
80 //purpose  : 
81 //=======================================================================
82 void SALOMEDS_TargetAttribute::Remove(TDF_Label& theReferencedObject) {
83   Backup();
84   TDF_ListIteratorOfAttributeList anIter(GetVariables());
85   for(;anIter.More();anIter.Next()) {
86     if (anIter.Value()->Label() == theReferencedObject) {
87       GetVariables().Remove(anIter);
88       return;
89     }
90   }  
91   MESSAGE("SALOMEDS_TargetAttribute::Remove: nothing to remove");
92 }
93
94 //=======================================================================
95 //function : ID
96 //purpose  : 
97 //=======================================================================
98
99 const Standard_GUID& SALOMEDS_TargetAttribute::ID () const { return GetID(); }
100