Salome HOME
portage sur processeur alpha/osf
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_SequenceOfIntegerAttribute.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_SequenceOfIntegerAttribute.cxx
25 //  Author : Yves FRICAUD
26 //  Module : SALOME
27 //  $Header: 
28
29 #include "SALOMEDS_SequenceOfIntegerAttribute.ixx"
30 using namespace std;
31
32 //=======================================================================
33 //function : GetID
34 //purpose  : 
35 //=======================================================================
36
37 const Standard_GUID& SALOMEDS_SequenceOfIntegerAttribute::GetID () 
38 {
39   static Standard_GUID SALOMEDS_SequenceOfIntegerAttributeID ("12837182-8F52-11d6-A8A3-0001021E8C7F");
40   return SALOMEDS_SequenceOfIntegerAttributeID;
41 }
42
43
44
45 //=======================================================================
46 //function : Set
47 //purpose  : 
48 //=======================================================================
49
50 Handle(SALOMEDS_SequenceOfIntegerAttribute) SALOMEDS_SequenceOfIntegerAttribute::Set (const TDF_Label& L) 
51 {
52   Handle(SALOMEDS_SequenceOfIntegerAttribute) A;
53   if (!L.FindAttribute(SALOMEDS_SequenceOfIntegerAttribute::GetID(),A)) {
54     A = new  SALOMEDS_SequenceOfIntegerAttribute(); 
55     L.AddAttribute(A);
56   }
57   return A;
58 }
59
60
61 //=======================================================================
62 //function : constructor
63 //purpose  : 
64 //=======================================================================
65 SALOMEDS_SequenceOfIntegerAttribute::SALOMEDS_SequenceOfIntegerAttribute()
66 {myValue = new TColStd_HSequenceOfInteger();}
67
68 //=======================================================================
69 //function : ID
70 //purpose  : 
71 //=======================================================================
72
73 const Standard_GUID& SALOMEDS_SequenceOfIntegerAttribute::ID () const { return GetID(); }
74
75
76 //=======================================================================
77 //function : NewEmpty
78 //purpose  : 
79 //=======================================================================
80
81 Handle(TDF_Attribute) SALOMEDS_SequenceOfIntegerAttribute::NewEmpty () const
82 {  
83   return new SALOMEDS_SequenceOfIntegerAttribute(); 
84 }
85
86 //=======================================================================
87 //function : Restore
88 //purpose  : 
89 //=======================================================================
90
91 void SALOMEDS_SequenceOfIntegerAttribute::Restore(const Handle(TDF_Attribute)& with) 
92 {
93   Standard_Integer i;
94   Handle(SALOMEDS_SequenceOfIntegerAttribute) anSeq = Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(with);
95   if(!anSeq->myValue.IsNull()) {
96     myValue = new TColStd_HSequenceOfInteger();
97     Standard_Integer Len = anSeq->Length();
98     for(i = 1; i<=Len; i++) Add(anSeq->Value(i)); 
99   }
100   else
101     myValue.Nullify();
102   return;
103 }
104
105 //=======================================================================
106 //function : Paste
107 //purpose  : 
108 //=======================================================================
109
110 void SALOMEDS_SequenceOfIntegerAttribute::Paste (const Handle(TDF_Attribute)& into,
111                                     const Handle(TDF_RelocationTable)& ) const
112 {
113   if(!myValue.IsNull()) {
114     Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast (into)->Assign(myValue);
115   }
116 }
117
118 void SALOMEDS_SequenceOfIntegerAttribute::Assign(const Handle(TColStd_HSequenceOfInteger)& other) 
119 {
120   Backup();
121   if (myValue.IsNull()) myValue = new TColStd_HSequenceOfInteger;
122   myValue->ChangeSequence() = other->Sequence();
123 }
124
125 void SALOMEDS_SequenceOfIntegerAttribute::ChangeValue(const Standard_Integer Index,const Standard_Integer Value) 
126 {
127   Backup();
128   myValue->SetValue(Index, Value);
129 }
130
131 void SALOMEDS_SequenceOfIntegerAttribute::Add(const Standard_Integer Value) 
132 {
133   Backup();
134   myValue->Append(Value);
135 }
136
137 void SALOMEDS_SequenceOfIntegerAttribute::Remove(const Standard_Integer Index) 
138 {
139   Backup();
140   myValue->Remove(Index);
141 }
142
143 Standard_Integer SALOMEDS_SequenceOfIntegerAttribute::Length() 
144 {
145   return myValue->Length();
146 }
147 Standard_Integer SALOMEDS_SequenceOfIntegerAttribute::Value(const Standard_Integer Index) 
148 {
149   return myValue->Value(Index);
150 }
151