Version: 8.3.0
SALOMEDSImpl_Study.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, 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
41 #include "SALOMEDSImpl_Defines.hxx"
43 #include "SALOMEDSImpl_SObject.hxx"
50 #include "SALOMEDSImpl_Driver.hxx"
53 
56 
57 
59 {
60 private:
61  std::string _name;
62  DF_Document* _doc; // Document
63  bool _Saved; // True if the Study is saved
64  std::string _URL; //URL of the persistent reference of the study
65  int _StudyId;
67  bool _autoFill;
68  std::string _errorCode;
69  std::vector<std::string> _lockers;
75 
76  std::map<std::string, SALOMEDSImpl_SObject> _mapOfSO;
77  std::map<std::string, SALOMEDSImpl_SComponent> _mapOfSCO;
78  std::map<std::string, DF_Label> myIORLabels;
79  std::vector<SALOMEDSImpl_GenericVariable*> myNoteBookVars;
80 
81  SALOMEDSImpl_SObject _FindObject(const SALOMEDSImpl_SObject& SO,
82  const std::string& anObjectName,
83  bool& _find);
84 
85  SALOMEDSImpl_SObject _FindObjectIOR(const SALOMEDSImpl_SObject& SO,
86  const std::string& anObjectIOR,
87  bool& _find);
88 
89  std::string _GetStudyVariablesScript();
90  std::string _GetNoteBookAccessor();
91  std::string _GetNoteBookAccess(const std::string& theStudyVar);
92 
93 public:
94 
95  static SALOMEDSImpl_Study* GetStudy(const DF_Label& theLabel);
96  static SALOMEDSImpl_SObject SObject(const DF_Label& theLabel);
97  static SALOMEDSImpl_SComponent SComponent(const DF_Label& theLabel);
98  static void IORUpdated(const SALOMEDSImpl_AttributeIOR* theAttribute);
99 
101  SALOMEDSImpl_Study(const DF_Document*, const std::string& study_name);
102 
104  virtual ~SALOMEDSImpl_Study();
105 
107  virtual std::string GetPersistentReference();
108 
110  virtual std::string GetTransientReference();
111 
112  virtual void SetTransientReference(const std::string& theIOR);
113 
115  virtual bool IsEmpty();
116 
118  virtual SALOMEDSImpl_SComponent FindComponent (const std::string& aComponentName);
119 
121  virtual SALOMEDSImpl_SComponent FindComponentID(const std::string& aComponentID);
122 
124  virtual SALOMEDSImpl_SObject FindObject(const std::string& anObjectName);
125 
126 
128  virtual std::vector<SALOMEDSImpl_SObject> FindObjectByName( const std::string& anObjectName,
129  const std::string& aComponentName ) ;
130 
132  virtual SALOMEDSImpl_SObject FindObjectID(const std::string& anObjectID);
133 
135  virtual SALOMEDSImpl_SObject CreateObjectID(const std::string& anObjectID);
136 
138  virtual SALOMEDSImpl_SObject FindObjectIOR(const std::string& anObjectIOR);
139 
141  virtual SALOMEDSImpl_SObject FindObjectByPath(const std::string& thePath);
142 
144  virtual std::string GetObjectPath(const SALOMEDSImpl_SObject& theObject);
145 
146  std::string GetObjectPathByIOR(const std::string& theIOR);
147 
149  virtual bool SetContext(const std::string& thePath);
150 
152  virtual std::string GetContext();
153 
155  virtual std::vector<std::string> GetObjectNames(const std::string& theContext);
156 
158  virtual std::vector<std::string> GetDirectoryNames(const std::string& theContext);
159 
161  virtual std::vector<std::string> GetFileNames(const std::string& theContext);
162 
164  virtual std::vector<std::string> GetComponentNames(const std::string& theContext);
165 
167  virtual SALOMEDSImpl_ChildIterator NewChildIterator(const SALOMEDSImpl_SObject& aSO);
168 
170  virtual SALOMEDSImpl_SComponentIterator NewComponentIterator();
171 
173  virtual SALOMEDSImpl_StudyBuilder* NewBuilder();
174 
176  virtual std::string Name();
177 
179  virtual void Name(const std::string& name);
180 
182  virtual bool IsSaved();
183 
185  virtual void IsSaved(bool save);
186 
188  virtual bool IsModified();
189 
191  virtual std::string URL();
192 
194  virtual void URL(const std::string& url);
195 
196  virtual bool IsLocked();
197 
198  virtual int StudyId();
199 
200  virtual void StudyId(int id);
201 
202  virtual void DeleteIORLabelMapItem(const std::string& anIOR);
203  virtual void UpdateIORLabelMap(const std::string& anIOR, const std::string& aLabel);
204 
205  virtual std::vector<SALOMEDSImpl_SObject> FindDependances(const SALOMEDSImpl_SObject& anObject);
206 
207  virtual SALOMEDSImpl_AttributeStudyProperties* GetProperties();
208 
209  virtual std::string GetLastModificationDate();
210 
211  virtual std::vector<std::string> GetModificationsDate();
212 
213  virtual SALOMEDSImpl_UseCaseBuilder* GetUseCaseBuilder();
214 
215  virtual void Close();
216 
217  void EnableUseCaseAutoFilling(bool isEnabled);
218 
219  virtual std::string GetErrorCode() { return _errorCode; }
220  virtual bool IsError() { return _errorCode != ""; }
221 
222  virtual SALOMEDSImpl_SComponent GetSComponent(const std::string& theEntry);
223  virtual SALOMEDSImpl_SComponent GetSComponent(const DF_Label& theLabel);
224  virtual SALOMEDSImpl_SObject GetSObject(const std::string& theEntry);
225  virtual SALOMEDSImpl_SObject GetSObject(const DF_Label& theEntryLabel);
226  virtual DF_Attribute* GetAttribute(const std::string& theEntry,
227  const std::string& theType);
228 
229  virtual bool HasCurrentContext() { return !_current.IsNull(); }
230 
231  virtual bool DumpStudy(const std::string& thePath,
232  const std::string& theBaseName,
233  bool isPublished,
234  bool isMultiFile,
235  SALOMEDSImpl_DriverFactory* theFactory);
236 
237  static std::string GetDumpStudyComment(const char* theComponentName = 0);
238 
239  virtual DF_Document* GetDocument() { return _doc; }
240 
241  //The method dump creates a txt file that contain a dump of the study, for debug use
242  void dump(const std::string& theFileName);
243 
244  //This method marks the study as being modified
245  void Modify();
246 
247  SALOMEDSImpl_AttributeParameter* GetCommonParameters(const char* theID, int theSavePoint);
248 
249  SALOMEDSImpl_AttributeParameter* GetModuleParameters(const char* theID,
250  const char* theModuleName,
251  int theSavePoint);
252 
253  //Locks the study, theLockerID is identificator of the of the one who locked the study for ex. IOR
254  void SetStudyLock(const char* theLockerID);
255 
256  //Returns True if the study is locked
257  bool IsStudyLocked();
258 
259  //Unlocks the study
260  void UnLockStudy(const char* theLockerID);
261 
262  //Returns an ID of the study locker
263  std::vector<std::string> GetLockerID();
264 
265  //Managing of variables
266  void SetVariable(const std::string& theVarName,
267  const double theValue,
269 
270  void SetStringVariable(const std::string& theVarName,
271  const std::string& theValue,
273 
274  void SetStringVariableAsDouble(const std::string& theVarName,
275  const double theValue,
277 
278  double GetVariableValue(const std::string& theVarName);
279 
280  std::string GetStringVariableValue(const std::string& theVarName);
281 
282  bool IsTypeOf(const std::string& theVarName,
284 
285  bool IsVariable(const std::string& theVarName) const;
286 
287 
288  std::vector<std::string> GetVariableNames() const;
289 
290  void AddVariable(SALOMEDSImpl_GenericVariable* theVariable);
291 
292  SALOMEDSImpl_GenericVariable* GetVariable(const std::string& theName) const;
293 
294  bool RemoveVariable(const std::string& theVarName);
295 
296  bool RenameVariable(const std::string& theVarName, const std::string& theNewVarName);
297 
298  bool IsVariableUsed(const std::string& theVarName);
299 
300  bool FindVariableAttribute(SALOMEDSImpl_StudyBuilder* theStudyBuilder,
301  SALOMEDSImpl_SObject theSObject,
302  const std::string& theName);
303  bool FindVariableAttribute(const std::string& theName);
304 
305  void ReplaceVariableAttribute(SALOMEDSImpl_StudyBuilder* theStudyBuilder,
306  SALOMEDSImpl_SObject theSObject,
307  const std::string& theSource,
308  const std::string& theDest);
309  void ReplaceVariableAttribute(const std::string& theSource, const std::string& theDest);
310 
311  std::vector< std::vector<std::string> > ParseVariables(const std::string& theVariables) const;
312 
313  //Returns a callback
315 
316  //Returns a list of IOR's stored in the study
317  std::vector<std::string> GetIORs();
318 
319  // Notification mechanism
320  virtual bool addSO_Notification(const SALOMEDSImpl_SObject& theSObject);
321  virtual bool removeSO_Notification(const SALOMEDSImpl_SObject& theSObject);
322  virtual bool modifySO_Notification(const SALOMEDSImpl_SObject& theSObject, int reason);
323  virtual void setNotifier(SALOMEDSImpl_AbstractCallback* notifier);
324 
325  static void RegisterGenObj (const std::string& theIOR, DF_Label label);
326  static void UnRegisterGenObj(const std::string& theIOR, DF_Label label);
327  void setGenObjRegister(SALOMEDSImpl_AbstractCallback* theRegister);
328 
332 };
333 #endif