Salome HOME
ENV: Windows porting.
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_AttributeTarget.cxx
1 //  File   : SALOMEDS_AttributeTarget.cxx
2 //  Author : Sergey RUIN
3 //  Module : SALOME
4
5 #include "SALOMEDS_AttributeTarget.hxx"
6
7 #include <TColStd_HSequenceOfTransient.hxx>
8
9 #include "SALOMEDSImpl_SObject.hxx"
10 #include "SALOMEDS_SObject.hxx"
11
12
13 SALOMEDS_AttributeTarget::SALOMEDS_AttributeTarget(const Handle(SALOMEDSImpl_AttributeTarget)& theAttr)
14 :SALOMEDS_GenericAttribute(theAttr)
15 {}
16
17 SALOMEDS_AttributeTarget::SALOMEDS_AttributeTarget(SALOMEDS::AttributeTarget_ptr theAttr)
18 :SALOMEDS_GenericAttribute(theAttr)
19 {}
20
21 SALOMEDS_AttributeTarget::~SALOMEDS_AttributeTarget()
22 {}
23
24 void SALOMEDS_AttributeTarget::Add(const _PTR(SObject)& theObject)
25 {
26   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
27
28   if(_isLocal) Handle(SALOMEDSImpl_AttributeTarget)::DownCast(_local_impl)->Add(aSO->GetLocalImpl());
29   else SALOMEDS::AttributeTarget::_narrow(_corba_impl)->Add(aSO->GetCORBAImpl());
30 }
31
32 std::vector<_PTR(SObject)> SALOMEDS_AttributeTarget::Get()
33 {
34   std::vector<_PTR(SObject)> aVector;
35   int aLength, i;
36   SALOMEDSClient_SObject* aSO = NULL;
37   
38   if(_isLocal) {
39     Handle(TColStd_HSequenceOfTransient) aSeq = Handle(SALOMEDSImpl_AttributeTarget)::DownCast(_local_impl)->Get();
40     aLength = aSeq->Length();
41     for(i=1; i<=aLength; i++) {
42       aSO = new SALOMEDS_SObject(Handle(SALOMEDSImpl_SObject)::DownCast(aSeq->Value(i)));
43       aVector.push_back(_PTR(SObject)(aSO));
44     }
45   }
46   else {
47     SALOMEDS::Study::ListOfSObject_var aSeq = SALOMEDS::AttributeTarget::_narrow(_corba_impl)->Get();
48     aLength = aSeq->length();
49     aSO = new SALOMEDS_SObject(aSeq[i].in());
50     for(i = 0; i<aLength; i++) aVector.push_back(_PTR(SObject)(aSO));
51   }
52
53   return aVector;
54 }
55
56 void SALOMEDS_AttributeTarget::Remove(const _PTR(SObject)& theObject)
57 {
58   SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(theObject.get());
59
60   if(_isLocal) Handle(SALOMEDSImpl_AttributeTarget)::DownCast(_local_impl)->Remove(aSO->GetLocalImpl());
61   else SALOMEDS::AttributeTarget::_narrow(_corba_impl)->Remove(aSO->GetCORBAImpl());
62 }
63