1 // File : SALOMEDSImpl_AttributeSequenceOfInteger.cxx
2 // Author : Sergey RUIN
5 #include "SALOMEDSImpl_AttributeSequenceOfInteger.hxx"
6 #include <Standard_GUID.hxx>
10 IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeSequenceOfInteger, SALOMEDSImpl_GenericAttribute )
11 IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeSequenceOfInteger, SALOMEDSImpl_GenericAttribute )
14 //=======================================================================
17 //=======================================================================
19 const Standard_GUID& SALOMEDSImpl_AttributeSequenceOfInteger::GetID ()
21 static Standard_GUID SALOMEDSImpl_AttributeSequenceOfIntegerID ("12837182-8F52-11d6-A8A3-0001021E8C7F");
22 return SALOMEDSImpl_AttributeSequenceOfIntegerID;
27 //=======================================================================
30 //=======================================================================
32 Handle(SALOMEDSImpl_AttributeSequenceOfInteger) SALOMEDSImpl_AttributeSequenceOfInteger::Set (const TDF_Label& L)
34 Handle(SALOMEDSImpl_AttributeSequenceOfInteger) A;
35 if (!L.FindAttribute(SALOMEDSImpl_AttributeSequenceOfInteger::GetID(),A)) {
36 A = new SALOMEDSImpl_AttributeSequenceOfInteger();
43 //=======================================================================
44 //function : constructor
46 //=======================================================================
47 SALOMEDSImpl_AttributeSequenceOfInteger::SALOMEDSImpl_AttributeSequenceOfInteger()
48 :SALOMEDSImpl_GenericAttribute("AttributeSequenceOfInteger")
50 myValue = new TColStd_HSequenceOfInteger();
53 //=======================================================================
56 //=======================================================================
58 const Standard_GUID& SALOMEDSImpl_AttributeSequenceOfInteger::ID () const { return GetID(); }
61 //=======================================================================
64 //=======================================================================
66 Handle(TDF_Attribute) SALOMEDSImpl_AttributeSequenceOfInteger::NewEmpty () const
68 return new SALOMEDSImpl_AttributeSequenceOfInteger();
71 //=======================================================================
74 //=======================================================================
76 void SALOMEDSImpl_AttributeSequenceOfInteger::Restore(const Handle(TDF_Attribute)& with)
79 Handle(SALOMEDSImpl_AttributeSequenceOfInteger) anSeq = Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(with);
80 if(!anSeq->myValue.IsNull()) {
81 myValue = new TColStd_HSequenceOfInteger();
82 Standard_Integer Len = anSeq->Length();
83 for(i = 1; i<=Len; i++) Add(anSeq->Value(i));
90 //=======================================================================
93 //=======================================================================
95 void SALOMEDSImpl_AttributeSequenceOfInteger::Paste (const Handle(TDF_Attribute)& into,
96 const Handle(TDF_RelocationTable)& ) const
98 if(!myValue.IsNull()) {
99 Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast (into)->Assign(myValue);
103 void SALOMEDSImpl_AttributeSequenceOfInteger::Assign(const Handle(TColStd_HSequenceOfInteger)& other)
107 if (myValue.IsNull()) myValue = new TColStd_HSequenceOfInteger;
108 myValue->ChangeSequence() = other->Sequence();
110 SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
113 void SALOMEDSImpl_AttributeSequenceOfInteger::ChangeValue(const Standard_Integer Index,const Standard_Integer Value)
117 myValue->SetValue(Index, Value);
119 SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
122 void SALOMEDSImpl_AttributeSequenceOfInteger::Add(const Standard_Integer Value)
126 myValue->Append(Value);
128 SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
131 void SALOMEDSImpl_AttributeSequenceOfInteger::Remove(const Standard_Integer Index)
135 myValue->Remove(Index);
137 SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
140 Standard_Integer SALOMEDSImpl_AttributeSequenceOfInteger::Length()
142 return myValue->Length();
144 Standard_Integer SALOMEDSImpl_AttributeSequenceOfInteger::Value(const Standard_Integer Index)
146 return myValue->Value(Index);
151 TCollection_AsciiString SALOMEDSImpl_AttributeSequenceOfInteger::Save()
153 Standard_Integer aLength = Length();
154 char* aResult = new char[aLength * 25];
156 Standard_Integer aPosition = 0;
157 for (int i = 1; i <= aLength; i++) {
158 sprintf(aResult + aPosition , "%d ", Value(i));
159 aPosition += strlen(aResult + aPosition);
161 TCollection_AsciiString ret(aResult);
167 void SALOMEDSImpl_AttributeSequenceOfInteger::Load(const TCollection_AsciiString& value)
169 Handle(TColStd_HSequenceOfInteger) CasCadeSeq = new TColStd_HSequenceOfInteger;
171 char* aCopy = value.ToCString();
172 char* adr = strtok(aCopy, " ");
175 CasCadeSeq->Append(l);
176 adr = strtok(NULL, " ");