Salome HOME
NRI : Remove dependence with VISU.
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_SequenceOfIntegerAttribute.cxx
1 using namespace std;
2 //  File      : SALOMEDS_SequenceOfIntegerAttribute.cxx
3 //  Created   : Wed Nov 28 16:09:35 2001
4 //  Author    : Yves FRICAUD
5 //  Project   : SALOME
6 //  Module    : SALOMEDS
7 //  Copyright : Open CASCADE 2001
8 //  $Header: 
9
10 #include "SALOMEDS_SequenceOfIntegerAttribute.ixx"
11
12 //=======================================================================
13 //function : GetID
14 //purpose  : 
15 //=======================================================================
16
17 const Standard_GUID& SALOMEDS_SequenceOfIntegerAttribute::GetID () 
18 {
19   static Standard_GUID SALOMEDS_SequenceOfIntegerAttributeID ("12837182-8F52-11d6-A8A3-0001021E8C7F");
20   return SALOMEDS_SequenceOfIntegerAttributeID;
21 }
22
23
24
25 //=======================================================================
26 //function : Set
27 //purpose  : 
28 //=======================================================================
29
30 Handle(SALOMEDS_SequenceOfIntegerAttribute) SALOMEDS_SequenceOfIntegerAttribute::Set (const TDF_Label& L) 
31 {
32   Handle(SALOMEDS_SequenceOfIntegerAttribute) A;
33   if (!L.FindAttribute(SALOMEDS_SequenceOfIntegerAttribute::GetID(),A)) {
34     A = new  SALOMEDS_SequenceOfIntegerAttribute(); 
35     L.AddAttribute(A);
36   }
37   return A;
38 }
39
40
41 //=======================================================================
42 //function : constructor
43 //purpose  : 
44 //=======================================================================
45 SALOMEDS_SequenceOfIntegerAttribute::SALOMEDS_SequenceOfIntegerAttribute()
46 {myValue = new TColStd_HSequenceOfInteger();}
47
48 //=======================================================================
49 //function : ID
50 //purpose  : 
51 //=======================================================================
52
53 const Standard_GUID& SALOMEDS_SequenceOfIntegerAttribute::ID () const { return GetID(); }
54
55
56 //=======================================================================
57 //function : NewEmpty
58 //purpose  : 
59 //=======================================================================
60
61 Handle(TDF_Attribute) SALOMEDS_SequenceOfIntegerAttribute::NewEmpty () const
62 {  
63   return new SALOMEDS_SequenceOfIntegerAttribute(); 
64 }
65
66 //=======================================================================
67 //function : Restore
68 //purpose  : 
69 //=======================================================================
70
71 void SALOMEDS_SequenceOfIntegerAttribute::Restore(const Handle(TDF_Attribute)& with) 
72 {
73   Standard_Integer i;
74   Handle(SALOMEDS_SequenceOfIntegerAttribute) anSeq = Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(with);
75   if(!anSeq->myValue.IsNull()) {
76     myValue = new TColStd_HSequenceOfInteger();
77     Standard_Integer Len = anSeq->Length();
78     for(i = 1; i<=Len; i++) Add(anSeq->Value(i)); 
79   }
80   else
81     myValue.Nullify();
82   return;
83 }
84
85 //=======================================================================
86 //function : Paste
87 //purpose  : 
88 //=======================================================================
89
90 void SALOMEDS_SequenceOfIntegerAttribute::Paste (const Handle(TDF_Attribute)& into,
91                                     const Handle(TDF_RelocationTable)& ) const
92 {
93   if(!myValue.IsNull()) {
94     Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast (into)->Assign(myValue);
95   }
96 }
97
98 void SALOMEDS_SequenceOfIntegerAttribute::Assign(const Handle(TColStd_HSequenceOfInteger)& other) 
99 {
100   Backup();
101   if (myValue.IsNull()) myValue = new TColStd_HSequenceOfInteger;
102   myValue->ChangeSequence() = other->Sequence();
103 }
104
105 void SALOMEDS_SequenceOfIntegerAttribute::ChangeValue(const Standard_Integer Index,const Standard_Integer Value) 
106 {
107   Backup();
108   myValue->SetValue(Index, Value);
109 }
110
111 void SALOMEDS_SequenceOfIntegerAttribute::Add(const Standard_Integer Value) 
112 {
113   Backup();
114   myValue->Append(Value);
115 }
116
117 void SALOMEDS_SequenceOfIntegerAttribute::Remove(const Standard_Integer Index) 
118 {
119   Backup();
120   myValue->Remove(Index);
121 }
122
123 Standard_Integer SALOMEDS_SequenceOfIntegerAttribute::Length() 
124 {
125   return myValue->Length();
126 }
127 Standard_Integer SALOMEDS_SequenceOfIntegerAttribute::Value(const Standard_Integer Index) 
128 {
129   return myValue->Value(Index);
130 }
131