Salome HOME
ENV: Windows porting.
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttributeSequenceOfInteger.cxx
1 //  File   : SALOMEDS_AttributeSequenceOfInteger.cxx
2 //  Author : Sergey RUIN
3 //  Module : SALOME
4
5 #include "SALOMEDS_AttributeSequenceOfInteger.hxx"
6
7 #include <TCollection_AsciiString.hxx>
8 #include <TCollection_ExtendedString.hxx>
9 #include <TColStd_HSequenceOfInteger.hxx>
10
11 SALOMEDS_AttributeSequenceOfInteger
12 ::SALOMEDS_AttributeSequenceOfInteger(const Handle(SALOMEDSImpl_AttributeSequenceOfInteger)& theAttr)
13 :SALOMEDS_GenericAttribute(theAttr)
14 {}
15
16 SALOMEDS_AttributeSequenceOfInteger::SALOMEDS_AttributeSequenceOfInteger(SALOMEDS::AttributeSequenceOfInteger_ptr theAttr)
17 :SALOMEDS_GenericAttribute(theAttr)
18 {}
19
20 SALOMEDS_AttributeSequenceOfInteger::~SALOMEDS_AttributeSequenceOfInteger()
21 {}
22
23 void SALOMEDS_AttributeSequenceOfInteger::Assign(const std::vector<int>& other)
24 {
25   int i, aLength = other.size();
26   if(_isLocal) {
27     Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger;
28     for(i = 0; i < aLength; i++) aSeq->Append(other[i]);
29     Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl)->Assign(aSeq);
30   }
31   else {
32     SALOMEDS::LongSeq_var aSeq = new SALOMEDS::LongSeq();
33     aSeq->length(aLength);
34     for(i = 0; i < aLength; i++) aSeq[i] = other[i];
35     SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)->Assign(aSeq);
36   }
37 }
38
39 std::vector<int> SALOMEDS_AttributeSequenceOfInteger::CorbaSequence()
40 {
41   std::vector<int> aVector;
42   int i, aLength;
43   if(_isLocal) {
44     Handle(SALOMEDSImpl_AttributeSequenceOfInteger) aSeqAttr;
45     aSeqAttr = Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl);
46     aLength = aSeqAttr->Length();
47     for(i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i));
48   }
49   else {
50     SALOMEDS::AttributeSequenceOfInteger_var aSeqAttr = SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl);
51     aLength = aSeqAttr->Length();
52     for(i = 1; i <=aLength; i++) aVector.push_back(aSeqAttr->Value(i));
53   }
54   return aVector;
55 }
56  
57 void SALOMEDS_AttributeSequenceOfInteger::Add(int value)
58 {
59   if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl)->Add(value);
60   else SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)->Add(value);
61 }
62
63 void SALOMEDS_AttributeSequenceOfInteger::Remove(int index)
64 {
65   if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl)->Remove(index);
66   else SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)->Remove(index);
67 }
68  
69 void SALOMEDS_AttributeSequenceOfInteger::ChangeValue(int index, int value)
70 {
71   if(_isLocal) Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl)->ChangeValue(index, value);
72   else SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)->ChangeValue(index, value);
73 }
74  
75 int SALOMEDS_AttributeSequenceOfInteger::Value(int index)
76 {
77   int aValue;
78   if(_isLocal) aValue = Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl)->Value(index);
79   else aValue = SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)->Value(index);
80   return aValue;
81 }
82  
83 int SALOMEDS_AttributeSequenceOfInteger::Length()
84 {
85   int aValue;
86   if(_isLocal) aValue = Handle(SALOMEDSImpl_AttributeSequenceOfInteger)::DownCast(_local_impl)-> Length();
87   else aValue = SALOMEDS::AttributeSequenceOfInteger::_narrow(_corba_impl)-> Length();
88   return aValue;
89 }