Salome HOME
PR: merge from branch BR_UT_V310a3 tag mergeto_trunk_05dec05
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_SComponent.cxx
1 //  File   : SALOMEDS_SComponent.cxx
2 //  Author : Sergey RUIN
3 //  Module : SALOME
4
5
6
7 #include "SALOMEDS_SComponent.hxx"
8 #include "SALOMEDS_SComponent_i.hxx"
9 #include <string> 
10 #include <TCollection_AsciiString.hxx> 
11
12 using namespace std; 
13
14 SALOMEDS_SComponent::SALOMEDS_SComponent(SALOMEDS::SComponent_ptr theSComponent)
15 :SALOMEDS_SObject(theSComponent) 
16 {}
17
18 SALOMEDS_SComponent::SALOMEDS_SComponent(const Handle(SALOMEDSImpl_SComponent)& theSComponent)
19 :SALOMEDS_SObject(theSComponent) 
20 {}
21
22 SALOMEDS_SComponent::~SALOMEDS_SComponent()
23 {}
24
25 std::string SALOMEDS_SComponent::ComponentDataType()
26 {
27   std::string aType;
28   if(_isLocal) {
29     aType = (Handle(SALOMEDSImpl_SComponent)::DownCast(GetLocalImpl()))->ComponentDataType().ToCString();
30   }
31   else aType = (SALOMEDS::SComponent::_narrow(GetCORBAImpl()))->ComponentDataType();
32
33   return aType;
34 }
35
36 bool SALOMEDS_SComponent::ComponentIOR(std::string& theID)
37 {
38   bool ret;
39   if(_isLocal) { 
40     TCollection_AsciiString anIOR;
41     ret = (Handle(SALOMEDSImpl_SComponent)::DownCast(GetLocalImpl()))->ComponentIOR(anIOR);
42     theID = anIOR.ToCString();
43   }
44   else {
45     CORBA::String_var anIOR;
46     ret = (SALOMEDS::SComponent::_narrow(GetCORBAImpl()))->ComponentIOR(anIOR.out());
47     theID = std::string(anIOR.in());                    
48   }
49
50   return ret;
51 }
52
53 SALOMEDS::SComponent_ptr SALOMEDS_SComponent::GetSComponent()
54 {
55   if(_isLocal) {
56     if(!CORBA::is_nil(_corba_impl)) return SALOMEDS::SComponent::_narrow(GetCORBAImpl());
57     SALOMEDS::SComponent_var aSCO = SALOMEDS_SComponent_i::New(Handle(SALOMEDSImpl_SComponent)::DownCast(GetLocalImpl()),
58                                                                _orb);
59     return aSCO._retn();
60   }
61   else {
62     return SALOMEDS::SComponent::_narrow(GetCORBAImpl());
63   }
64
65   return SALOMEDS::SComponent::_nil();
66 }
67