+ // old code, it is useless, because <aSSObj->GetObject()> here will be NULL
+ // (because it is retrieved from <aSSObj> by stored IOR)
+ /*
+ SALOMEDS_Study* aSStudy = dynamic_cast<SALOMEDS_Study*>( aSObj->GetStudy().get() );
+ SALOMEDS_SObject* aSSObj = dynamic_cast<SALOMEDS_SObject*>( aSObj.get() );
+ if ( aSStudy && aSSObj )
+ ior = aSStudy->ConvertObjectToIOR( aSSObj->GetObject() ).c_str();
+ //*/
+
+ // new code
+
+ // default value: null IOR (IOR:01000000010000000000...)
+ SalomeApp_Application* anApp = theModule->getApp();
+ CORBA::Object_var aNullObj;
+ ior = anApp->orb()->object_to_string(aNullObj);
+
+ // try to load a component data from an opened (presumably) study
+ _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
+ std::string aCompIOR;
+ if (!aSComp->ComponentIOR(aCompIOR)) {
+ std::string aCompDataType = aSComp->ComponentDataType();
+
+ // obtain a driver by a component data type
+ // like it is done in SALOMEDS_DriverFactory_i::GetDriverByType
+ SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_nil();
+ SALOME_LifeCycleCORBA * LCC = anApp->lcc();
+ try {
+ CORBA::Object_var
+ anEngineObj = LCC->FindOrLoad_Component("FactoryServer", aCompDataType.c_str());
+ if (CORBA::is_nil(anEngineObj))
+ anEngineObj = LCC->FindOrLoad_Component("FactoryServerPy", aCompDataType.c_str());
+
+ if (!CORBA::is_nil(anEngineObj))
+ anEngine = SALOMEDS::Driver::_narrow(anEngineObj);
+ }
+ catch (...) {
+ }
+
+ if (!CORBA::is_nil(anEngine)) {
+ // try to load
+ _PTR(StudyBuilder) aStudyBuilder = aSObj->GetStudy()->NewBuilder();
+ bool isOk = true;
+ try {
+ CORBA::String_var aDriverIOR = anApp->orb()->object_to_string(anEngine);
+ aStudyBuilder->LoadWith(aSComp, aDriverIOR.in());
+ }
+ catch (...) {
+ isOk = false;
+ }
+
+ if (isOk) {
+ // now try to obtain the IOR once again (after successfull component data loading)
+ if (aSObj->FindAttribute( anAttr, "AttributeIOR" )) {
+ _PTR(AttributeIOR) anIOR ( anAttr );
+ ior = anIOR->Value().c_str();
+ }
+ }
+ } // if (!CORBA::is_nil(anEngine))
+ } // if (!aSComp->ComponentIOR(aCompIOR))
+
+ return ior;
+ }
+
+} // no name namespace