From: rnv
Date: Thu, 21 Dec 2017 13:57:35 +0000 (+0300)
Subject: Merge changes from 'master' branch.
X-Git-Tag: V9_0_0~3
X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4b14a3f48efda72f90b88c78c6ae02153631dfd6;p=modules%2Fkernel.git
Merge changes from 'master' branch.
---
4b14a3f48efda72f90b88c78c6ae02153631dfd6
diff --cc bin/appliskel/salome_tester/salome_test_driver.py
index 62dcc5fe2,c167e97f6..6bc8b9771
--- a/bin/appliskel/salome_tester/salome_test_driver.py
+++ b/bin/appliskel/salome_tester/salome_test_driver.py
@@@ -80,7 -54,7 +80,7 @@@ if __name__ == "__main__"
setOmniOrbUserPath()
# Set timeout handler
- print("Test timeout explicitely set to: %s seconds"%timeout_delay)
- print "Test timeout explicitly set to: %s seconds"%timeout_delay
++ print("Test timeout explicitly set to: %s seconds"%timeout_delay)
timeout_sec = abs(int(timeout_delay)-10)
if sys.platform == 'win32':
from threading import Timer
diff --cc bin/appliskel/salome_tester/salome_test_driver_gui.py
index 92a19d6b3,1e99d312d..9d4940d95
--- a/bin/appliskel/salome_tester/salome_test_driver_gui.py
+++ b/bin/appliskel/salome_tester/salome_test_driver_gui.py
@@@ -51,7 -51,7 +51,7 @@@ if __name__ == "__main__"
setOmniOrbUserPath()
# Set timeout handler
- print("Test timeout explicitely set to: %s seconds"%timeout_delay)
- print "Test timeout explicitly set to: %s seconds"%timeout_delay
++ print("Test timeout explicitly set to: %s seconds"%timeout_delay)
timeout_sec = abs(int(timeout_delay)-10)
if sys.platform == 'win32':
from threading import Timer
diff --cc bin/launchConfigureParser.py
index afe604591,06b9645d8..e32982a54
--- a/bin/launchConfigureParser.py
+++ b/bin/launchConfigureParser.py
@@@ -764,11 -767,11 +764,11 @@@ Python file arguments, if any, must be
# wake up session
help_str = "Wake up a previously closed session. "
help_str += "The session object is found in the naming service pointed by the variable OMNIORB_CONFIG. "
- help_str += "If this variable is not setted, the last configuration is taken. "
+ help_str += "If this variable is not set, the last configuration is taken. "
- o_wake_up = optparse.Option("--wake-up-session",
- action="store_true",
- dest="wake_up_session", default=False,
- help=help_str)
+ pars.add_argument("--wake-up-session",
+ action="store_true",
- dest="wake_up_session",
++ dest="wake_up_session", default=False,
+ help=help_str)
# server launch mode
help_str = "Mode used to launch server processes (daemon or fork)."
diff --cc doc/salome/examples/example19
index 1a60f7df8,db65c7d92..afa10acb7
--- a/doc/salome/examples/example19
+++ b/doc/salome/examples/example19
@@@ -235,13 -235,13 +235,13 @@@ Mulz = Mul.Port('z'
Divz = Div.Port('z')
# This DataFlow is "executable" : all pending Ports are defined with Datas
-print myGraph.IsExecutable()
+print(myGraph.IsExecutable())
- # Starts only execution of that DataFlow and gets control immediatly
+ # Starts only execution of that DataFlow and gets control immediately
-print myGraph.Run()
+print(myGraph.Run())
# That DataFlow is running ==> 0 (false)
-print myGraph.IsDone()
+print(myGraph.IsDone())
# Events of execution :
aStatus,aNode,anEvent,aState = myGraph.Event()
diff --cc idl/SALOMEDS.idl
index eb14c2fa0,8e8f4f218..e063ff7ad
--- a/idl/SALOMEDS.idl
+++ b/idl/SALOMEDS.idl
@@@ -98,752 -105,899 +98,752 @@@ module SALOMED
//! Exception indicating that this feature hasn't been implemented in %SALOME application.
exception NotImplemented {};
+ //==========================================================================
+/*! \brief %Study Builder Interface
- //===========================================================================
- /*! \brief %Study Interface
-
- The purpose of the %Study is to manage the data produced by various components of %SALOME platform.
- Most of the %Study operations are handled by the StudyManager and the StudyBuilder.
- What is left in the %Study interface are elementary inquiries.
- (Incidentally, we recall that a CORBA attribute is implemented as a pair of get
- and set methods.) A %Study is explored by a set of tools, mainly iterators
- , which are described further. Nevertheless, the %Study
- interface allows the search of an object by name or by ID.
- \note
-
The Path of an object in %SALOME application is much alike a standard path of a file.
- In general it's a string of names of directories divided by a slash '/'.
-
The Context is the current directory of an object.
+ The purpose of the Builder is to add and/or remove objects and attributes.
+ A %StudyBuilder is linked to a %Study. A
+ command management is provided for the undo/redo functionalities.
+ \note
+
The Tag of an item in %SALOME application is a symbolic description of
+ item's position in the tree-type structure of the browser. In general it has the following
+ form: 0:2:1:1
*/
+ //==========================================================================
- interface Study
+ interface StudyBuilder
{
+/*! \brief %LockProtection Exception
-//! Invalid study reference
- exception StudyInvalidReference {};
-//! Invalid study context
- exception StudyInvalidContext {};
-//! Invalid study component
- exception StudyInvalidComponent {};
-//! Invalid directory of the %study exception
- exception StudyInvalidDirectory {};
-//! Exception pointing that this name of the study has already been used.
- exception StudyNameAlreadyUsed {};
-//! study object already exists
- exception StudyObjectAlreadyExists {};
-//! Invalid name of the %study exception
- exception StudyNameError {};
-//! Invalid study comment
- exception StudyCommentError {};
-
-/*! \brief The name of the %Study
-
- This is equivalent to the methods setName() & getName()
+ This exception is raised while attempting to modify a locked %study.
*/
- attribute string Name; // equivalent to setName() & getName()
-/*! \brief The ID of the %Study
+ exception LockProtection {};
+/*! \brief Creation of a new %SComponent.
- This is equivalent to the methods setID() & getID()
-*/
- attribute short StudyId;
-//! Sequence containing %SObjects
- typedef sequence ListOfSObject;
-//! Get the persistent reference to the %Study.
- PersistentReference GetPersistentReference() raises(StudyInvalidReference);
-//! Get a transient reference to the %Study.
- SalomeReference GetTransientReference() raises(StudyInvalidReference);
+ Creates a new %SComponent
+ \param ComponentDataType Data type of the %SComponent which will be created.
-/*! \brief indicate whether the %Study is empty
+See \ref example17 for an example of this method usage in batchmode of %SALOME application.
- \return True if the %Study is empty
*/
- boolean IsEmpty() raises(StudyInvalidReference);
-/*! \brief Find a %SComponent by its name.
-
- \param aComponentName It's a string value in the Comment Attribute of the Component,
- which is looked for, defining the data type of this Component.
+ SComponent NewComponent(in string ComponentDataType) raises(LockProtection);
-See \ref example1 for an example of this method usage in batchmode of %SALOME application.
+/*! \brief Definition of the instance to the %SComponent
+ Defines the instance to the %SComponent.
*/
- SComponent FindComponent (in string aComponentName) raises(StudyInvalidReference);
+ void DefineComponentInstance (in SComponent aComponent,in Object ComponentIOR) raises(LockProtection);
-/*! \brief Find a %SComponent by ID of the according %SObject
+/*! \brief Deletion of a %SComponent
+
+ Removes a %SComponent.
*/
- SComponent FindComponentID(in ID aComponentID) raises(StudyInvalidReference);
-/*! \brief Find a %SObject by the Name Attribute of this %SObject
+ void RemoveComponent(in SComponent aComponent) raises(LockProtection);
- \param anObjectName String parameter defining the name of the object
- \return The obtained %SObject
+/*! \brief Creation of a new %SObject
-See \ref example19 for an example of this method usage in batchmode of %SALOME application.
-*/
- SObject FindObject (in string anObjectName) raises(StudyInvalidReference);
-/*! \brief Find a %SObject by its ID
+ Creates a new %SObject under a definite father %SObject.
- \param aObjectID This parameter defines the ID of the required object
- \return The obtained %SObject
-*/
- SObject FindObjectID (in ID aObjectID) raises(StudyInvalidReference);
-/*! \brief Create a %SObject by its ID
+ \param theFatherObject The father %SObject under which this one should be created.
+ \return New %SObject
- \param aObjectID This parameter defines the ID of the required object
- \return The created %SObject
-*/
- SObject CreateObjectID (in ID aObjectID) raises(StudyInvalidReference);
-/*! \brief Find a %SObject by IOR of the object belonging to this %SObject.
+See \ref example18 for an example of this method usage in batchmode of %SALOME application.
- \param anObjectName This parameter defines the IOR of the object
- \return The obtained %SObject
*/
- SObject FindObjectIOR (in ID aObjectIOR) raises(StudyInvalidReference);
-/*! \brief Find in the study all %SObjects produced by a given %Component.
- \param anObjectName The Name Attribute of the searched %SObjects should correspond to anObjectName.
- \param aComponentName The name of the component, which objects are searched for.
-*/
- ListOfSObject FindObjectByName(in string anObjectName, in string aComponentName) raises(StudyInvalidReference);
-/*! \brief Find a %SObject by the path to it.
+ SObject NewObject (in SObject theFatherObject) raises(LockProtection);
- \param thePath The path to the required %SObject.
- \return The obtained %SObject.
-*/
- SObject FindObjectByPath(in string thePath) raises(StudyInvalidReference);
-/*! \brief Get the path to the %SObject.
-*/
- string GetObjectPath(in Object theObject) raises(StudyInvalidReference);
+/*! \brief Creation of a new %SObject with a definite %tag
-/*! \brief Set the context of the %Study.
+ Creates a new %SObject with a definite %tag.
- \param thePath String parameter defining the context of the study.
+ \param atag Long value corresponding to the tag of the new %SObject.
+ \return New %SObject
-See \ref example23 for an example of this method usage in batchmode of %SALOME application.
*/
- void SetContext(in string thePath) raises (StudyInvalidReference, StudyInvalidContext);
-/*! \brief Get the context of the %Study.
+ SObject NewObjectToTag (in SObject theFatherObject, in long atag) raises(LockProtection);
+/*! \brief Deletion of the %SObject
-See \ref example23 for an example of this method usage in batchmode of %SALOME application.
-*/
- string GetContext() raises (StudyInvalidReference, StudyInvalidContext);
-/*! \brief Get a list of names of objects corresponding to the context.
+ Removes a %SObject from the %StudyBuilder.
- \note If the parameter theContext is empty, then the current context will be used.
+ \param anObject The %SObject to be deleted.
*/
- ListOfStrings GetObjectNames(in string theContext) raises (StudyInvalidReference, StudyInvalidContext);
-/*! \brief Get a list of names of directories and subdirectories corresponding to the context.
+ void RemoveObject (in SObject anObject) raises(LockProtection);
+/*! \brief Deletion of the %SObject with all his child objects.
- \note If the parameter theContext is empty, then the current context will be used.
-*/
- ListOfStrings GetDirectoryNames(in string theContext) raises (StudyInvalidReference, StudyInvalidContext);
-/*! \brief Get a list of names of Files corresponding to the context.
+ Removes the %SObject with all his child objects.
- \note If the parameter theContext is empty, then the current context will be used.
+ \param anObject The %SObject to be deleted with all child objects.
*/
- ListOfStrings GetFileNames(in string theContext) raises (StudyInvalidReference, StudyInvalidContext);
-/*! \brief Get a list of names of Components corresponding to the context.
+ void RemoveObjectWithChildren(in SObject anObject) raises(LockProtection);
- \note If the parameter theContext is empty, then the current context will be used.
-*/
- ListOfStrings GetComponentNames(in string theContext) raises(StudyInvalidReference);
-/*! \brief Create a new iterator of child levels of the given %SObject.
+/*!
+ Loads a %SComponent.
- \param aSO The given %SObject
- \return A new iterator of child levels of the given %SObject.
-*/
- ChildIterator NewChildIterator(in SObject aSO) raises(StudyInvalidReference);
+See \ref example19 for an example of this method usage in batchmode of %SALOME application.
-/*! \brief Create a new iterator of the %SComponents.
+*/
+ void LoadWith (in SComponent sco, in Driver Engine) raises (SALOME::SALOME_Exception);
+/*!
+ Loads a %SObject.
- \return A new iterator of the %SComponents.
+ \param sco %SObject to be loaded.
*/
- SComponentIterator NewComponentIterator() raises(StudyInvalidReference);
+ void Load (in SObject sco);
-/*! \brief Create a new %StudyBuilder to add or modify an object in the study.
+/*! \brief Looking for or creating an attribute assigned to the %SObject
- \return A new %StudyBuilder.
+ Allows to find or create an attribute of a specific type which is assigned to the object.
+ \param anObject The %SObject corresponding to the attribute which is looked for.
+ \param aTypeOfAttribute Type of the attribute.
-See \ref example20 for an example of this method usage in batchmode of %SALOME application.
+See \ref example1 for an example of this method usage in batchmode of %SALOME application.
*/
- StudyBuilder NewBuilder() raises(StudyInvalidReference);
-/*! \brief Labels dependency
- Updates the map with IOR attribute. It's an inner method used for optimization.
-*/
- void UpdateIORLabelMap(in string anIOR, in string anEntry) raises(StudyInvalidReference);
+ GenericAttribute FindOrCreateAttribute(in SObject anObject,
+ in string aTypeOfAttribute) raises(LockProtection);
-/*! \brief Getting properties of the study
+/*! \brief Looking for an attribute assigned to a %SObject
- Returns the attribute, which contains the properties of this study.
+ Allows to find an attribute of a specific type which is assigned to the object.
+ \param anObject The %SObject corresponding to the attribute which is looked for.
+ \param aTypeOfAttribute Type of the attribute.
+ \param anAttribute Where the attribute is placed if it's found.
+ \return True if it finds an attribute.
+ */
-See \ref example20 for an example of this method usage in batchmode of %SALOME application.
+ boolean FindAttribute(in SObject anObject,
+ out GenericAttribute anAttribute,
+ in string aTypeOfAttribute);
+/*! \brief Deleting the attribute assigned to the %SObject
-*/
- AttributeStudyProperties GetProperties() raises(StudyInvalidReference);
-/*! \brief Indicate whether the %study has been saved
-*/
- attribute boolean IsSaved;
-/*! \brief Indicate whether the %study has been modified and not saved.
+ Removes the attribute of a specific type which is assigned to the object.
+ \param anObject The %SObject corresponding to the attribute.
+ \param aTypeOfAttribute Type of the attribute.
- Returns True if the %study has been modified and not saved.
+See \ref example17 for an example of this method usage in batchmode of %SALOME application.
*/
- boolean IsModified() raises(StudyInvalidReference);
-
-/*! \brief Mark the %study as being modified and not saved.
+ void RemoveAttribute(in SObject anObject,
+ in string aTypeOfAttribute) raises(LockProtection);
+/*!
+ Adds a reference between %anObject and %theReferencedObject.
+ \param anObject The %SObject which will get a reference
+ \param theReferencedObject The %SObject having a reference
*/
- void Modified() raises(StudyInvalidReference);
-/*! \brief Indicate the file where the %study has been saved
+ void Addreference(in SObject anObject,
+ in SObject theReferencedObject) ;
+
+/*!
+ Removes a reference from %anObject to another object.
+ \param anObject The %SObject which contains a reference
*/
- attribute string URL;
-/*! \brief List of %SObjects
+ void RemoveReference(in SObject anObject) ;
- Returns the list of %SObjects which refers to %anObject.
-*/
- ListOfSObject FindDependances(in SObject anObject) raises(StudyInvalidReference);
+/*! \brief Identification of the %SObject's substructure.
-/*! \brief The date of the last saving of the study
+ Identification of the %SObject's substructure by GUID.
- Returns the date of the last saving of study with format: "DD/MM/YYYY HH:MM"
-*/
- string GetLastModificationDate() raises(StudyInvalidReference);
-/*! \brief The list of modification dates of the study
- Returns the list of modification dates (without creation date) with format "DD/MM/YYYY HH:MM".
- Note : the first modification begins the list.
+ \param anObject The %SObject which will be identified
+ \param theGUID GUID has the following format "00000000-0000-0000-0000-000000000000"
*/
- ListOfDates GetModificationsDate() raises(StudyInvalidReference);
-/*! \brief Object conversion.
+ void SetGUID(in SObject anObject, in string theGUID) raises(LockProtection);
+/*!
+Searches for a definite %SObject with a definite GUID and returns True if it finds it.
- Converts an object into IOR.
- \return IOR
+\param anObject A definite %SObject which will be identified
+\param theGUID GUID has the following format "00000000-0000-0000-0000-000000000000"
*/
- string ConvertObjectToIOR(in Object theObject);
-/*! \brief Object conversion.
+ boolean IsGUID(in SObject anObject, in string theGUID);
- Converts IOR into an object.
- \return An object
-*/
- Object ConvertIORToObject(in string theIOR);
+/*! \brief Creation of a new command
-/*! \brief Get a new %UseCaseBuilder.
-*/
- UseCaseBuilder GetUseCaseBuilder() raises(StudyInvalidReference);
+ Creates a new command which can contain several different actions.
-/*! \brief Close the components in the study, remove itself from the %StudyManager.
-*/
- void Close() raises(StudyInvalidReference);
+See \ref example3 for an example of this method usage in batchmode of %SALOME application.
-/*! \brief Enable (if isEnabled = True)/disable automatic addition of new %SObjects to the use case.
*/
- void EnableUseCaseAutoFilling(in boolean isEnabled) raises(StudyInvalidReference);
+ void NewCommand(); // command management
+/*! \brief Execution of the command
-/*!
- Functions for internal usage only
-*/
- void AddPostponed(in string theIOR) raises(StudyInvalidReference);
+ Commits all actions declared within this command.
- void AddCreatedPostponed(in string theIOR) raises(StudyInvalidReference);
+ \exception LockProtection This exception is raised, when trying to perform this command a study, which is protected for modifications.
- void RemovePostponed(in long theUndoLimit) raises(StudyInvalidReference);
+See \ref example16 for an example of this method usage in batchmode of %SALOME application.
- void UndoPostponed(in long theWay) raises(StudyInvalidReference);
-
- boolean DumpStudy(in string thePath,
- in string theBaseName,
- in boolean isPublished,
- in boolean isMultiFile) raises(StudyInvalidReference);
-
-/*! \brief Get an AttributeParameter used to store common parameters for given %theSavePoint.
-
- \param theID identifies a common parameters set (Example: "Interface Applicative")
- \param theSavePoint is number of a set of parameters as there can be several sets
-*/
- AttributeParameter GetCommonParameters(in string theID, in long theSavePoint) raises(StudyInvalidReference);
-
-/*! \brief Get an AttributeParameter used to store parameters for given %theModuleName.
-
- \param theID identifies a common parameters set (Example: "Interface Applicative")
- \param theModuleName is a name of the module (Example: "Geometry")
- \param theSavePoint is number of a set of parameters as there can be several sets
*/
- AttributeParameter GetModuleParameters(in string theID, in string theModuleName, in long theSavePoint) raises(StudyInvalidReference);
-
-
-/*! \brief Get a default Python script to restore visual parameters for given %theModuleName.
-
- \param theModuleName is a name of the module (Example: "Geometry")
- \param indent is a string to use for script indentation
-*/
- string GetDefaultScript(in string theModuleName, in string indent) raises(StudyInvalidReference);
-
+ void CommitCommand() raises(LockProtection); // command management
/*!
- Private method, returns an implementation of this Study.
- \param theHostname is a hostname of the caller
- \param thePID is a process ID of the caller
- \param isLocal is set True if the Study is launched locally with the caller
-*/
- long long GetLocalImpl(in string theHostname, in long thePID, out boolean isLocal);
-
-
-/*! \brief Mark this Study as being locked by the given locker.
-
- The lock status can be checked by method IsStudyLocked
- \param theLockerID identifies a locker of the study can be for ex. IOR of the engine that locks the study.
-*/
- void SetStudyLock(in string theLockerID) raises(StudyInvalidReference);
-
-/*! \brief Indicate if the Study is locked
-
- Returns True if the Study was marked locked.
+ Returns True if at this moment there is a command under execution.
*/
- boolean IsStudyLocked() raises(StudyInvalidReference);
+ boolean HasOpenCommand();
- /*! \brief Cancelation of the command
++/*! \brief Cancellation of the command
-/*! \brief Mark this Study as being unlocked by the given locker.
+ Cancels all actions declared within the command.
- The lock status can be checked by method IsStudyLocked
- \param theLockerID identifies a locker of the study can be for ex. IOR of the engine that unlocks the study.
+See \ref example17 for an example of this method usage in batchmode of %SALOME application.
*/
- void UnLockStudy(in string theLockerID) raises(StudyInvalidReference);
+ void AbortCommand(); // command management
+/*! \brief Undolimit
-/*! \brief Get the list of IDs of the Study's lockers.
+ The number of actions which can be undone
*/
- ListOfStrings GetLockerID() raises(StudyInvalidReference);
+ attribute long UndoLimit;
+/*! \brief Undo method
-/*! \brief Create real variable with Name theVarName and value theValue
+ Cancels all actions of the last command.
- (or set if variable value into theValue already exists)
- \param theVarName is a name of the variable
- \param theVarName is a value of the variable.
-*/
- void SetReal( in string theVarName, in double theValue ) raises(StudyInvalidReference);
+ \exception LockProtection This exception is raised, when trying to perform this command a study, which is protected for modifications.
-/*! \brief Create integer variable with Name theVarName and value theValue
+See \ref example16 for an example of this method usage in batchmode of %SALOME application.
- (or set if variable value into theValue already exists)
- \param theVarName is a name of the variable
- \param theVarName is a value of the variable.
*/
- void SetInteger( in string theVarName, in long theValue ) raises(StudyInvalidReference);
-/*! \brief Create boolean variable with Name theVarName and value theValue
+ void Undo() raises (LockProtection);
+/*! \brief Redo method
- (or set if variable value into theValue already exists)
- \param theVarName is a name of the variable
- \param theVarName is a value of the variable.
-*/
- void SetBoolean( in string theVarName, in boolean theValue ) raises(StudyInvalidReference);
+ Redoes all actions of the last command.
-/*! \brief Create string variable with Name theVarName and value theValue
+\exception LockProtection This exception is raised, when trying to perform this command a study, which is protected for modifications.
- (or set if variable value into theValue already exists)
- \param theVarName is a name of the variable
- \param theVarName is a value of the variable.
-*/
- void SetString( in string theVarName, in string theValue ) raises(StudyInvalidReference);
+See \ref example16 for an example of this method usage in batchmode of %SALOME application.
-/*! \brief Set current value as double for string variable
*/
- void SetStringAsDouble( in string theVarName, in double theValue ) raises(StudyInvalidReference);
+ void Redo() raises (LockProtection);
+/*!
+ Returns True if at this moment there are any actions which can be canceled.
-/*! \brief Get value of a real variable
+See \ref example16 for an example of this method usage in batchmode of %SALOME application.
- \param theVarName is a name of the variable.
*/
- double GetReal( in string theVarName ) raises(StudyInvalidReference);
+ boolean GetAvailableUndos();
+/*!
+ Returns True if at this moment there are any actions which can be redone.
-/*! \brief Get value of an integer variable
+See \ref example3 for an example of this method usage in batchmode of %SALOME application.
- \param theVarName is a name of the variable.
*/
- long GetInteger( in string theVarName ) raises(StudyInvalidReference);
-
-/*! \brief Get value of a boolean variable
+ boolean GetAvailableRedos();
+/*!
+ Puts name attribute with the given string value to the given %SObject
- \param theVarName is a name of the variable.
+ \param theSO Existing SObject to set name attribute.
+ \param theValue The value to be set to the name attribute.
*/
- boolean GetBoolean( in string theVarName ) raises(StudyInvalidReference);
+ void SetName(in SObject theSO, in string theValue) raises (LockProtection);
-/*! \brief Get value of a string variable
+/*!
+ Puts comment attribute with the given string value to the given %SObject
- \param theVarName is a name of the variable.
+ \param theSO Existing SObject to set comment attribute.
+ \param theValue The value to be set to the comment attribute.
*/
- string GetString( in string theVarName ) raises(StudyInvalidReference);
-
+ void SetComment(in SObject theSO, in string theValue) raises (LockProtection);
-/*! \brief Indicate if a variable is real
+/*!
+ Puts IOR attribute with the given string value to the given %SObject
- Return true if variable is real otherwise return false.
- \param theVarName is a name of the variable.
+ \param theSO Existing SObject to set IOR attribute.
+ \param theValue The value to be set to the IOR attribute.
*/
- boolean IsReal( in string theVarName ) raises(StudyInvalidReference);
+ void SetIOR(in SObject theSO, in string theValue) raises (LockProtection);
+ };
-/*! \brief Indicate if a variable is integer
+ //===========================================================================
+ /*! \brief %Study Interface
- Return true if variable is integer otherwise return false.
- \param theVarName is a name of the variable.
+ The purpose of the %Study is to manage the data produced by various components of %SALOME platform.
+ Most of the %Study operations are handled by the StudyBuilder.
+ What is left in the %Study interface are elementary inquiries.
+ (Incidentally, we recall that a CORBA attribute is implemented as a pair of get
+ and set methods.) A %Study is explored by a set of tools, mainly iterators
+ , which are described further. Nevertheless, the %Study
+ interface allows the search of an object by name or by ID.
+ \note
+
The Path of an object in %SALOME application is much alike a standard path of a file.
+ In general it's a string of names of directories divided by a slash '/'.
+
The Context is the current directory of an object.
*/
- boolean IsInteger( in string theVarName ) raises(StudyInvalidReference);
-/*! \brief Indicate if a variable is boolean
+ interface Study
+ {
- Return true if variable is boolean otherwise return false.
- \param theVarName is a name of the variable.
+//! Invalid study reference
+ exception StudyInvalidReference {};
+//! Invalid study component
+ exception StudyInvalidComponent {};
+//! Invalid directory of the %study exception
+ exception StudyInvalidDirectory {};
+//! Exception pointing that this name of the study has already been used.
+ exception StudyNameAlreadyUsed {};
+//! study object already exists
+ exception StudyObjectAlreadyExists {};
+//! Invalid name of the %study exception
+ exception StudyNameError {};
+//! Invalid study comment
+ exception StudyCommentError {};
+
+/*!
+ Determines whether the server has already been loaded or not.
*/
- boolean IsBoolean( in string theVarName ) raises(StudyInvalidReference);
-
-/*! \brief Indicate if a variable is string
+ void ping();
+ void Shutdown();
+/*!
+ Returns the PID of the server
+*/
+ long getPID();
- Return true if variable is string otherwise return false.
- \param theVarName is a name of the variable.
+/*!
+ Shutdown the Study process.
*/
- boolean IsString( in string theVarName ) raises(StudyInvalidReference);
+ oneway void ShutdownWithExit();
-/*! \brief Indicate if a variable exists in the study
+/*! \brief The name of the %Study
- Return true if variable exists in the study,
- otherwise return false.
- \param theVarName is a name of the variable.
+ This is equivalent to the methods setName() & getName()
*/
- boolean IsVariable( in string theVarName ) raises(StudyInvalidReference);
+ attribute wstring Name; // equivalent to getName()
-/*! \brief Get names of all variables from the study.
+/*! \brief Indicate the file where the %study has been saved
*/
- ListOfStrings GetVariableNames() raises(StudyInvalidReference);
-/*! \brief Remove a variable
+//! Sequence containing %SObjects
+ typedef sequence ListOfSObject;
+//! Get the persistent reference to the %Study.
+ PersistentReference GetPersistentReference() raises(StudyInvalidReference);
- Remove variable with the specified name from the study with substitution of its value.
+/*! \brief indicate whether the %Study is empty
- \param theVarName Name of the variable.
- \return Status of operation.
+ \return True if the %Study is empty
*/
- boolean RemoveVariable( in string theVarName ) raises(StudyInvalidReference);
+ boolean IsEmpty() raises(StudyInvalidReference);
+/*! \brief Find a %SComponent by its name.
-/*! \brief Rename a variable
+ \param aComponentName It's a string value in the Comment Attribute of the Component,
+ which is looked for, defining the data type of this Component.
- Rename variable with the specified name within the study.
+See \ref example1 for an example of this method usage in batchmode of %SALOME application.
- \param theVarName Name of the variable.
- \param theNewVarName New name for the variable.
- \return Status of operation.
*/
- boolean RenameVariable( in string theVarName, in string theNewVarName ) raises(StudyInvalidReference);
-
-/*! \brief Indicate whether variable is used
-
- Check that variable is used in the study.
+ SComponent FindComponent (in string aComponentName) raises(StudyInvalidReference);
- \param theVarName Name of the variable.
- \return Variable usage.
+/*! \brief Find a %SComponent by ID of the according %SObject
*/
- boolean IsVariableUsed( in string theVarName ) raises(StudyInvalidReference);
+ SComponent FindComponentID(in ID aComponentID) raises(StudyInvalidReference);
+/*! \brief Find a %SObject by the Name Attribute of this %SObject
-/*! \brief Parse variables used for object creation
+ \param anObjectName String parameter defining the name of the object
+ \return The obtained %SObject
- \param string with variables, separated by special symbol.
- \return Variables list.
+See \ref example19 for an example of this method usage in batchmode of %SALOME application.
*/
- ListOfListOfStrings ParseVariables( in string theVars ) raises(StudyInvalidReference);
-
-/*!
- Attach an observer to the Study
+ SObject FindObject (in string anObjectName) raises(StudyInvalidReference);
+/*! \brief Find a %SObject by its ID
- \param theObserver observer being attached
- \param modify when \c true, observer receives any object's modification events;
- otherwise observer receives object's creation events only
+ \param aObjectID This parameter defines the ID of the required object
+ \return The obtained %SObject
*/
- void attach(in SALOMEDS::Observer theObserver, in boolean modify);
-/*!
- Detach an observer from the Study
+ SObject FindObjectID (in ID aObjectID) raises(StudyInvalidReference);
+/*! \brief Create a %SObject by its ID
- \param theObserver observer to be detached
+ \param aObjectID This parameter defines the ID of the required object
+ \return The created %SObject
*/
- void detach(in SALOMEDS::Observer theObserver);
- };
-
- //==========================================================================
-/*! \brief %Study Builder Interface
+ SObject CreateObjectID (in ID aObjectID) raises(StudyInvalidReference);
+/*! \brief Find a %SObject by IOR of the object belonging to this %SObject.
- The purpose of the Builder is to add and/or remove objects and attributes.
- A %StudyBuilder is linked to a %Study. A
- command management is provided for the undo/redo functionalities.
- \note
-
The Tag of an item in %SALOME application is a symbolic description of
- item's position in the tree-type structure of the browser. In general it has the following
- form: 0:2:1:1
+ \param anObjectName This parameter defines the IOR of the object
+ \return The obtained %SObject
*/
- //==========================================================================
-
- interface StudyBuilder
- {
-/*! \brief %LockProtection Exception
+ SObject FindObjectIOR (in ID aObjectIOR) raises(StudyInvalidReference);
+/*! \brief Find in the study all %SObjects produced by a given %Component.
- This exception is raised while attempting to modify a locked %study.
+ \param anObjectName The Name Attribute of the searched %SObjects should correspond to anObjectName.
+ \param aComponentName The name of the component, which objects are searched for.
*/
- exception LockProtection {};
-/*! \brief Creation of a new %SComponent.
-
- Creates a new %SComponent
- \param ComponentDataType Data type of the %SComponent which will be created.
-
-See \ref example17 for an example of this method usage in batchmode of %SALOME application.
+ ListOfSObject FindObjectByName(in string anObjectName, in string aComponentName) raises(StudyInvalidReference);
+/*! \brief Find a %SObject by the path to it.
+ \param thePath The path to the required %SObject.
+ \return The obtained %SObject.
*/
- SComponent NewComponent(in string ComponentDataType) raises(LockProtection);
-/*! \brief Definition of the instance to the %SComponent
-
- Defines the instance to the %SComponent.
+ SObject FindObjectByPath(in string thePath) raises(StudyInvalidReference);
+/*! \brief Get the path to the %SObject.
*/
- void DefineComponentInstance (in SComponent aComponent,in Object ComponentIOR) raises(LockProtection);
+ string GetObjectPath(in Object theObject) raises(StudyInvalidReference);
-/*! \brief Deletion of a %SComponent
+/*! \brief Create a new iterator of child levels of the given %SObject.
- Removes a %SComponent.
+ \param aSO The given %SObject
+ \return A new iterator of child levels of the given %SObject.
*/
- void RemoveComponent(in SComponent aComponent) raises(LockProtection);
+ ChildIterator NewChildIterator(in SObject aSO) raises(StudyInvalidReference);
-/*! \brief Creation of a new %SObject
+/*! \brief Create a new iterator of the %SComponents.
- Creates a new %SObject under a definite father %SObject.
+ \return A new iterator of the %SComponents.
+*/
+ SComponentIterator NewComponentIterator() raises(StudyInvalidReference);
- \param theFatherObject The father %SObject under which this one should be created.
- \return New %SObject
+/*! \brief Create a new %StudyBuilder to add or modify an object in the study.
-See \ref example18 for an example of this method usage in batchmode of %SALOME application.
+ \return A new %StudyBuilder.
+See \ref example20 for an example of this method usage in batchmode of %SALOME application.
*/
+ StudyBuilder NewBuilder() raises(StudyInvalidReference);
+/*! \brief Labels dependency
- SObject NewObject (in SObject theFatherObject) raises(LockProtection);
+ Updates the map with IOR attribute. It's an inner method used for optimization.
+*/
+ void UpdateIORLabelMap(in string anIOR, in string anEntry) raises(StudyInvalidReference);
-/*! \brief Creation of a new %SObject with a definite %tag
+/*! \brief Getting properties of the study
- Creates a new %SObject with a definite %tag.
+ Returns the attribute, which contains the properties of this study.
- \param atag Long value corresponding to the tag of the new %SObject.
- \return New %SObject
+See \ref example20 for an example of this method usage in batchmode of %SALOME application.
*/
- SObject NewObjectToTag (in SObject theFatherObject, in long atag) raises(LockProtection);
-/*! \brief Deletion of the %SObject
-
- Removes a %SObject from the %StudyBuilder.
-
- \param anObject The %SObject to be deleted.
+ AttributeStudyProperties GetProperties() raises(StudyInvalidReference);
+/*! \brief Indicate whether the %study has been saved
*/
- void RemoveObject (in SObject anObject) raises(LockProtection);
-/*! \brief Deletion of the %SObject with all his child objects.
-
- Removes the %SObject with all his child objects.
+ attribute boolean IsSaved;
+/*! \brief Indicate whether the %study has been modified and not saved.
- \param anObject The %SObject to be deleted with all child objects.
+ Returns True if the %study has been modified and not saved.
*/
- void RemoveObjectWithChildren(in SObject anObject) raises(LockProtection);
-
-/*!
- Loads a %SComponent.
-
-See \ref example19 for an example of this method usage in batchmode of %SALOME application.
+ boolean IsModified() raises(StudyInvalidReference);
+/*! \brief Mark the %study as being modified and not saved.
*/
- void LoadWith (in SComponent sco, in Driver Engine) raises (SALOME::SALOME_Exception);
-/*!
- Loads a %SObject.
+ void Modified() raises(StudyInvalidReference);
- \param sco %SObject to be loaded.
+/*! \brief Indicate the file where the %study has been saved
*/
- void Load (in SObject sco);
-
-/*! \brief Looking for or creating an attribute assigned to the %SObject
+ attribute wstring URL;
- Allows to find or create an attribute of a specific type which is assigned to the object.
- \param anObject The %SObject corresponding to the attribute which is looked for.
- \param aTypeOfAttribute Type of the attribute.
+/*! \brief List of %SObjects
-See \ref example1 for an example of this method usage in batchmode of %SALOME application.
+ Returns the list of %SObjects which refers to %anObject.
*/
+ ListOfSObject FindDependances(in SObject anObject) raises(StudyInvalidReference);
- GenericAttribute FindOrCreateAttribute(in SObject anObject,
- in string aTypeOfAttribute) raises(LockProtection);
+/*! \brief The date of the last saving of the study
-/*! \brief Looking for an attribute assigned to a %SObject
+ Returns the date of the last saving of study with format: "DD/MM/YYYY HH:MM"
+*/
+ string GetLastModificationDate() raises(StudyInvalidReference);
+/*! \brief The list of modification dates of the study
- Allows to find an attribute of a specific type which is assigned to the object.
- \param anObject The %SObject corresponding to the attribute which is looked for.
- \param aTypeOfAttribute Type of the attribute.
- \param anAttribute Where the attribute is placed if it's found.
- \return True if it finds an attribute.
- */
+ Returns the list of modification dates (without creation date) with format "DD/MM/YYYY HH:MM".
+ Note : the first modification begins the list.
+*/
+ ListOfDates GetModificationsDate() raises(StudyInvalidReference);
+/*! \brief Object conversion.
- boolean FindAttribute(in SObject anObject,
- out GenericAttribute anAttribute,
- in string aTypeOfAttribute);
-/*! \brief Deleting the attribute assigned to the %SObject
+ Converts an object into IOR.
+ \return IOR
+*/
+ string ConvertObjectToIOR(in Object theObject);
+/*! \brief Object conversion.
- Removes the attribute of a specific type which is assigned to the object.
- \param anObject The %SObject corresponding to the attribute.
- \param aTypeOfAttribute Type of the attribute.
+ Converts IOR into an object.
+ \return An object
+*/
+ Object ConvertIORToObject(in string theIOR);
-See \ref example17 for an example of this method usage in batchmode of %SALOME application.
+/*! \brief Get a new %UseCaseBuilder.
*/
- void RemoveAttribute(in SObject anObject,
- in string aTypeOfAttribute) raises(LockProtection);
-/*!
- Adds a reference between %anObject and %theReferencedObject.
- \param anObject The %SObject which will get a reference
- \param theReferencedObject The %SObject having a reference
+ UseCaseBuilder GetUseCaseBuilder() raises(StudyInvalidReference);
+
+/*! \brief Clear a study object
*/
+ void Clear() raises(StudyInvalidReference);
- void Addreference(in SObject anObject,
- in SObject theReferencedObject) ;
-
-/*!
- Removes a reference from %anObject to another object.
- \param anObject The %SObject which contains a reference
+/*! \brief Initialization a study object
*/
+ void Init() raises(StudyInvalidReference);
+
+/*! \brief Open a study by url
- void RemoveReference(in SObject anObject) ;
-
-/*!
- Adds a directory in the %Study.
- \param theName String parameter defining the name of the directory.
-
-See \ref example23 for an example of this method usage in batchmode of %SALOME application.
-
+ Reads and activates the structure of the study %Objects.
+ \param aStudyUrl The path to the study
*/
- void AddDirectory(in string theName) raises(LockProtection);
-
-/*! \brief Identification of the %SObject's substructure.
+ boolean Open (in URLPath aStudyUrl) raises (SALOME::SALOME_Exception);
+
+/*! \brief Saving the study in a file (or files).
- Identification of the %SObject's substructure by GUID.
+ Saves a study.
+ \param theMultiFile If this parameter is True the study will be saved in several files.
+ \param theASCII If this parameter is True the study will be saved in ASCII format, otherwise in HDF format.
+*/
+ boolean Save(in boolean theMultiFile, in boolean theASCII) raises(StudyInvalidReference);
+
+/*! \brief Saving the study in a specified file (or files).
+ Saves the study in a specified file (or files).
+ \param aUrl The path to the definite file in whcih the study will be saved
+ \param theMultiFile If this parameter is True the study will be saved in several files.
+ \param theASCII If this parameter is True the study will be saved in ASCII format, otherwise in HDF format.
- \param anObject The %SObject which will be identified
- \param theGUID GUID has the following format "00000000-0000-0000-0000-000000000000"
+See \ref example1 for an example of this method usage in batchmode of %SALOME application.
*/
-
- void SetGUID(in SObject anObject, in string theGUID) raises(LockProtection);
+ boolean SaveAs(in URLPath aUrl, // if the file already exists
+ in boolean theMultiFile, // overwrite (as option)
+ in boolean theASCII)
+ raises(StudyInvalidReference);
/*!
-Searches for a definite %SObject with a definite GUID and returns True if it finds it.
-
-\param anObject A definite %SObject which will be identified
-\param theGUID GUID has the following format "00000000-0000-0000-0000-000000000000"
+ Returns True, if the given %SObject can be copied to the clipboard.
*/
- boolean IsGUID(in SObject anObject, in string theGUID);
-
-/*! \brief Creation of a new command
-
- Creates a new command which can contain several different actions.
-
-See \ref example3 for an example of this method usage in batchmode of %SALOME application.
-
+ boolean CanCopy(in SObject theObject) raises(StudyInvalidReference);
+/*!
+ Returns True, if the given %SObject is copied to the clipboard.
+ \param theObject The %SObject which will be copied
*/
- void NewCommand(); // command management
-/*! \brief Execution of the command
-
- Commits all actions declared within this command.
-
- \exception LockProtection This exception is raised, when trying to perform this command a study, which is protected for modifications.
-
-See \ref example16 for an example of this method usage in batchmode of %SALOME application.
-
+ boolean Copy(in SObject theObject) raises(StudyInvalidReference);
+/*!
+ Returns True, if the object from the clipboard can be pasted to the given %SObject.
+ \param theObject The %SObject stored in the clipboard.
*/
- void CommitCommand() raises(LockProtection); // command management
+ boolean CanPaste(in SObject theObject) raises(StudyInvalidReference);
/*!
- Returns True if at this moment there is a command under execution.
+ Returns the %SObject in which the object from the clipboard was pasted to.
+ \param theObject The %SObject which will be pasted
+ \exception SALOMEDS::StudyBuilder::LockProtection This exception is raised, when trying to paste
+ an object into a study, which is protected for modifications.
*/
- boolean HasOpenCommand();
-/*! \brief Cancellation of the command
-
- Cancels all actions declared within the command.
+ SObject Paste(in SObject theObject) raises (SALOMEDS::StudyBuilder::LockProtection);
-See \ref example17 for an example of this method usage in batchmode of %SALOME application.
+/*! \brief Enable (if isEnabled = True)/disable automatic addition of new %SObjects to the use case.
*/
- void AbortCommand(); // command management
-/*! \brief Undolimit
+ void EnableUseCaseAutoFilling(in boolean isEnabled) raises(StudyInvalidReference);
- The number of actions which can be undone
+/*!
+ Functions for internal usage only
*/
- attribute long UndoLimit;
-/*! \brief Undo method
+ void AddPostponed(in string theIOR) raises(StudyInvalidReference);
- Cancels all actions of the last command.
+ void AddCreatedPostponed(in string theIOR) raises(StudyInvalidReference);
- \exception LockProtection This exception is raised, when trying to perform this command a study, which is protected for modifications.
+ void RemovePostponed(in long theUndoLimit) raises(StudyInvalidReference);
-See \ref example16 for an example of this method usage in batchmode of %SALOME application.
+ void UndoPostponed(in long theWay) raises(StudyInvalidReference);
-*/
- void Undo() raises (LockProtection);
-/*! \brief Redo method
+ boolean DumpStudy(in string thePath,
+ in string theBaseName,
+ in boolean isPublished,
+ in boolean isMultiFile) raises(StudyInvalidReference);
- Redoes all actions of the last command.
+/*! \brief Get an AttributeParameter used to store common parameters for given %theSavePoint.
-\exception LockProtection This exception is raised, when trying to perform this command a study, which is protected for modifications.
+ \param theID identifies a common parameters set (Example: "Interface Applicative")
+ \param theSavePoint is number of a set of parameters as there can be several sets
+*/
+ AttributeParameter GetCommonParameters(in string theID, in long theSavePoint) raises(StudyInvalidReference);
-See \ref example16 for an example of this method usage in batchmode of %SALOME application.
+/*! \brief Get an AttributeParameter used to store parameters for given %theModuleName.
+ \param theID identifies a common parameters set (Example: "Interface Applicative")
+ \param theModuleName is a name of the module (Example: "Geometry")
+ \param theSavePoint is number of a set of parameters as there can be several sets
*/
- void Redo() raises (LockProtection);
-/*!
- Returns True if at this moment there are any actions which can be canceled.
+ AttributeParameter GetModuleParameters(in string theID, in string theModuleName, in long theSavePoint) raises(StudyInvalidReference);
-See \ref example16 for an example of this method usage in batchmode of %SALOME application.
+/*! \brief Get a default Python script to restore visual parameters for given %theModuleName.
+
+ \param theModuleName is a name of the module (Example: "Geometry")
+ \param indent is a string to use for script indentation
*/
- boolean GetAvailableUndos();
+ string GetDefaultScript(in string theModuleName, in string indent) raises(StudyInvalidReference);
+
/*!
- Returns True if at this moment there are any actions which can be redone.
+ Private method, returns an implementation of this Study.
+ \param theHostname is a hostname of the caller
+ \param thePID is a process ID of the caller
+ \param isLocal is set True if the Study is launched locally with the caller
+*/
+ long long GetLocalImpl(in string theHostname, in long thePID, out boolean isLocal);
-See \ref example3 for an example of this method usage in batchmode of %SALOME application.
-*/
- boolean GetAvailableRedos();
-/*!
- Puts name attribute with the given string value to the given %SObject
+/*! \brief Mark this Study as being locked by the given locker.
- \param theSO Existing SObject to set name attribute.
- \param theValue The value to be set to the name attribute.
+ The lock status can be checked by method IsStudyLocked
+ \param theLockerID identifies a locker of the study can be for ex. IOR of the engine that locks the study.
*/
- void SetName(in SObject theSO, in string theValue) raises (LockProtection);
+ void SetStudyLock(in string theLockerID) raises(StudyInvalidReference);
-/*!
- Puts comment attribute with the given string value to the given %SObject
+/*! \brief Indicate if the Study is locked
- \param theSO Existing SObject to set comment attribute.
- \param theValue The value to be set to the comment attribute.
+ Returns True if the Study was marked locked.
*/
- void SetComment(in SObject theSO, in string theValue) raises (LockProtection);
+ boolean IsStudyLocked() raises(StudyInvalidReference);
-/*!
- Puts IOR attribute with the given string value to the given %SObject
+/*! \brief Mark this Study as being unlocked by the given locker.
- \param theSO Existing SObject to set IOR attribute.
- \param theValue The value to be set to the IOR attribute.
+ The lock status can be checked by method IsStudyLocked
+ \param theLockerID identifies a locker of the study can be for ex. IOR of the engine that unlocks the study.
*/
- void SetIOR(in SObject theSO, in string theValue) raises (LockProtection);
- };
-
- //==========================================================================
-/*! \brief %Study Manager interface
+ void UnLockStudy(in string theLockerID) raises(StudyInvalidReference);
- The purpose of the Manager is to manipulate the %Studies. You will find in this
- interface the methods to create, open,
- close, and save a %Study. Since a %SALOME session is multi-document, you will
- also find the methods allowing to navigate
- through the collection of studies present in a session.
+/*! \brief Get the list of IDs of the Study's lockers.
*/
- //==========================================================================
+ ListOfStrings GetLockerID() raises(StudyInvalidReference);
- interface StudyManager
- {
-/*!
- Determines whether the server has already been loaded or not.
+/*! \brief Create real variable with Name theVarName and value theValue
+
+ (or set if variable value into theValue already exists)
+ \param theVarName is a name of the variable
+ \param theVarName is a value of the variable.
*/
- void ping();
+ void SetReal( in string theVarName, in double theValue ) raises(StudyInvalidReference);
- void Shutdown();
+/*! \brief Create integer variable with Name theVarName and value theValue
-/*!
- Returns the PID of the server
+ (or set if variable value into theValue already exists)
+ \param theVarName is a name of the variable
+ \param theVarName is a value of the variable.
*/
- long getPID();
+ void SetInteger( in string theVarName, in long theValue ) raises(StudyInvalidReference);
+/*! \brief Create boolean variable with Name theVarName and value theValue
-/*!
- Shutdown the StudyManager process.
+ (or set if variable value into theValue already exists)
+ \param theVarName is a name of the variable
+ \param theVarName is a value of the variable.
*/
- oneway void ShutdownWithExit();
+ void SetBoolean( in string theVarName, in boolean theValue ) raises(StudyInvalidReference);
-/*! \brief Creation of a new study
+/*! \brief Create string variable with Name theVarName and value theValue
- Creates a new study with a definite name.
+ (or set if variable value into theValue already exists)
+ \param theVarName is a name of the variable
+ \param theVarName is a value of the variable.
+*/
+ void SetString( in string theVarName, in string theValue ) raises(StudyInvalidReference);
- \param study_name String parameter defining the name of the study
+/*! \brief Set current value as double for string variable
+*/
+ void SetStringAsDouble( in string theVarName, in double theValue ) raises(StudyInvalidReference);
-See \ref example17 for an example of this method usage in batchmode of %SALOME application.
+/*! \brief Get value of a real variable
+ \param theVarName is a name of the variable.
*/
- Study NewStudy(in string study_name) raises (SALOME::SALOME_Exception);
-
-/*! \brief Open a study
+ double GetReal( in string theVarName ) raises(StudyInvalidReference);
- Reads and activates the structure of the study %Objects.
- \param aStudyUrl The path to the study
- \warning This method doesn't activate the corba objects. Only a component can do it.
+/*! \brief Get value of an integer variable
-See \ref example1 for an example of this method usage in batchmode of %SALOME application.
+ \param theVarName is a name of the variable.
*/
- Study Open (in URL aStudyUrl) raises (SALOME::SALOME_Exception);
+ long GetInteger( in string theVarName ) raises(StudyInvalidReference);
-/*! \brief Closing the study
+/*! \brief Get value of a boolean variable
- Closes a study.
+ \param theVarName is a name of the variable.
*/
- void Close(in Study aStudy);
-/*! \brief Saving the study in a HDF file (or files).
+ boolean GetBoolean( in string theVarName ) raises(StudyInvalidReference);
- Saves a study.
+/*! \brief Get value of a string variable
- \param theMultiFile If this parameter is True the study will be saved in several files.
+ \param theVarName is a name of the variable.
+*/
+ string GetString( in string theVarName ) raises(StudyInvalidReference);
-See \ref example19 for an example of this method usage in batchmode of %SALOME application.
-*/
- boolean Save(in Study aStudy, in boolean theMultiFile);
-/*! \brief Saving a study in a ASCII file (or files).
+/*! \brief Indicate if a variable is real
- Saves a study in an ASCII format file (or files).
- \param theMultiFile If this parameter is True the study will be saved in several files.
+ Return true if variable is real otherwise return false.
+ \param theVarName is a name of the variable.
*/
- boolean SaveASCII(in Study aStudy, in boolean theMultiFile);
-/*! \brief Saving the study in a specified HDF file (or files).
+ boolean IsReal( in string theVarName ) raises(StudyInvalidReference);
- Saves the study in a specified file (or files).
- \param aUrl The path to the definite file in which the study will be saved
- \param aStudy The study which will be saved
- \param theMultiFile If this parameter is True the study will be saved in several files.
+/*! \brief Indicate if a variable is integer
-See \ref example1 for an example of this method usage in batchmode of %SALOME application.
+ Return true if variable is integer otherwise return false.
+ \param theVarName is a name of the variable.
*/
- boolean SaveAs(in URL aUrl, // if the file already exists
- in Study aStudy,
- in boolean theMultiFile); // overwrite (as option)
-/*! \brief Saving the study in a specified ASCII file (or files).
+ boolean IsInteger( in string theVarName ) raises(StudyInvalidReference);
- Saves the study in a specified ASCII file (or files).
+/*! \brief Indicate if a variable is boolean
- \param aUrl The path to the definite file in which the study will be saved
- \param aStudy The study which will be saved
- \param theMultiFile If this parameter is True the study will be saved in several files.
+ Return true if variable is boolean otherwise return false.
+ \param theVarName is a name of the variable.
*/
- boolean SaveAsASCII(in URL aUrl, // if the file already exists
- in Study aStudy,
- in boolean theMultiFile); // overwrite (as option)
+ boolean IsBoolean( in string theVarName ) raises(StudyInvalidReference);
+/*! \brief Indicate if a variable is string
-/*! \brief List of open studies.
+ Return true if variable is string otherwise return false.
+ \param theVarName is a name of the variable.
+*/
+ boolean IsString( in string theVarName ) raises(StudyInvalidReference);
-Gets the list of open studies
+/*! \brief Indicate if a variable exists in the study
- \return A list of open studies in the current session.
+ Return true if variable exists in the study,
+ otherwise return false.
+ \param theVarName is a name of the variable.
*/
- ListOfOpenStudies GetOpenStudies();
-
-/*! \brief Getting a particular %Study picked by name
+ boolean IsVariable( in string theVarName ) raises(StudyInvalidReference);
- Activates a particular %Study
- among the session collection picking it by name.
- \param aStudyName The name of the study
+/*! \brief Get names of all variables from the study.
*/
- Study GetStudyByName (in string aStudyName);
+ ListOfStrings GetVariableNames() raises(StudyInvalidReference);
-/*! \brief Getting a particular %Study picked by ID
+/*! \brief Remove a variable
+
+ Remove variable with the specified name from the study with substitution of its value.
- Activates a particular %Study
- among the session collection picking it by ID.
- \param aStudyID The ID of the study
+ \param theVarName Name of the variable.
+ \return Status of operation.
*/
- Study GetStudyByID (in short aStudyID);
+ boolean RemoveVariable( in string theVarName ) raises(StudyInvalidReference);
- // copy/paste methods
+/*! \brief Rename a variable
-/*!
- Returns True, if the given %SObject can be copied to the clipboard.
-*/
- boolean CanCopy(in SObject theObject);
-/*!
- Returns True, if the given %SObject is copied to the clipboard.
- \param theObject The %SObject which will be copied
-*/
- boolean Copy(in SObject theObject);
-/*!
- Returns True, if the object from the clipboard can be pasted to the given %SObject.
- \param theObject The %SObject stored in the clipboard.
-*/
- boolean CanPaste(in SObject theObject);
-/*!
- Returns the %SObject in which the object from the clipboard was pasted to.
- \param theObject The %SObject which will be pasted
- \exception SALOMEDS::StudyBuilder::LockProtection This exception is raised, when trying to paste
- an object into a study, which is protected for modifications.
+ Rename variable with the specified name within the study.
+
+ \param theVarName Name of the variable.
+ \param theNewVarName New name for the variable.
+ \return Status of operation.
*/
- SObject Paste(in SObject theObject) raises (SALOMEDS::StudyBuilder::LockProtection);
+ boolean RenameVariable( in string theVarName, in string theNewVarName ) raises(StudyInvalidReference);
-/*! \brief Object conversion.
+/*! \brief Indicate whether variable is used
- Converts an object into IOR.
- \return IOR
+ Check that variable is used in the study.
+
+ \param theVarName Name of the variable.
+ \return Variable usage.
*/
- string ConvertObjectToIOR(in Object theObject);
-/*! \brief Object conversion.
+ boolean IsVariableUsed( in string theVarName ) raises(StudyInvalidReference);
- Converts IOR into an object.
- \return An object
+/*! \brief Parse variables used for object creation
+
+ \param string with variables, separated by special symbol.
+ \return Variables list.
*/
- Object ConvertIORToObject(in string theIOR);
+ ListOfListOfStrings ParseVariables( in string theVars ) raises(StudyInvalidReference);
/*!
- Private method, returns an implementation of this StudyManager.
- \param theHostname is a hostname of the caller
- \param thePID is a process ID of the caller
- \param isLocal is set True if the StudyManager is launched locally with the caller
+ Attach an observer to the Study
+
+ \param theObserver observer being attached
+ \param modify when \c true, observer receives any object's modification events;
+ otherwise observer receives object's creation events only
*/
- long long GetLocalImpl(in string theHostname, in long thePID, out boolean isLocal);
+ void attach(in SALOMEDS::Observer theObserver, in boolean modify);
+/*!
+ Detach an observer from the Study
+ \param theObserver observer to be detached
+*/
+ void detach(in SALOMEDS::Observer theObserver);
};
-
//==========================================================================
/*! \brief %SObject interface
@@@ -1215,8 -1374,8 +1215,8 @@@ This class represents a common tool fo
can be called by any component and which provide the following functionality:
- publishing in the study of the objects created by a definite component
-
- saving/loading of the data created by a definite component. These methods are called by the StudyManager when loading/saving a study containing the data created by a definite component.
+
- saving/loading of the data created by a definite component. These methods are called when loading/saving a study containing the data created by a definite component.
-
- transforming of the transient references into persistant references (or vice versa) of the SObjects when saving (or loading) a study
+
- transforming of the transient references into persistent references (or vice versa) of the SObjects when saving (or loading) a study
- copy/paste common functionality. These methods can be called by any component in order to copy/paste its object created in the study
diff --cc idl/SALOME_Component.idl
index ff1e97141,930835584..805e09d26
--- a/idl/SALOME_Component.idl
+++ b/idl/SALOME_Component.idl
@@@ -99,8 -102,10 +99,8 @@@ module Engine
This simply loads the service in the current container by importing the
corresponding Python module.
Warning: no internal registration is done, so it is up to the caller to
- manage the various instanciation.
+ manage the various instantiation.
\param serviceName Name of the service
-
- >0 otherwise (== study id)
\param reason in case of error (return void string) a string explaining the error
\return the IOR of the loaded service.
*/
diff --cc src/HDFPersist/HDFfile.cc
index d372e460c,3f5e0e1a1..da3eeaa7e
--- a/src/HDFPersist/HDFfile.cc
+++ b/src/HDFPersist/HDFfile.cc
@@@ -58,36 -58,29 +58,36 @@@ void HDFfile::CreateOnDisk(
void HDFfile::OpenOnDisk(hdf_access_mode access_mode)
{
- _access_mode = access_mode;
+ _access_mode = access_mode;
+ std::string msgerr;
- switch (_access_mode)
- {
- case HDF_RDWR :
- if (access(_name,F_OK))
+ switch (_access_mode)
{
- if ((_id = HDFfileCreate(_name)) < 0)
- throw HDFexception("Can't open HDF file");
+ case HDF_RDWR:
+ if (access(_name, F_OK))
+ {
+ if ((_id = HDFfileCreate(_name)) < 0) {
+ msgerr = "Can't create HDF in RW mode file" + std::string(_name);
+ throw HDFexception(msgerr.c_str());
+ }
+ }
+ else if ((_id = HDFfileOpen(_name, _access_mode)) < 0) {
+ msgerr = "Can't open HDF in RW mode file " + std::string(_name);
+ throw HDFexception(msgerr.c_str());
+ }
+ break;
+
+ case HDF_RDONLY:
+ if ((_id = HDFfileOpen(_name, _access_mode)) < 0) {
+ msgerr = "Can't open HDF in RO mode file " + std::string(_name);
+ throw HDFexception(msgerr.c_str());
+ }
+ break;
+
+ default:
- msgerr = "Can't open HDF file " + std::string(_name) + " : bad acces option";
++ msgerr = "Can't open HDF file " + std::string(_name) + " : bad access option";
+ throw HDFexception(msgerr.c_str());
}
- else
- if ((_id = HDFfileOpen(_name,_access_mode)) < 0)
- throw HDFexception("Can't open HDF file");
- break;
-
- case HDF_RDONLY :
- if ((_id = HDFfileOpen(_name,_access_mode)) < 0)
- throw HDFexception("Can't open HDF file");
- break;
-
- default :
- throw HDFexception("Can't open HDF file : bad access option");
- }
}
void HDFfile::CloseOnDisk()
diff --cc src/KERNEL_PY/__init__.py
index 79fb951df,ce4a8d46e..08c13f38d
--- a/src/KERNEL_PY/__init__.py
+++ b/src/KERNEL_PY/__init__.py
@@@ -195,14 -229,14 +195,14 @@@ def salome_init(embedded=0)
import time
time.sleep(0.2)
x = inst
- print "salome.salome_init():", x
- print """
+ print("salome.salome_init():", x)
+ print("""
============================================
May be there is no running SALOME session
- salome.salome_init() is intented to be used
+ salome.salome_init() is intended to be used
within an already running session
============================================
- """
+ """)
raise
def salome_close():
diff --cc src/KERNEL_PY/kernel/testdata.py
index ffbb0dcc9,76485786f..4c671abd8
--- a/src/KERNEL_PY/kernel/testdata.py
+++ b/src/KERNEL_PY/kernel/testdata.py
@@@ -133,10 -133,10 +133,10 @@@ def TEST_useBadRange()
def TEST_serialize():
import salome.kernel
ref_testdata = TestData()
- ref_testdata.setName("The firts name")
+ ref_testdata.setName("The first name")
res_testdata = salome.kernel.unserialize(salome.kernel.serialize(ref_testdata))
- print res_testdata.getName()
+ print(res_testdata.getName())
if res_testdata.getName() != ref_testdata.getName():
return False
diff --cc src/KERNEL_PY/kernel/unittester.py
index dc447b6f1,1a0001b98..9abb4fa4c
--- a/src/KERNEL_PY/kernel/unittester.py
+++ b/src/KERNEL_PY/kernel/unittester.py
@@@ -45,30 -45,30 +45,30 @@@ def run(modulePath, functionName)
module=sys.modules[moduleName]
func = getattr(module,functionName)
tabsize = 70-len(moduleName)-len(functionName)
- print "[TEST] %s.%s %s test in progress" % (moduleName, functionName,"."*tabsize)
+ print("[TEST] %s.%s %s test in progress" % (moduleName, functionName,"."*tabsize))
ok = func()
if ( ok ):
- print "[TEST] %s.%s %s OK" % (moduleName, functionName,"."*tabsize)
+ print("[TEST] %s.%s %s OK" % (moduleName, functionName,"."*tabsize))
else:
- print "[TEST] %s.%s %s NOT OK" % (moduleName, functionName,"."*tabsize)
+ print("[TEST] %s.%s %s NOT OK" % (moduleName, functionName,"."*tabsize))
## This function is for debug only. It executes the specified function with the
- # specified arguments in a try/except bloc so that to display the exception in
- # the case where an exception is raised (usefull to debug server side of a CORBA
+ # specified arguments in a try/except block so as to display the exception in
+ # the case where an exception is raised (useful to debug server side of a CORBA
# process).
# \ingroup unittester
def tryfunction(function,*argv):
"""
This function is for debug only. It executes the specified function with the
- specified arguments in a try/except bloc so that to display the exception in
- the case where an exception is raised (usefull to debug server side of a CORBA
+ specified arguments in a try/except block so as to display the exception in
+ the case where an exception is raised (useful to debug server side of a CORBA
process).
"""
- print "[TEST] trying the function %s" % function
+ print("[TEST] trying the function %s" % function)
try:
return function(*argv)
- except Exception, e:
- print e
+ except Exception as e:
+ print(e)
raise e
diff --cc src/KERNEL_PY/omnipatch.py
index 29dd1e4f8,963b1e3cb..d39c60469
--- a/src/KERNEL_PY/omnipatch.py
+++ b/src/KERNEL_PY/omnipatch.py
@@@ -117,10 -117,10 +117,10 @@@ def newModule(mname)
# partial module map
def updateModule(mname):
# Salome modification start
- # Be sure to use the right module dictionnary
+ # Be sure to use the right module dictionary
import sys
# Salome modification end
- if _partialModules.has_key(mname):
+ if mname in _partialModules:
pmod = _partialModules[mname]
mod = sys.modules[mname]
mod.__dict__.update(pmod.__dict__)
diff --cc src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx
index 773f16e5f,5947c4030..e0814bab1
--- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx
+++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx
@@@ -59,50 -54,6 +59,50 @@@
#define FILEID "FILE: "
#define VARIABLE_SEPARATOR ':'
#define OPERATION_SEPARATOR '|'
+#define USE_CASE_LABEL_ID "0:2"
+
+static void SaveAttributes(const SALOMEDSImpl_SObject& SO, HDFgroup *hdf_group_sobject);
+static void ReadAttributes(SALOMEDSImpl_Study*, const SALOMEDSImpl_SObject&, HDFdataset* );
+static void BuildTree (SALOMEDSImpl_Study*, HDFgroup*);
+static void Translate_IOR_to_persistentID (const SALOMEDSImpl_SObject&,
+ SALOMEDSImpl_Driver*, bool isMultiFile, bool isASCII);
+static void ReadNoteBookVariables(SALOMEDSImpl_Study* theStudy, HDFgroup* theGroup);
+
+namespace {
+ class StudyUnlocker
+ {
+ public:
+ StudyUnlocker( SALOMEDSImpl_Study* study ): myStudy( study ), myLocked( false )
+ {
+ myPrevLocked = myStudy->GetProperties()->IsLocked();
+ resume();
+ }
+ ~StudyUnlocker()
+ {
+ suspend();
+ }
+ void suspend()
+ {
+ if (myLocked) {
- myStudy->GetProperties()->SetLocked(true);
- myPrevLocked = myLocked;
- myLocked = false;
++ myStudy->GetProperties()->SetLocked(true);
++ myPrevLocked = myLocked;
++ myLocked = false;
+ }
+ }
+ void resume()
+ {
+ if (myPrevLocked) {
- myStudy->GetProperties()->SetLocked(false);
- myLocked = myPrevLocked;
- myPrevLocked = false;
++ myStudy->GetProperties()->SetLocked(false);
++ myLocked = myPrevLocked;
++ myPrevLocked = false;
+ }
+ }
+ private:
+ SALOMEDSImpl_Study* myStudy;
+ bool myLocked;
+ bool myPrevLocked;
+ };
+}
//============================================================================
/*! Function : SALOMEDSImpl_Study
@@@ -336,861 -129,14 +336,865 @@@ bool SALOMEDSImpl_Study::Impl_SavePrope
{
_errorCode = "";
+ HDFdataset *hdf_dataset = 0;
+ hdf_size size[1];
+ hdf_int32 name_len;
+
+ // add modifications list (user and date of save)
SALOMEDSImpl_AttributeStudyProperties* aProp = GetProperties();
- int aLocked = aProp->IsLocked();
- if (aLocked) aProp->SetLocked(false);
- // Assign the value of the IOR in the study->root
- SALOMEDSImpl_AttributeIOR::Set(_doc->Main().Root(), theIOR);
+ // unlock study if it is locked, to set modification date
+ StudyUnlocker unlock(this);
+
+ int month=0,day=0,year=0,hh=0,mn=0,ss=0;
+ SALOMEDSImpl_Tool::GetSystemDate(year, month, day, hh, mn, ss);
+ aProp->SetModification(SALOMEDSImpl_Tool::GetUserName(),
- mn, hh, day, month, year);
++ mn, hh, day, month, year);
+
+ // lock study back if it was locked initially, to write correct value of Locked flag
+ unlock.suspend();
+
+ std::vector aNames;
+ std::vector aMinutes, aHours, aDays, aMonths, aYears;
+
+ aProp->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears);
+
+ std::string units = aProp->GetUnits();
+ std::string comment = aProp->GetComment();
+
+ std::map< std::string, std::vector > allVersions = aProp->GetComponentsVersions();
+ std::map versions;
+
+ int aLength = 0, aLength1 = 0, anIndex, i, unitsSize = 0, commentSize = 0;
+
+ for(i=1; i<=aNames.size(); i++)
+ aLength += aNames[i-1].size() + 1;
+
+ std::map< std::string, std::vector >::const_iterator it;
+ for (it = allVersions.begin(); it != allVersions.end(); ++it ) {
+ std::string vlist = "";
+ std::vector vl = it->second;
+ std::vector::const_iterator vlit;
+ for ( vlit = vl.begin(); vlit != vl.end(); ++vlit ) {
+ if ( vlist != "" ) vlist += ";";
+ vlist += *vlit;
+ }
+ versions[ it->first ] = vlist;
+ aLength1 += it->first.size() + vlist.size() + 2;
+ }
+
+ unitsSize = units.size();
+ commentSize = comment.size();
+
+ //string format:
+ //locked flag, modified flag,
+ //minutes, hours, day, months, year, user name, char(1),
+ //minutes, hours, day, months, year, user name, char(1),
+ //.....................................................,
+ //.....................................................,
+ //.....................................................,
+ //minutes, hours, day, months, year, user name, char(1), char(30) <- !!!! used to define end of section with modifications !!!!
+ //units, char(1), comment, char(30) <- !!!! used to define start of section with components' versions !!!!
+ //component=versions, char(1),
+ //component=versions, char(1),
+ //...........................,
+ //component=versions, char(1), char(0)
+
- //string length: 1 byte = locked flag, 1 byte = modified flag, (12 + name length + 1) for each name and date, 1 byte (char(30) section delimeter)
++ //string length: 1 byte = locked flag, 1 byte = modified flag, (12 + name length + 1) for each name and date, 1 byte (char(30) section delimiter)
+ // unit length + 1, comment length, "zero" byte
+
+ char* aProperty = new char[3 + aLength + 12 * aNames.size() + 1 + unitsSize + 1 + commentSize + 1 + aLength1 ];
+
+ sprintf(aProperty,"%c%c", (char)aProp->GetCreationMode(), (aProp->IsLocked())?'l':'u');
+
+ aLength = aNames.size();
+ int a = 2;
+ for(anIndex = 0; anIndex 0) {
+ sprintf(&(aProperty[a]),"%s",units.c_str());
+ a = strlen(aProperty);
+ }
+
+ aProperty[a++] = 1;
+
+ //Write comments if need
+ if(comment.size() > 0) {
+ sprintf(&(aProperty[a]),"%s",comment.c_str());
+ a = strlen(aProperty);
+ }
+
- aProperty[a++] = 30; //delimeter of the component versions
++ aProperty[a++] = 30; //delimiter of the component versions
+
+ std::map::const_iterator versionsIt;
+ for ( versionsIt = versions.begin(); versionsIt != versions.end(); ++versionsIt ) {
+ sprintf(&(aProperty[a]),"%s=%s",
+ (char*)(versionsIt->first.c_str()),
- (char*)(versionsIt->second.c_str()));
++ (char*)(versionsIt->second.c_str()));
+ a = a + versionsIt->first.size() + versionsIt->second.size() + 1;
+ aProperty[a++] = 1;
+ }
+
+ aProperty[a] = 0;
+
+ name_len = (hdf_int32) a;
+ size[0] = name_len + 1 ;
+ hdf_dataset = new HDFdataset("AttributeStudyProperties",hdf_group,HDF_STRING,size,1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk(aProperty);
+ hdf_dataset->CloseOnDisk();
+ hdf_dataset=0; //will be deleted by hdf_sco_group destructor
+ delete [] aProperty;
+
+ aProp->SetModified(0);
+ return true;
+}
+
+//=============================================================================
+/*! Function : _SaveAs
+ * Purpose : save the study in HDF file
+ */
+//============================================================================
+bool SALOMEDSImpl_Study::Impl_SaveAs(const std::string& aStudyUrl,
+ SALOMEDSImpl_DriverFactory* aFactory,
+ bool theMultiFile,
+ bool theASCII)
+{
+ // Set "C" locale temporarily to avoid possible localization problems
+ Kernel_Utils::Localizer loc;
+
+ // HDF File will be composed of differents part :
+ // * For each ComponentDataType, all data created by the component
- // Informations in data group hdf_group_datacomponent
++ // Information in data group hdf_group_datacomponent
+ // * Study Structure -> Exactly what is contained in Document
- // Informations in data group hdf_group_study_structure
++ // Information in data group hdf_group_study_structure
+
+ _errorCode = "";
+
+ HDFfile *hdf_file=0;
+ HDFgroup *hdf_group_study_structure =0;
+ HDFgroup *hdf_sco_group =0;
+ HDFgroup *hdf_sco_group2 =0;
+ HDFgroup *hdf_notebook_vars =0;
+ HDFgroup *hdf_notebook_var = 0;
+
+ HDFgroup *hdf_group_datacomponent =0;
+ HDFdataset *hdf_dataset =0;
+ hdf_size size[1];
+ hdf_int32 name_len = 0;
+ std::string component_name;
+
+ // Store previous URL
+ std::string anOldName = URL();
+
+ // Map to store components' versions
+ std::map componentVersions;
+
+ //Create a temporary url to which the study is saved
+ std::string aUrl = SALOMEDSImpl_Tool::GetTmpDir() + SALOMEDSImpl_Tool::GetNameFromPath(aStudyUrl);
+
+ // unlock study if it is locked, as some attributes need to be modified
+ StudyUnlocker unlock(this);
+
+ SALOMEDSImpl_StudyBuilder* SB= NewBuilder();
+ std::map aMapTypeDriver;
+
+ try {
+ // mpv 15.12.2003: for saving components we have to load all data from all modules
+ SALOMEDSImpl_SComponentIterator itcomponent = NewComponentIterator();
+ for (; itcomponent.More(); itcomponent.Next()) {
+ SALOMEDSImpl_SComponent sco = itcomponent.Value();
+ // if there is an associated Engine call its method for saving
+ std::string IOREngine;
+ try {
+ SALOMEDSImpl_Driver* aDriver = NULL;
+ std::string aCompType = sco.GetComment();
+ if (!sco.ComponentIOR(IOREngine)) {
+ if (!aCompType.empty()) {
+ aDriver = aFactory->GetDriverByType(aCompType);
+ if (aDriver != NULL) {
+ if (!SB->LoadWith(sco, aDriver)) {
+ _errorCode = SB->GetErrorCode();
+ return false;
+ }
+ }
+ }
+ }
- else {
- aDriver = aFactory->GetDriverByIOR(IOREngine);
- }
- aMapTypeDriver[aCompType] = aDriver;
++ else {
++ aDriver = aFactory->GetDriverByIOR(IOREngine);
++ }
++ aMapTypeDriver[aCompType] = aDriver;
+ }
+ catch(...) {
+ _errorCode = "Can not restore information to resave it";
+ return false;
+ }
+ }
+
+ // VSR: set URL to new file name
+ // VSR: remember to set previous name if save operation fails
+ URL(aStudyUrl);
+
+ // To change for Save
- // Do not have to do a new file but just a Open??? Rewrite all informations after erasing evrything??
++ // Do not have to do a new file but just a Open??? Rewrite all information after erasing evrything??
+ hdf_file = new HDFfile((char*)aUrl.c_str());
+ hdf_file->CreateOnDisk();
+
+ //-----------------------------------------------------------------------
+ // 1 - Create a groupe for each SComponent and Update the PersistanceRef
+ //-----------------------------------------------------------------------
+ hdf_group_datacomponent = new HDFgroup("DATACOMPONENT",hdf_file);
+ hdf_group_datacomponent->CreateOnDisk();
+
+ for (itcomponent.Init(); itcomponent.More(); itcomponent.Next()) {
+ SALOMEDSImpl_SComponent sco = itcomponent.Value();
+
+ std::string scoid = sco.GetID();
+ hdf_sco_group = new HDFgroup((char*)scoid.c_str(), hdf_group_datacomponent);
+ hdf_sco_group->CreateOnDisk();
+
+ std::string componentDataType = sco.ComponentDataType();
+ std::string IOREngine;
+ if (sco.ComponentIOR(IOREngine)) {
- // Engine should be already in the map as it was to added before
- SALOMEDSImpl_Driver* Engine = aMapTypeDriver[componentDataType];
++ // Engine should be already in the map as it was to added before
++ SALOMEDSImpl_Driver* Engine = aMapTypeDriver[componentDataType];
+ if (Engine != NULL) {
+ SALOMEDSImpl_TMPFile* aStream = NULL;
+ long length = 0;
+
+ componentVersions[ componentDataType ] = Engine->Version();
+
+ if (theASCII) aStream = Engine->SaveASCII(sco,
+ SALOMEDSImpl_Tool::GetDirFromPath(aUrl),
+ length,
+ theMultiFile);
+ else aStream = Engine->Save(sco,
+ SALOMEDSImpl_Tool::GetDirFromPath(aUrl),
+ length,
+ theMultiFile);
+ HDFdataset *hdf_dataset;
+ hdf_size aHDFSize[1];
+ if (length > 0) { //The component saved some auxiliary files, then put them into HDF file
+ aHDFSize[0] = length;
+
+ HDFdataset *hdf_dataset = new HDFdataset("FILE_STREAM", hdf_sco_group, HDF_STRING, aHDFSize, 1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk(aStream->Data()); //Save the stream in the HDF file
+ hdf_dataset->CloseOnDisk();
+ }
+
+ if (aStream) delete aStream;
+
+ // store multifile state
+ aHDFSize[0] = 2;
+ hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((void*)(theMultiFile?"M":"S")); // save: multi or single
+ hdf_dataset->CloseOnDisk();
+ hdf_dataset=0; //will be deleted by hdf_sco_AuxFiles destructor
+ // store ASCII state
+ aHDFSize[0] = 2;
+ hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((void*)(theASCII?"A":"B")); // save: ASCII or BINARY
+ hdf_dataset->CloseOnDisk();
+ hdf_dataset=0; //will be deleted by hdf_sco_AuxFiles destructor
- // Creation of the persistance reference attribute
++ // Creation of the persistence reference attribute
+ Translate_IOR_to_persistentID (sco, Engine, theMultiFile, theASCII);
+ }
+ }
+ hdf_sco_group->CloseOnDisk();
+ hdf_sco_group=0; // will be deleted by hdf_group_datacomponent destructor
+ }
+ hdf_group_datacomponent->CloseOnDisk();
+ hdf_group_datacomponent =0; // will be deleted by hdf_file destructor
+
+ //-----------------------------------------------------------------------
+ //3 - Write the Study Structure
+ //-----------------------------------------------------------------------
+ hdf_group_study_structure = new HDFgroup("STUDY_STRUCTURE",hdf_file);
+ hdf_group_study_structure->CreateOnDisk();
+ // save component attributes
+ for (itcomponent.Init(); itcomponent.More(); itcomponent.Next()) {
+ SALOMEDSImpl_SComponent SC = itcomponent.Value();
+ std::string scid = SC.GetID();
+ hdf_sco_group2 = new HDFgroup((char*)scid.c_str(), hdf_group_study_structure);
+ hdf_sco_group2->CreateOnDisk();
+ SaveAttributes(SC, hdf_sco_group2);
+ // ComponentDataType treatment
+ component_name = SC.ComponentDataType();
+ name_len = (hdf_int32)component_name.length();
+ size[0] = name_len +1 ;
+ hdf_dataset = new HDFdataset("COMPONENTDATATYPE",hdf_sco_group2,HDF_STRING,size,1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((char*)component_name.c_str());
+ hdf_dataset->CloseOnDisk();
+ hdf_dataset=0; //will be deleted by hdf_sco_group destructor
+ Impl_SaveObject(SC, hdf_sco_group2);
+ hdf_sco_group2->CloseOnDisk();
+ hdf_sco_group2=0; // will be deleted by hdf_group_study_structure destructor
+ }
+ //-----------------------------------------------------------------------
+ //4 - Write the Study UseCases Structure
+ //-----------------------------------------------------------------------
+ SALOMEDSImpl_SObject aSO = FindObjectID(USE_CASE_LABEL_ID);
+ if (aSO) {
+ HDFgroup *hdf_soo_group = new HDFgroup(USE_CASE_LABEL_ID,hdf_group_study_structure);
+ hdf_soo_group->CreateOnDisk();
+ SaveAttributes(aSO, hdf_soo_group);
+ Impl_SaveObject(aSO, hdf_soo_group);
+ hdf_soo_group->CloseOnDisk();
+ hdf_soo_group=0; // will be deleted by hdf_group_study_structure destructor
+ }
+ //-----------------------------------------------------------------------
+ //5 - Write the NoteBook Variables
+ //-----------------------------------------------------------------------
+
+ //5.1 Create group to store all note book variables
+ hdf_notebook_vars = new HDFgroup("NOTEBOOK_VARIABLES",hdf_file);
+ hdf_notebook_vars->CreateOnDisk();
+
+ std::string varValue;
+ std::string varType;
+ std::string varIndex;
+
+ for (int i=0 ;i < myNoteBookVars.size(); i++ ) {
+ // For each variable create HDF group
+ hdf_notebook_var = new HDFgroup((char*)myNoteBookVars[i]->Name().c_str(),hdf_notebook_vars);
+ hdf_notebook_var->CreateOnDisk();
+
+ // Save Variable type
+ varType = myNoteBookVars[i]->SaveType();
+ name_len = (hdf_int32) varType.length();
+ size[0] = name_len +1 ;
+ hdf_dataset = new HDFdataset("VARIABLE_TYPE",hdf_notebook_var,HDF_STRING,size,1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((char*)varType.c_str());
+ hdf_dataset->CloseOnDisk();
+ hdf_dataset=0; //will be deleted by hdf_sco_group destructor
+
+ char buffer[256];
+ sprintf(buffer,"%d",i);
+ varIndex= std::string(buffer);
+ name_len = (hdf_int32) varIndex.length();
+ size[0] = name_len +1 ;
+ hdf_dataset = new HDFdataset("VARIABLE_INDEX",hdf_notebook_var,HDF_STRING,size,1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((char*)varIndex.c_str());
+ hdf_dataset->CloseOnDisk();
+ hdf_dataset=0; //will be deleted by hdf_sco_group destructor
+
+ // Save Variable value
+ varValue = myNoteBookVars[i]->Save();
+ name_len = (hdf_int32) varValue.length();
+ size[0] = name_len +1 ;
+ hdf_dataset = new HDFdataset("VARIABLE_VALUE",hdf_notebook_var,HDF_STRING,size,1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((char*)varValue.c_str());
+ hdf_dataset->CloseOnDisk();
+ hdf_dataset=0; //will be deleted by hdf_sco_group destructor
+ hdf_notebook_var->CloseOnDisk();
+ hdf_notebook_var = 0; //will be deleted by hdf_sco_group destructor
+ }
+ hdf_notebook_vars->CloseOnDisk();
+ hdf_notebook_vars = 0; //will be deleted by hdf_sco_group destructor
+
+ // record component versions
+ std::map::const_iterator itVersions;
+ for ( itVersions = componentVersions.begin(); itVersions != componentVersions.end(); ++itVersions )
+ GetProperties()->SetComponentVersion( itVersions->first, itVersions->second );
+
+ // lock study back if it was locked initially, to write correct value of Locked flag
+ unlock.suspend();
+
+ //-----------------------------------------------------------------------
+ //6 - Write the Study Properties
+ //-----------------------------------------------------------------------
+ std::string study_name = Name();
+ name_len = (hdf_int32) study_name.size();
+ size[0] = name_len +1 ;
+ hdf_dataset = new HDFdataset("STUDY_NAME",hdf_group_study_structure,HDF_STRING,size,1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((char*)study_name.c_str());
+ hdf_dataset->CloseOnDisk();
+ hdf_dataset=0; // will be deleted by hdf_group_study_structure destructor
+
+ Impl_SaveProperties(hdf_group_study_structure);
+ hdf_group_study_structure->CloseOnDisk();
+ hdf_file->CloseOnDisk();
+
+ hdf_group_study_structure =0; // will be deleted by hdf_file destructor
+ delete hdf_file; // recursively deletes all hdf objects...
+ }
+ catch (HDFexception) {
+ _errorCode = "HDFexception ! ";
+ URL( anOldName ); // VSR: restore previous url if operation is failed
+ return false;
+ }
+ catch (std::exception& exc) {
+ _errorCode = const_cast(exc.what());
+ URL( anOldName ); // VSR: restore previous url if operation is failed
+ return false;
+ }
+ catch (...) {
+ _errorCode = "Unknown exception ! ";
+ URL( anOldName ); // VSR: restore previous url if operation is failed
+ return false;
+ }
+ if (theASCII) { // save file in ASCII format
+ HDFascii::ConvertFromHDFToASCII(aUrl.c_str(), true);
+ }
+
+ // Now it's necessary to copy files from the temporary directory to the user defined directory.
+ // The easiest way to get a list of file in the temporary directory
+
+ std::string aCmd, aTmpFileDir = SALOMEDSImpl_Tool::GetTmpDir();
+ std::string aTmpFile = aTmpFileDir +"files";
+ std::string aStudyTmpDir = SALOMEDSImpl_Tool::GetDirFromPath(aUrl);
+
+#ifdef WIN32
+ aCmd = "dir /B \"" + aStudyTmpDir +"\" > " + aTmpFile;
+#else
+ aCmd ="ls -1 \"" + aStudyTmpDir +"\" > " + aTmpFile;
+#endif
+ system(aCmd.c_str());
+
+ // Iterate and move files in the temporary directory
+ FILE* fp = fopen(aTmpFile.c_str(), "rb");
+ if (!fp) {
+ URL( anOldName ); // VSR: restore previous url if operation is failed
+ return false;
+ }
+ char* buffer = new char[2047];
+ int errors = 0;
+ while (!feof(fp) && !errors) {
+ if ((fgets(buffer, 2046, fp)) == NULL) break;
+ size_t aLen = strlen(buffer);
+ if (buffer[aLen-1] == '\n') buffer[aLen-1] = char(0);
+#ifdef WIN32
+ aCmd = "move /Y \"" + aStudyTmpDir + std::string(buffer) + "\" \"" + SALOMEDSImpl_Tool::GetDirFromPath(aStudyUrl) +"\"";
+#else
+ aCmd = "mv -f \"" + aStudyTmpDir + std::string(buffer) + "\" \"" + SALOMEDSImpl_Tool::GetDirFromPath(aStudyUrl)+"\"";
+#endif
+ errors = system(aCmd.c_str());
+ }
+
+ delete []buffer;
+ fclose(fp);
+
+ // Perform cleanup
+#ifdef WIN32
+ DeleteFileA(aTmpFile.c_str());
+#else
+ unlink(aTmpFile.c_str());
+#endif
+
+#ifdef WIN32
+ RemoveDirectoryA(aTmpFileDir.c_str());
+ RemoveDirectoryA(aStudyTmpDir.c_str());
+#else
+ rmdir(aTmpFileDir.c_str());
+ rmdir(aStudyTmpDir.c_str());
+#endif
+
+ if ( !errors ) {
+ // VSR: finally, if all is done without errors, mark study as Saved
+ IsSaved(true);
+ }
+
++ std::map::iterator n2dr = aMapTypeDriver.begin();
++ for ( ; n2dr != aMapTypeDriver.end(); ++n2dr )
++ delete n2dr->second;
++
+ return !errors;
+}
+
+//============================================================================
+/*! Function : Impl_SaveObject
+ * Purpose :
+ */
+//============================================================================
+bool SALOMEDSImpl_Study::Impl_SaveObject(const SALOMEDSImpl_SObject& SC,
+ HDFgroup *hdf_group_datatype)
+{
+ _errorCode = "";
+
- // Write in group hdf_group_datatype all informations of SObject SC
++ // Write in group hdf_group_datatype all information of SObject SC
+ // Iterative function to parse all SObjects under a SComponent
+
+ HDFgroup *hdf_group_sobject = 0;
+
+ DF_ChildIterator itchild(SC.GetLabel());
+ for (; itchild.More(); itchild.Next()) {
+ // mpv: don't save empty labels
+ std::vector attr = itchild.Value().GetAttributes();
+ if (attr.size() == 0) { //No attributes on the label
+ DF_ChildIterator subchild(itchild.Value());
+ if (!subchild.More()) {
+ continue;
+ }
+ subchild.Init(itchild.Value(), true);
+ bool anEmpty = true;
+ for (; subchild.More() && anEmpty; subchild.Next()) {
+ std::vector attr2 = subchild.Value().GetAttributes();
+ if (attr2.size()) {
+ anEmpty = false; //There are attributes on the child label
+ break;
+ }
+ }
+ if (anEmpty) continue;
+ }
+
+ SALOMEDSImpl_SObject SO = SALOMEDSImpl_Study::SObject(itchild.Value());
+
+ std::string scoid = SO.GetID();
+ hdf_group_sobject = new HDFgroup(scoid.c_str(), hdf_group_datatype);
+ hdf_group_sobject->CreateOnDisk();
+ SaveAttributes(SO, hdf_group_sobject);
+ Impl_SaveObject(SO, hdf_group_sobject);
+ hdf_group_sobject->CloseOnDisk();
+ hdf_group_sobject =0; // will be deleted by father hdf object destructor
+ }
+ return true;
+}
+
+//============================================================================
+/*! Function : CanCopy
+ * Purpose :
+ */
+//============================================================================
+bool SALOMEDSImpl_Study::CanCopy(const SALOMEDSImpl_SObject& theObject,
+ SALOMEDSImpl_Driver* theEngine)
+{
+ _errorCode = "";
+ SALOMEDSImpl_SComponent aComponent = theObject.GetFatherComponent();
+ if (!aComponent) return false;
+ if (aComponent.GetLabel() == theObject.GetLabel()) return false;
+ std::string IOREngine;
+ if (!aComponent.ComponentIOR(IOREngine)) return false;
+ if (theEngine == NULL) return false;
+ return theEngine->CanCopy(theObject);
+}
+
+//============================================================================
+/*! Function : CopyLabel
+ * Purpose :
+ */
+//============================================================================
+bool SALOMEDSImpl_Study::CopyLabel(SALOMEDSImpl_Driver* theEngine,
+ const int theSourceStartDepth,
+ const DF_Label& theSource,
+ const DF_Label& theDestinationMain)
+{
+ _errorCode = "";
+
+ int a;
+ DF_Label aTargetLabel = theDestinationMain;
+ DF_Label aAuxTargetLabel = theDestinationMain.Father().FindChild(2);
+ for(a = theSource.Depth() - theSourceStartDepth; a > 0 ; a--) {
+ DF_Label aSourceLabel = theSource;
+ for(int aNbFather = 1; aNbFather < a; aNbFather++) aSourceLabel = aSourceLabel.Father();
+ aTargetLabel = aTargetLabel.FindChild(aSourceLabel.Tag());
+ aAuxTargetLabel = aAuxTargetLabel.FindChild(aSourceLabel.Tag());
+ }
+ // iterate attributes
+ std::vector attrList = theSource.GetAttributes();
+ for(int i = 0, len = attrList.size(); i(anAttr)->Get();
+ std::string anEntry = aReferenced.Entry();
+ // store the value of name attribute of referenced label
+ SALOMEDSImpl_AttributeName* aNameAttribute;
+ if ((aNameAttribute=(SALOMEDSImpl_AttributeName*)aReferenced.FindAttribute(SALOMEDSImpl_AttributeName::GetID()))) {
+ anEntry += " ";
+ anEntry += aNameAttribute->Value();
+ }
+ SALOMEDSImpl_AttributeComment::Set(aAuxTargetLabel, anEntry);
+ continue;
+ }
+
+ if (type == std::string("AttributeIOR")) { // IOR => ID and TMPFile of Engine
+ std::string anEntry = theSource.Entry();
+ SALOMEDSImpl_SObject aSO = FindObjectID(anEntry);
+ int anObjID;
+ long aLen;
+ SALOMEDSImpl_TMPFile* aStream = theEngine->CopyFrom(aSO, anObjID, aLen);
+ std::string aResStr("");
+ for(a = 0; a < aLen; a++) {
+ aResStr += (char)(aStream->Get(a));
+ }
+
+ if(aStream) delete aStream;
+
+ SALOMEDSImpl_AttributeInteger::Set(aAuxTargetLabel, anObjID);
+ SALOMEDSImpl_AttributeName::Set(aAuxTargetLabel, aResStr);
+ continue;
+ }
+ DF_Attribute* aNewAttribute = anAttr->NewEmpty();
+ aTargetLabel.AddAttribute(aNewAttribute);
+ anAttr->Paste(aNewAttribute);
+ }
+
+ return true;
+}
+
+//============================================================================
+/*! Function : Copy
+ * Purpose :
+ */
+//============================================================================
+bool SALOMEDSImpl_Study::Copy(const SALOMEDSImpl_SObject& theObject,
+ SALOMEDSImpl_Driver* theEngine)
+{
+ _errorCode = "";
+
+ // adoptation for alliances datamodel copy: without IOR attributes !!!
+ bool aStructureOnly; // copy only SObjects and attributes without component help
+ aStructureOnly = !theObject.GetLabel().IsAttribute(SALOMEDSImpl_AttributeIOR::GetID());
+
+ if (!_doc) {
+ _errorCode = "Document is null";
+ return false;
+ }
+
+ //Clear the clipboard
+ _clipboard->Main().Root().ForgetAllAttributes(true);
+ _appli->Close(_clipboard);
+ _clipboard = _appli->NewDocument("SALOME_STUDY");
+
+ // set component data type to the name attribute of root label
+ if (!aStructureOnly) {
+ SALOMEDSImpl_AttributeComment::Set(_clipboard->Main().Root(),
+ theEngine->ComponentDataType());
+ }
+ // iterate all theObject's label children
+ DF_Label aStartLabel = theObject.GetLabel();
+ int aSourceStartDepth = aStartLabel.Depth();
+
+ // copy main source label
+ CopyLabel(theEngine, aSourceStartDepth, aStartLabel, _clipboard->Main());
+
+ // copy all subchildren of the main source label (all levels)
+ DF_ChildIterator anIterator(aStartLabel, true);
+ for(; anIterator.More(); anIterator.Next()) {
+ CopyLabel(theEngine, aSourceStartDepth, anIterator.Value(), _clipboard->Main());
+ }
+
+ return true;
+}
+
+//============================================================================
+/*! Function : CanPaste
+ * Purpose :
+ */
+//============================================================================
+bool SALOMEDSImpl_Study::CanPaste(const SALOMEDSImpl_SObject& theObject,
+ SALOMEDSImpl_Driver* theEngine)
+{
+ _errorCode = "";
+
+ if (!_clipboard) {
+ _errorCode = "Clipboard is null";
+ return false;
+ }
+
+ SALOMEDSImpl_AttributeComment* aCompName = NULL;
+ if (!(aCompName=(SALOMEDSImpl_AttributeComment*)_clipboard->Main().Root().FindAttribute(SALOMEDSImpl_AttributeComment::GetID()))) {
+ _errorCode = "Clipboard has no component type";
+ return false;
+ }
+ SALOMEDSImpl_AttributeInteger* anObjID;
+ if (!(anObjID=(SALOMEDSImpl_AttributeInteger*)_clipboard->Main().Father().FindChild(2).FindAttribute(SALOMEDSImpl_AttributeInteger::GetID()))) {
+ _errorCode = "Clipboard has no object id";
+ return false;
+ }
+ SALOMEDSImpl_SComponent aComponent = theObject.GetFatherComponent();
+ if (!aComponent) {
+ _errorCode = "Object doesn't belong to component";
+ return false;
+ }
+
+ std::string IOREngine;
+ if (!aComponent.ComponentIOR(IOREngine)) {
+ _errorCode = "component has no IOR";
+ return false;
+ }
+ return theEngine->CanPaste(aCompName->Value(), anObjID->Value());
+}
+
+//============================================================================
+/*! Function : PasteLabel
+ * Purpose :
+ */
+//============================================================================
+DF_Label SALOMEDSImpl_Study::PasteLabel(SALOMEDSImpl_Driver* theEngine,
+ const DF_Label& theSource,
+ const DF_Label& theDestinationStart,
+ const bool isFirstElement)
+{
+ _errorCode = "";
+
+ // get corresponding source, target and auxiliary labels
+ DF_Label aTargetLabel = theDestinationStart;
+
+ DF_Label aAuxSourceLabel = theSource.Root().FindChild(2);
+ int a;
+ if (!isFirstElement) {
+ for(a = theSource.Depth() - 1; a > 0 ; a--) {
+ DF_Label aSourceLabel = theSource;
+ for(int aNbFather = 1; aNbFather < a; aNbFather++) aSourceLabel = aSourceLabel.Father();
+ aTargetLabel = aTargetLabel.FindChild(aSourceLabel.Tag());
+ aAuxSourceLabel = aAuxSourceLabel.FindChild(aSourceLabel.Tag());
+ }
+ SALOMEDSImpl_SObject so = GetSObject(aTargetLabel);
+ addSO_Notification(so);
+ }
+
+ // check auxiliary label for TMPFile => IOR
+ SALOMEDSImpl_AttributeName* aNameAttribute = NULL;
+ if ((aNameAttribute=(SALOMEDSImpl_AttributeName*)aAuxSourceLabel.FindAttribute(SALOMEDSImpl_AttributeName::GetID()))) {
+ SALOMEDSImpl_AttributeInteger* anObjID = (SALOMEDSImpl_AttributeInteger*)aAuxSourceLabel.FindAttribute(SALOMEDSImpl_AttributeInteger::GetID());
+ SALOMEDSImpl_AttributeComment* aComponentName = (SALOMEDSImpl_AttributeComment*)theSource.Root().FindAttribute(SALOMEDSImpl_AttributeComment::GetID());
+ std::string aCompName = aComponentName->Value();
+
+ if (theEngine->CanPaste(aCompName, anObjID->Value())) {
+ std::string aTMPStr = aNameAttribute->Value();
+ int aLen = aTMPStr.size();
+ unsigned char* aStream = NULL;
+ if(aLen > 0) {
+ aStream = new unsigned char[aLen+10];
+ for(a = 0; a < aLen; a++) {
+ aStream[a] = aTMPStr[a];
+ }
+ }
+
+ std::string anEntry = aTargetLabel.Entry();
+ SALOMEDSImpl_SObject aPastedSO = FindObjectID(anEntry);
+
+ if (isFirstElement) {
+ std::string aDestEntry = theEngine->PasteInto(aStream,
+ aLen,
+ anObjID->Value(),
+ aPastedSO.GetFatherComponent());
+ aTargetLabel = DF_Label::Label(theDestinationStart, aDestEntry);
+ } else
+ theEngine->PasteInto(aStream, aLen, anObjID->Value(), aPastedSO);
+
+ if(aStream != NULL) delete []aStream;
+ }
+ }
+
+ // iterate attributes
+ std::vector attrList = theSource.GetAttributes();
+ for(int i = 0, len = attrList.size(); iID())) {
+ aTargetLabel.ForgetAttribute(anAttr->ID());
+ }
+ DF_Attribute* aNewAttribute = anAttr->NewEmpty();
+ aTargetLabel.AddAttribute(aNewAttribute);
+ anAttr->Paste(aNewAttribute);
+ }
+
+ // check auxiliary label for Comment => reference or name attribute of the referenced object
+ SALOMEDSImpl_AttributeComment* aCommentAttribute = NULL;
+ if ((aCommentAttribute=(SALOMEDSImpl_AttributeComment*)aAuxSourceLabel.FindAttribute(SALOMEDSImpl_AttributeComment::GetID()))) {
+ char * anEntry = new char[aCommentAttribute->Value().size() + 1];
+ strcpy(anEntry, std::string(aCommentAttribute->Value()).c_str());
+ char* aNameStart = strchr(anEntry, ' ');
+ if (aNameStart) {
+ *aNameStart = '\0';
+ aNameStart++;
+ }
+ // copy to the same study, reanimate reference
+ DF_Label aRefLabel = DF_Label::Label(aTargetLabel, anEntry);
+ SALOMEDSImpl_AttributeReference::Set(aTargetLabel, aRefLabel);
+ // target attributes structure support
+ SALOMEDSImpl_AttributeTarget::Set(aRefLabel)->Add(SALOMEDSImpl_Study::SObject(aTargetLabel));
+
+ delete [] anEntry;
+ }
+
+ return aTargetLabel;
+}
+
+//============================================================================
+/*! Function : Paste
+ * Purpose :
+ */
+//============================================================================
+SALOMEDSImpl_SObject SALOMEDSImpl_Study::Paste(const SALOMEDSImpl_SObject& theObject,
+ SALOMEDSImpl_Driver* theEngine)
+{
+ _errorCode = "";
+
+ SALOMEDSImpl_SObject so;
+
+ // if study is locked, then paste can't be done
+ if (GetProperties()->IsLocked()) {
+ _errorCode = "LockProtection";
+ throw LockProtection("LockProtection");
+ }
+
+ // if there is no component name, then paste only SObjects and attributes: without component help
+ SALOMEDSImpl_AttributeComment* aComponentName = NULL;
+ bool aStructureOnly = !(aComponentName=(SALOMEDSImpl_AttributeComment*)_clipboard->Main().Root().FindAttribute(SALOMEDSImpl_AttributeComment::GetID()));
+
+ // CAF document of current study usage
+ if (!_doc) {
+ _errorCode = "Document is null";
+ return so;
+ }
+
+ SALOMEDSImpl_SComponent aComponent = theObject.GetFatherComponent();
+
+ // fill root inserted SObject
+ DF_Label aStartLabel;
+ if (aStructureOnly) {
+ DF_Label anObjectLabel = DF_Label::Label(_doc->Main(), theObject.GetID());
+ aStartLabel = PasteLabel(theEngine, _clipboard->Main(), anObjectLabel, false);
+ } else {
+ DF_Label aComponentLabel = DF_Label::Label(_doc->Main(), aComponent.GetID());
+ aStartLabel = PasteLabel(theEngine, _clipboard->Main(), aComponentLabel, true);
+ }
+
+ // paste all sublebels
+ DF_ChildIterator anIterator(_clipboard->Main(), true);
+ for(; anIterator.More(); anIterator.Next()) {
+ PasteLabel(theEngine, anIterator.Value(), aStartLabel, false);
+ }
+
+ return SALOMEDSImpl_Study::SObject(aStartLabel);
+}
- if (aLocked) aProp->SetLocked(true);
+//============================================================================
+/*! Function : GetPersistentReference
+ * Purpose : Get persistent reference of study (idem URL())
+ */
+//============================================================================
+std::string SALOMEDSImpl_Study::GetPersistentReference()
+{
+ _errorCode = "";
+ return URL();
}
//============================================================================
@@@ -2979,213 -2165,3 +2983,213 @@@ void SALOMEDSImpl_Study::UnRegisterGenO
if ( SALOMEDSImpl_AbstractCallback* goRegister = getGenObjRegister( label.GetDocument() ))
goRegister->UnRegisterGenObj( theIOR );
}
+
+//#######################################################################################################
+//# STATIC PRIVATE FUNCTIONS
+//#######################################################################################################
+
+//============================================================================
+/*! Function : SaveAttributes
+ * Purpose : Save attributes for object
+ */
+//============================================================================
+static void SaveAttributes(const SALOMEDSImpl_SObject& aSO, HDFgroup *hdf_group_sobject)
+{
+ hdf_size size[1];
+ std::vector attrList = aSO.GetLabel().GetAttributes();
+ DF_Attribute* anAttr = NULL;
+ for(int i = 0, len = attrList.size(); iSave();
+ //cout << "Saving: " << aSO.GetID() << " type: "<< type<<"|" << endl;
+ size[0] = (hdf_int32) strlen(aSaveStr.c_str()) + 1;
+ HDFdataset *hdf_dataset = new HDFdataset((char*)type.c_str(), hdf_group_sobject, HDF_STRING,size, 1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((char*)aSaveStr.c_str());
+ hdf_dataset->CloseOnDisk();
+ hdf_dataset=0; //will be deleted by hdf_sco_group destructor
+ }
+}
+
+//===========================================================================
+//Function : ReadAttributes
+//===========================================================================
+static void ReadAttributes(SALOMEDSImpl_Study* theStudy,
+ const SALOMEDSImpl_SObject& aSO,
+ HDFdataset* hdf_dataset)
+{
+ hdf_dataset->OpenOnDisk();
+
+ DF_Attribute* anAttr = NULL;
+ char* current_string = new char[hdf_dataset->GetSize()+1];
+ hdf_dataset->ReadFromDisk(current_string);
+ //cout << "Reading attr type = " << hdf_dataset->GetName() << " SO = " << aSO.GetID() << endl;
+ if (!strcmp(hdf_dataset->GetName(),"COMPONENTDATATYPE")) {
+ anAttr = theStudy->NewBuilder()->FindOrCreateAttribute(aSO, "AttributeComment");
+ }
+ else if (!strcmp(hdf_dataset->GetName(),"AttributeReference") ||
- !strcmp(hdf_dataset->GetName(),"Reference")) { // Old format maintainance
++ !strcmp(hdf_dataset->GetName(),"Reference")) { // Old format maintenance
+ theStudy->NewBuilder()->Addreference(aSO, theStudy->CreateObjectID(current_string));
+ delete [] (current_string);
+ hdf_dataset->CloseOnDisk();
+ return;
+ }
+ else {
+ anAttr = theStudy->NewBuilder()->FindOrCreateAttribute(aSO, hdf_dataset->GetName());
+ }
+
+ if (anAttr) {
+ anAttr->Load(current_string);
+ }
+
+ delete [] (current_string);
+ hdf_dataset->CloseOnDisk();
+}
+
+//============================================================================
+//Function : BuildlTree
+//============================================================================
+static void BuildTree (SALOMEDSImpl_Study* theStudy, HDFgroup* hdf_current_group)
+{
+ hdf_current_group->OpenOnDisk();
+ SALOMEDSImpl_SObject aSO;
+ char* Entry = hdf_current_group->GetName();
+ if (strcmp(Entry,"STUDY_STRUCTURE") == 0) {
+ aSO = theStudy->CreateObjectID("0:1");
+ }
+ else {
+ aSO = theStudy->CreateObjectID(Entry);
+ }
+
+ char name[HDF_NAME_MAX_LEN+1];
+ int nbsons = hdf_current_group->nInternalObjects();
+ for (int i=0; iInternalObjectIndentify(i,name);
+ if (strncmp(name, "INTERNAL_COMPLEX",16) == 0) continue;
+ hdf_object_type type = hdf_current_group->InternalObjectType(name);
+
+ if (type == HDF_DATASET) {
+ HDFdataset* new_dataset = new HDFdataset(name,hdf_current_group);
+ ReadAttributes(theStudy,aSO,new_dataset);
+ new_dataset = 0; // will be deleted by father destructor
+ }
+ else if (type == HDF_GROUP) {
+ HDFgroup* new_group = new HDFgroup(name,hdf_current_group);
+ BuildTree (theStudy, new_group);
+ new_group = 0; // will be deleted by father destructor
+ }
+ }
+ hdf_current_group->CloseOnDisk();
+}
+
+
+//============================================================================
+//Function : Translate_IOR_to_persistentID
+//============================================================================
+static void Translate_IOR_to_persistentID (const SALOMEDSImpl_SObject& so,
+ SALOMEDSImpl_Driver* engine,
+ bool isMultiFile,
+ bool isASCII)
+{
+ DF_ChildIterator itchild(so.GetLabel());
+ std::string ior_string, persistent_string, curid;
+
+ for (; itchild.More(); itchild.Next()) {
+ SALOMEDSImpl_SObject current = SALOMEDSImpl_Study::SObject(itchild.Value());
+ SALOMEDSImpl_AttributeIOR* IOR = NULL;
+ if ((IOR=(SALOMEDSImpl_AttributeIOR*)current.GetLabel().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))) {
+ ior_string = IOR->Value();
+
+ persistent_string = engine->IORToLocalPersistentID (current, ior_string, isMultiFile, isASCII);
+ SALOMEDSImpl_AttributePersistentRef::Set(current.GetLabel(), persistent_string);
+ }
+ Translate_IOR_to_persistentID (current, engine, isMultiFile, isASCII);
+ }
+}
+
+void ReadNoteBookVariables(SALOMEDSImpl_Study* theStudy, HDFgroup* theGroup)
+{
+ if(!theGroup)
+ return;
+
+ HDFgroup* new_group =0;
+ HDFdataset* new_dataset =0;
+
+ char aVarName[HDF_NAME_MAX_LEN+1];
+ char *currentVarType = 0;
+ char *currentVarValue = 0;
+ char *currentVarIndex = 0;
+ int order = 0;
+ //Open HDF group with notebook variables
+ theGroup->OpenOnDisk();
+
+ //Get Nb of variables
+ int aNbVars = theGroup->nInternalObjects();
+
+ std::map aVarsMap;
+
+ for( int iVar=0;iVar < aNbVars;iVar++ ) {
+ theGroup->InternalObjectIndentify(iVar,aVarName);
+ hdf_object_type type = theGroup->InternalObjectType(aVarName);
+ if(type == HDF_GROUP) {
+
+ //Read Variable
+ new_group = new HDFgroup(aVarName,theGroup);
+ new_group->OpenOnDisk();
+
+ //Read Type
+ new_dataset = new HDFdataset("VARIABLE_TYPE",new_group);
+ new_dataset->OpenOnDisk();
+ currentVarType = new char[new_dataset->GetSize()+1];
+ new_dataset->ReadFromDisk(currentVarType);
+ new_dataset->CloseOnDisk();
+ new_dataset = 0; //will be deleted by hdf_sco_group destructor
+
+ //Read Order
+ if(new_group->ExistInternalObject("VARIABLE_INDEX")) {
+ new_dataset = new HDFdataset("VARIABLE_INDEX",new_group);
+ new_dataset->OpenOnDisk();
+ currentVarIndex = new char[new_dataset->GetSize()+1];
+ new_dataset->ReadFromDisk(currentVarIndex);
+ new_dataset->CloseOnDisk();
+ new_dataset = 0; //will be deleted by hdf_sco_group destructor
+ order = atoi(currentVarIndex);
+ delete [] currentVarIndex;
+ }
+ else
+ order = iVar;
+
+ //Read Value
+ new_dataset = new HDFdataset("VARIABLE_VALUE",new_group);
+ new_dataset->OpenOnDisk();
+ currentVarValue = new char[new_dataset->GetSize()+1];
+ new_dataset->ReadFromDisk(currentVarValue);
+ new_dataset->CloseOnDisk();
+ new_dataset = 0; //will be deleted by hdf_sco_group destructor
+
+ new_group->CloseOnDisk();
+ new_group = 0; //will be deleted by hdf_sco_group destructor
+
+ SALOMEDSImpl_GenericVariable::VariableTypes aVarType =
+ SALOMEDSImpl_GenericVariable::String2VariableType(std::string(currentVarType));
+ delete [] currentVarType;
+
+ //Create variable and add it in the study
+ SALOMEDSImpl_GenericVariable* aVariable =
+ new SALOMEDSImpl_ScalarVariable(aVarType,std::string(aVarName));
+ aVariable->Load(std::string(currentVarValue));
+ aVarsMap.insert(std::make_pair(order,aVariable));
+ delete [] currentVarValue;
+ }
+ }
+
+ std::map::const_iterator it= aVarsMap.begin();
+ for(;it!=aVarsMap.end();it++)
+ theStudy->AddVariable((*it).second);
+
+ theGroup->CloseOnDisk();
+}
+
diff --cc src/SALOMESDS/TestSalomeSDS.py
index e00a5ed77,338953335..67bc42b2b
--- a/src/SALOMESDS/TestSalomeSDS.py
+++ b/src/SALOMESDS/TestSalomeSDS.py
@@@ -23,15 -23,18 +23,18 @@@ import SalomeSDSCl
import SALOME
import salome
import unittest
-import cPickle
+import pickle
import gc
import time
+ from datetime import datetime
import multiprocessing as mp
+ nbOfSecWait=1.
+
def obj2Str(obj):
- return cPickle.dumps(obj,cPickle.HIGHEST_PROTOCOL)
+ return pickle.dumps(obj,pickle.HIGHEST_PROTOCOL)
def str2Obj(strr):
- return cPickle.loads(strr)
+ return pickle.loads(strr)
def generateKey(varName,scopeName):
dsm=salome.naming_service.Resolve("/DataServerManager")
dss,isCreated=dsm.giveADataScopeTransactionCalled(scopeName)
@@@ -48,13 -51,41 +51,41 @@@ def work(t)
import TestSalomeSDSHelper0
import os,subprocess
fname=os.path.splitext(TestSalomeSDSHelper0.__file__)[0]+".py"
- proc=subprocess.Popen(["python",fname],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
+ proc = subprocess.Popen(["python3", fname], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out,err=proc.communicate()
if proc.returncode!=0:
- print out
- print err
+ print(out)
+ print(err)
return proc.returncode
-
+
+ def func_test7(scopeName,l,l2,cv):
+ salome.salome_init()
+ varName="a"
+ zeValue={"ab":[4,5,6]}
+ dsm=salome.naming_service.Resolve("/DataServerManager")
+ dss,isCreated=dsm.giveADataScopeTransactionCalled(scopeName) # should be suspended nbOfSecWait s by main process
+ assert(not isCreated)
+ l.release() # tell manager that I'm ready
+ l2.acquire() # wait for manager to start micro-test1
+ ######### micro-test1 - check that all requests are suspended
+ s=datetime.now()
+ t0=dss.createRdWrVarTransac(varName,obj2Str(zeValue))
+ s=(datetime.now()-s).total_seconds()
+ assert(s>=0.99*nbOfSecWait and s=0. and s<0.05) # expect to be not locked
+ ######### end of micro-test2
+ with cv:
+ cv.notify_all()
+ dss.takeANap(nbOfSecWait) # emulate a DataServer occupation
+ pass
+
class SalomeSDSTest(unittest.TestCase):
def testList1(self):