Version: 9.16.0
SALOMEDSImpl_Study.hxx
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, OPEN CASCADE
2//
3// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5//
6// This library is free software; you can redistribute it and/or
7// modify it under the terms of the GNU Lesser General Public
8// License as published by the Free Software Foundation; either
9// version 2.1 of the License, or (at your option) any later version.
10//
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14// Lesser General Public License for more details.
15//
16// You should have received a copy of the GNU Lesser General Public
17// License along with this library; if not, write to the Free Software
18// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19//
20// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21//
22
23// File : SALOMEDSImpl_Study.hxx
24// Author : Sergey RUIN
25// Module : SALOME
26//
27#ifndef __SALOMEDSIMPL_STUDY_I_H__
28#define __SALOMEDSIMPL_STUDY_I_H__
29
30// std C++ headers
31#include <iostream>
32#include <string>
33#include <vector>
34#include <map>
35
36#include "DF_Document.hxx"
37#include "DF_Label.hxx"
38#include <stdio.h>
39
40//SALOMEDSImpl headers
53
54class HDFgroup;
56
57
59{
60private:
61 std::string _name;
63 DF_Document* _doc; // Document
65 bool _Saved; // True if the Study is saved
66 std::string _URL; //URL of the persistent reference of the study
67 bool _autoFill;
68 std::string _errorCode;
69 std::vector<std::string> _lockers;
75 std::string _dumpPath; // path (folder) to the python file which is currently dumped
76
77 std::map<std::string, SALOMEDSImpl_SObject> _mapOfSO;
78 std::map<std::string, SALOMEDSImpl_SComponent> _mapOfSCO;
79 std::map<std::string, DF_Label> myIORLabels;
80 std::vector<SALOMEDSImpl_GenericVariable*> myNoteBookVars;
81
83 const std::string& anObjectName,
84 bool& _find);
85
86 SALOMEDSImpl_SObject _FindObjectIOR(const SALOMEDSImpl_SObject& SO,
87 const std::string& anObjectIOR,
88 bool& _find);
89
90 std::string _GetStudyVariablesScript();
91 std::string _GetNoteBookAccessor();
92 std::string _GetNoteBookAccess();
93
94public:
95
96 static SALOMEDSImpl_Study* GetStudyImpl(const DF_Label& theLabel);
97 static SALOMEDSImpl_SObject SObject(const DF_Label& theLabel);
98 static SALOMEDSImpl_SComponent SComponent(const DF_Label& theLabel);
99 static void IORUpdated(const SALOMEDSImpl_AttributeIOR* theAttribute);
100
103
105 virtual ~SALOMEDSImpl_Study();
106
107 virtual void Init();
108 virtual void Clear();
109
111 virtual bool Open(const std::string& aStudyUrl);
112
114 virtual bool Save(SALOMEDSImpl_DriverFactory* aFactory,
115 bool theMultiFile,
116 bool theASCII);
117
119 virtual bool SaveAs(const std::string& aUrl,
121 bool theMultiFile,
122 bool theASCII);
123
124 bool CopyLabel(SALOMEDSImpl_Driver* theEngine,
125 const int theSourceStartDepth,
126 const DF_Label& theSource,
127 const DF_Label& theDestinationMain);
128
129 DF_Label PasteLabel(SALOMEDSImpl_Driver* theEngine,
130 const DF_Label& theSource,
131 const DF_Label& theDestinationStart,
132 const bool isFirstElement);
133
134 virtual bool CanCopy(const SALOMEDSImpl_SObject& theObject, SALOMEDSImpl_Driver* Engine);
135 virtual bool Copy(const SALOMEDSImpl_SObject& theObject, SALOMEDSImpl_Driver* Engine);
136 virtual bool CanPaste(const SALOMEDSImpl_SObject& theObject, SALOMEDSImpl_Driver* Engine);
137 virtual SALOMEDSImpl_SObject Paste(const SALOMEDSImpl_SObject& theObject, SALOMEDSImpl_Driver* Engine);
138
139 // _SaveAs private function called by Save and SaveAs
140 virtual bool Impl_SaveAs(const std::string& aUrl,
142 bool theMultiFile,
143 bool theASCII);
144
145 // _SaveObject private function called by _SaveAs
146 virtual bool Impl_SaveObject(const SALOMEDSImpl_SObject& SC, HDFgroup *hdf_group_datatype);
147
148 virtual bool Impl_SaveProperties(HDFgroup *hdf_group);
149
150
152 virtual std::string GetPersistentReference();
153
155 virtual bool IsEmpty();
156
158 virtual SALOMEDSImpl_SComponent FindComponent (const std::string& aComponentName);
159
161 virtual SALOMEDSImpl_SComponent FindComponentID(const std::string& aComponentID);
162
164 virtual SALOMEDSImpl_SObject FindObject(const std::string& anObjectName);
165
166
168 virtual std::vector<SALOMEDSImpl_SObject> FindObjectByName( const std::string& anObjectName,
169 const std::string& aComponentName ) ;
170
172 virtual SALOMEDSImpl_SObject FindObjectID(const std::string& anObjectID);
173
175 virtual SALOMEDSImpl_SObject CreateObjectID(const std::string& anObjectID);
176
178 virtual SALOMEDSImpl_SObject FindObjectIOR(const std::string& anObjectIOR);
179
181 virtual SALOMEDSImpl_SObject FindObjectByPath(const std::string& thePath);
182
184 virtual std::string GetObjectPath(const SALOMEDSImpl_SObject& theObject);
185
186 std::string GetObjectPathByIOR(const std::string& theIOR);
187
189 virtual SALOMEDSImpl_ChildIterator NewChildIterator(const SALOMEDSImpl_SObject& aSO);
190
192 virtual SALOMEDSImpl_SComponentIterator NewComponentIterator();
193
195 virtual SALOMEDSImpl_StudyBuilder* NewBuilder();
196
198 virtual std::string Name();
199
201 virtual void Name(const std::string& name);
202
204 virtual bool IsSaved();
205
207 virtual void IsSaved(bool save);
208
210 virtual bool IsModified();
211
213 virtual std::string URL();
214
216 virtual void URL(const std::string& url);
217
218 virtual bool IsLocked();
219
220 virtual void DeleteIORLabelMapItem(const std::string& anIOR);
221 virtual void UpdateIORLabelMap(const std::string& anIOR, const std::string& aLabel);
222
223 virtual std::vector<SALOMEDSImpl_SObject> FindDependances(const SALOMEDSImpl_SObject& anObject);
224
225 virtual SALOMEDSImpl_AttributeStudyProperties* GetProperties();
226
227 virtual std::string GetLastModificationDate();
228
229 virtual std::vector<std::string> GetModificationsDate();
230
231 virtual SALOMEDSImpl_UseCaseBuilder* GetUseCaseBuilder();
232
233 void EnableUseCaseAutoFilling(bool isEnabled);
234
235 virtual std::string GetErrorCode() { return _errorCode; }
236 virtual bool IsError() { return _errorCode != ""; }
237
238 virtual SALOMEDSImpl_SComponent GetSComponent(const std::string& theEntry);
239 virtual SALOMEDSImpl_SComponent GetSComponent(const DF_Label& theLabel);
240 virtual SALOMEDSImpl_SObject GetSObject(const std::string& theEntry);
241 virtual SALOMEDSImpl_SObject GetSObject(const DF_Label& theEntryLabel);
242 virtual DF_Attribute* GetAttribute(const std::string& theEntry,
243 const std::string& theType);
244
245 virtual bool DumpStudy(const std::string& thePath,
246 const std::string& theBaseName,
247 bool isPublished,
248 bool isMultiFile,
249 SALOMEDSImpl_DriverFactory* theFactory);
250
251 static std::string GetDumpStudyComment(const char* theComponentName = 0);
252
253 // Returns the folder of the python script which is currently dumped
254 std::string GetDumpPath();
255
256 virtual DF_Document* GetDocument() { return _doc; }
257
258 //The method dump creates a txt file that contain a dump of the study, for debug use
259 void dump(const std::string& theFileName);
260
261 //This method marks the study as being modified
262 void Modify();
263
264 SALOMEDSImpl_AttributeParameter* GetCommonParameters(const char* theID, int theSavePoint);
265
266 SALOMEDSImpl_AttributeParameter* GetModuleParameters(const char* theID,
267 const char* theModuleName,
268 int theSavePoint);
269
270 //Locks the study, theLockerID is identificator of the of the one who locked the study for ex. IOR
271 void SetStudyLock(const char* theLockerID);
272
273 //Returns True if the study is locked
274 bool IsStudyLocked();
275
276 //Unlocks the study
277 void UnLockStudy(const char* theLockerID);
278
279 //Returns an ID of the study locker
280 std::vector<std::string> GetLockerID();
281
282 //Managing of variables
283 void SetVariable(const std::string& theVarName,
284 const double theValue,
286
287 void SetStringVariable(const std::string& theVarName,
288 const std::string& theValue,
290
291 void SetStringVariableAsDouble(const std::string& theVarName,
292 const double theValue,
294
295 double GetVariableValue(const std::string& theVarName);
296
297 std::string GetStringVariableValue(const std::string& theVarName);
298
299 bool IsTypeOf(const std::string& theVarName,
301
302 bool IsVariable(const std::string& theVarName) const;
303
304
305 std::vector<std::string> GetVariableNames() const;
306
307 void AddVariable(SALOMEDSImpl_GenericVariable* theVariable);
308
309 SALOMEDSImpl_GenericVariable* GetVariable(const std::string& theName) const;
310
311 bool RemoveVariable(const std::string& theVarName);
312
313 bool RenameVariable(const std::string& theVarName, const std::string& theNewVarName);
314
315 bool IsVariableUsed(const std::string& theVarName);
316
317 bool FindVariableAttribute(SALOMEDSImpl_StudyBuilder* theStudyBuilder,
318 SALOMEDSImpl_SObject theSObject,
319 const std::string& theName);
320 bool FindVariableAttribute(const std::string& theName);
321
322 void ReplaceVariableAttribute(SALOMEDSImpl_StudyBuilder* theStudyBuilder,
323 SALOMEDSImpl_SObject theSObject,
324 const std::string& theSource,
325 const std::string& theDest);
326 void ReplaceVariableAttribute(const std::string& theSource, const std::string& theDest);
327
328 std::vector< std::vector<std::string> > ParseVariables(const std::string& theVariables) const;
329
330 //Returns a callback
332
333 //Returns a list of IOR's stored in the study
334 std::vector<std::string> GetIORs();
335
336 // Notification mechanism
337 virtual bool addSO_Notification(const SALOMEDSImpl_SObject& theSObject);
338 virtual bool removeSO_Notification(const SALOMEDSImpl_SObject& theSObject);
339 virtual bool modifySO_Notification(const SALOMEDSImpl_SObject& theSObject, int reason);
340 virtual void setNotifier(SALOMEDSImpl_AbstractCallback* notifier);
341
342 static void RegisterGenObj (const std::string& theIOR, DF_Label label);
343 static void UnRegisterGenObj(const std::string& theIOR, DF_Label label);
344 void setGenObjRegister(SALOMEDSImpl_AbstractCallback* theRegister);
345
348};
349#endif
#define SALOMEDSIMPL_EXPORT
Definition: SALOMEDSImpl_Defines.hxx:34
static void DumpStudy()
Function : Purpose :
Definition: SALOMEDS_Client.cxx:72
Definition: DF_Application.hxx:29
Definition: DF_Attribute.hxx:30
Definition: DF_Document.hxx:32
Definition: DF_Label.hxx:65
Definition: HDFgroup.hxx:38
Definition: SALOMEDSImpl_Callback.hxx:59
Definition: SALOMEDSImpl_AttributeIOR.hxx:39
Class: SALOMEDSImpl_AttributeParameter Description : AttributeParameter is a universal container of b...
Definition: SALOMEDSImpl_AttributeParameter.hxx:48
Definition: SALOMEDSImpl_AttributeStudyProperties.hxx:39
Definition: SALOMEDSImpl_Callback.hxx:34
Definition: SALOMEDSImpl_ChildIterator.hxx:36
Definition: SALOMEDSImpl_Driver.hxx:99
Definition: SALOMEDSImpl_Driver.hxx:34
Definition: SALOMEDSImpl_GenericAttribute.hxx:39
Definition: SALOMEDSImpl_GenericVariable.hxx:34
VariableTypes
Definition: SALOMEDSImpl_GenericVariable.hxx:38
Definition: SALOMEDSImpl_SComponentIterator.hxx:41
Definition: SALOMEDSImpl_SComponent.hxx:44
Definition: SALOMEDSImpl_SObject.hxx:41
Definition: SALOMEDSImpl_StudyBuilder.hxx:42
Definition: SALOMEDSImpl_Study.hxx:59
bool _Saved
Definition: SALOMEDSImpl_Study.hxx:65
std::vector< SALOMEDSImpl_GenericVariable * > myNoteBookVars
Definition: SALOMEDSImpl_Study.hxx:80
DF_Application * _appli
Definition: SALOMEDSImpl_Study.hxx:62
virtual bool IsError()
Definition: SALOMEDSImpl_Study.hxx:236
std::map< std::string, SALOMEDSImpl_SComponent > _mapOfSCO
Definition: SALOMEDSImpl_Study.hxx:78
std::string _name
Definition: SALOMEDSImpl_Study.hxx:61
virtual DF_Document * GetDocument()
Definition: SALOMEDSImpl_Study.hxx:256
DF_Document * _clipboard
Definition: SALOMEDSImpl_Study.hxx:64
virtual std::string GetErrorCode()
Definition: SALOMEDSImpl_Study.hxx:235
std::map< std::string, DF_Label > myIORLabels
Definition: SALOMEDSImpl_Study.hxx:79
SALOMEDSImpl_AbstractCallback * _genObjRegister
Definition: SALOMEDSImpl_Study.hxx:74
std::string _URL
Definition: SALOMEDSImpl_Study.hxx:66
SALOMEDSImpl_AbstractCallback * _notifier
Definition: SALOMEDSImpl_Study.hxx:73
SALOMEDSImpl_Callback * _cb
Definition: SALOMEDSImpl_Study.hxx:70
std::string _dumpPath
Definition: SALOMEDSImpl_Study.hxx:75
bool _autoFill
Definition: SALOMEDSImpl_Study.hxx:67
SALOMEDSImpl_UseCaseBuilder * _useCaseBuilder
Definition: SALOMEDSImpl_Study.hxx:72
SALOMEDSImpl_Callback * GetCallback()
Definition: SALOMEDSImpl_Study.hxx:331
DF_Document * _doc
Definition: SALOMEDSImpl_Study.hxx:63
std::map< std::string, SALOMEDSImpl_SObject > _mapOfSO
Definition: SALOMEDSImpl_Study.hxx:77
std::string _errorCode
Definition: SALOMEDSImpl_Study.hxx:68
SALOMEDSImpl_StudyBuilder * _builder
Definition: SALOMEDSImpl_Study.hxx:71
std::vector< std::string > _lockers
Definition: SALOMEDSImpl_Study.hxx:69
Definition: SALOMEDSImpl_UseCaseBuilder.hxx:40
def Init()
Definition: salome_ComponentGUI.py:84
@ SO
component implemented as a dynamic library loadable with dlopen
Definition: SALOME_ModuleCatalog.idl:157
string name
Definition: pythfilter.py:56
def dump(filename)
Definition: pythfilter.py:368