Personal tools
You are here: Home Forum Other... (new forum, problems, etc.) IOR does not save in project

IOR does not save in project

Up to Other... (new forum, problems, etc.)

IOR does not save in project

Posted by dmitriy at May 20. 2012

Hello. Now i am doing my module on Python. But i have some difficulties. I create sobject and publish it in tree. Then i install IOR property. After save/load IOR property disappears. Here is my code:

 

sobject = builder.NewObject( elem_father )

attr = builder.FindOrCreateAttribute( sobject, "AttributeName" )

attr.SetValue( object.getName())

attr = builder.FindOrCreateAttribute( sobject, "AttributeIOR" )

attr.SetValue( ObjectToString( object ))

attr = builder.FindOrCreateAttribute( sobject, "AttributeLocalID" )

attr.SetValue( objectID())

 

 

Is it a bug or my mistake?

Re: IOR does not save in project

Posted by Saint Michael at May 21. 2012

Hello Dmitry

In order save/load to work, you should implement the following methods of your module's engine
for save:
  SALOMEDS::TMPFile* Save( SALOMEDS::SComponent_ptr theComponent,
                           const char*              theURL,
                           bool                     isMultiFile );
- here you save your module's data into a string and return this string.
  char* IORToLocalPersistentID( SALOMEDS::SObject_ptr theSObject,
                                const char*           IORString,
                                CORBA::Boolean        isMultiFile,
                                CORBA::Boolean        isASCII );
- here you should return an unique string ID of your object published in the study. The ID to return can be any string by which you can discriminate your objects during loading the study.

for load:

  bool Load( SALOMEDS::SComponent_ptr theComponent,
             const SALOMEDS::TMPFile& theStream,
             const char*              theURL,
             bool                     isMultiFile );
- here you load you module's data from a sting.
  char* LocalPersistentIDToIOR( SALOMEDS::SObject_ptr theSObject,
                                const char*           aLocalPersistentID,
                                CORBA::Boolean        isMultiFile,
                                CORBA::Boolean        isASCII );
- here your should return an IOR of your published object, which was created during Load(...), by an unique string ID of your object.

St.Michael

Re: IOR does not save in project

Posted by dmitriy at May 22. 2012

Saint Michael, thank you. Can you explain how to save/load module's data into/from a string? Or can you give me link for an example?

 

Re: IOR does not save in project

Posted by Saint Michael at May 22. 2012

Here is a sample code.

Attachments

Re: IOR does not save in project

Posted by dmitriy at May 24. 2012

Thank you for sample. But i get trouble again.

 

I can't save all my object's parameters in string (in "save" method), so i save object's ID's/IOR's (is it correct?). After "Load" all restores, but i can't call methods of objects. I get:

 

return _omnipy.invoke(self, "getName", _0_MBS_ORB.Element._d_getName, args)

 

TRANSIENT: CORBA.TRANSIENT(omniORB.TRANSIENT_ConnectFailed, CORBA.COMPLETED_NO)

 

What am i doing wrong?

 

Re: IOR does not save in project

Posted by Saint Michael at May 25. 2012

Hi Dmitry

I try to explain what is happening during save/restore.

A study object (SALOMEDS_SObject) keeps an IOR of a CORBA object. The IOR is an identifier of a CORBA object by which the CORBA object can be retrieved from an ORB. This is the way a study object is associated with a data object wrapped into the CORBA object.

When the study object is saved it does not save the IOR since after loading the IOR will become different. Instead, the study object stores a "LocalPersistentID" returned from IORToLocalPersistentID().

During Load() you create new CORBA objects wrapping your data objects. After that, to restore association of a study object to a CORBA object, LocalPersistentIDToIOR() is called where you should find by "LocalPersistentID" a new CORBA object corresponding to a study object and return its new IOR.

St.Michael

Quick reply
URLs will be automatically hyperlinked. Basic HTML tags are OK.
Powered by Ploneboard
History
Activate by dmitriy on May 20, 2012 01:30 PM
Document Actions