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