Back to index

salome-kernel  6.5.0
SALOMEDSImpl_Study.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  File   : SALOMEDSImpl_Study.hxx
00024 //  Author : Sergey RUIN
00025 //  Module : SALOME
00026 //
00027 #ifndef __SALOMEDSIMPL_STUDY_I_H__
00028 #define __SALOMEDSIMPL_STUDY_I_H__
00029 
00030 // std C++ headers
00031 #include <iostream>
00032 #include <string>
00033 #include <vector>
00034 #include <map>
00035 
00036 #include "DF_Document.hxx"
00037 #include "DF_Label.hxx"
00038 #include <stdio.h>
00039 
00040 //SALOMEDSImpl headers
00041 #include "SALOMEDSImpl_Defines.hxx"
00042 #include "SALOMEDSImpl_SComponentIterator.hxx"
00043 #include "SALOMEDSImpl_SObject.hxx"
00044 #include "SALOMEDSImpl_StudyBuilder.hxx"
00045 #include "SALOMEDSImpl_UseCaseBuilder.hxx"
00046 #include "SALOMEDSImpl_AttributeStudyProperties.hxx"
00047 #include "SALOMEDSImpl_AttributeIOR.hxx"
00048 #include "SALOMEDSImpl_AttributeParameter.hxx"
00049 #include "SALOMEDSImpl_Callback.hxx"
00050 #include "SALOMEDSImpl_Driver.hxx" 
00051 #include "SALOMEDSImpl_ChildIterator.hxx" 
00052 #include "SALOMEDSImpl_GenericVariable.hxx"
00053 
00054 class SALOMEDSImpl_StudyManager;
00055 class SALOMEDSImpl_GenericAttribute;
00056 
00057 
00058 class SALOMEDSIMPL_EXPORT SALOMEDSImpl_Study
00059 {
00060 private:
00061   std::string              _name;  
00062   DF_Document*             _doc;  // Document
00063   bool                     _Saved; // True if the Study is saved
00064   std::string              _URL; //URL of the persistent reference of the study
00065   int                      _StudyId; 
00066   DF_Label                 _current;
00067   bool                     _autoFill; 
00068   std::string              _errorCode;
00069   std::vector<std::string> _lockers;
00070   SALOMEDSImpl_Callback*   _cb;
00071   SALOMEDSImpl_StudyBuilder*   _builder;
00072   SALOMEDSImpl_UseCaseBuilder* _useCaseBuilder;
00073   SALOMEDSImpl_AbstractCallback*   _notifier;
00074 
00075   std::map<std::string, SALOMEDSImpl_SObject> _mapOfSO;
00076   std::map<std::string, SALOMEDSImpl_SComponent> _mapOfSCO;
00077   std::map<std::string, DF_Label> myIORLabels;
00078   std::vector<SALOMEDSImpl_GenericVariable*> myNoteBookVars;
00079 
00080   SALOMEDSImpl_SObject   _FindObject(const SALOMEDSImpl_SObject& SO,
00081     const std::string& anObjectName,
00082     bool& _find);
00083 
00084   SALOMEDSImpl_SObject   _FindObjectIOR(const SALOMEDSImpl_SObject& SO,
00085     const std::string& anObjectIOR,
00086     bool& _find);
00087 
00088   std::string _GetStudyVariablesScript();
00089   std::string _GetNoteBookAccessor();
00090   std::string _GetNoteBookAccess();
00091 
00092 public:
00093 
00094   static SALOMEDSImpl_Study* GetStudy(const DF_Label& theLabel);
00095   static SALOMEDSImpl_SObject SObject(const DF_Label& theLabel);
00096   static SALOMEDSImpl_SComponent SComponent(const DF_Label& theLabel);
00097   static void IORUpdated(const SALOMEDSImpl_AttributeIOR* theAttribute);
00098 
00100    SALOMEDSImpl_Study(const DF_Document*, const std::string& study_name);
00101   
00103   virtual ~SALOMEDSImpl_Study(); 
00104   
00106   virtual std::string GetPersistentReference();
00107 
00109   virtual std::string GetTransientReference();
00110 
00111   virtual void SetTransientReference(const std::string& theIOR);
00112 
00114   virtual bool IsEmpty();
00115 
00117   virtual SALOMEDSImpl_SComponent FindComponent (const std::string& aComponentName);
00118 
00120   virtual SALOMEDSImpl_SComponent FindComponentID(const std::string& aComponentID);
00121 
00123   virtual SALOMEDSImpl_SObject FindObject(const std::string& anObjectName);
00124 
00125 
00127   virtual std::vector<SALOMEDSImpl_SObject> FindObjectByName( const std::string& anObjectName, 
00128                                                                        const std::string& aComponentName ) ;
00129   
00131   virtual SALOMEDSImpl_SObject FindObjectID(const std::string& anObjectID);
00132   
00134   virtual SALOMEDSImpl_SObject CreateObjectID(const std::string& anObjectID);
00135 
00137   virtual SALOMEDSImpl_SObject FindObjectIOR(const std::string& anObjectIOR);
00138 
00140   virtual SALOMEDSImpl_SObject FindObjectByPath(const std::string& thePath);
00141 
00143   virtual std::string GetObjectPath(const SALOMEDSImpl_SObject& theObject);
00144 
00145   std::string GetObjectPathByIOR(const std::string& theIOR);
00146 
00148   virtual bool SetContext(const std::string& thePath);
00149 
00151   virtual std::string GetContext();  
00152 
00154   virtual std::vector<std::string> GetObjectNames(const std::string& theContext);
00155 
00157   virtual std::vector<std::string> GetDirectoryNames(const std::string& theContext);
00158 
00160   virtual std::vector<std::string> GetFileNames(const std::string& theContext);
00161 
00163   virtual std::vector<std::string> GetComponentNames(const std::string& theContext);
00164 
00166   virtual SALOMEDSImpl_ChildIterator NewChildIterator(const SALOMEDSImpl_SObject& aSO);
00167 
00169   virtual SALOMEDSImpl_SComponentIterator NewComponentIterator();
00170 
00172   virtual SALOMEDSImpl_StudyBuilder* NewBuilder();
00173  
00175   virtual std::string Name();
00176 
00178   virtual void  Name(const std::string& name);
00179   
00181   virtual bool IsSaved();
00182 
00184   virtual void  IsSaved(bool save);
00185 
00187   virtual bool IsModified();
00188   
00190   virtual std::string URL();
00191 
00193   virtual void  URL(const std::string& url);
00194 
00195   virtual bool IsLocked();
00196   
00197   virtual int StudyId();
00198 
00199   virtual void  StudyId(int id);
00200   
00201   virtual void DeleteIORLabelMapItem(const std::string& anIOR);
00202   virtual void UpdateIORLabelMap(const std::string& anIOR, const std::string& aLabel);
00203   
00204   virtual std::vector<SALOMEDSImpl_SObject> FindDependances(const SALOMEDSImpl_SObject& anObject);
00205   
00206   virtual SALOMEDSImpl_AttributeStudyProperties* GetProperties();
00207   
00208   virtual std::string GetLastModificationDate();
00209   
00210   virtual std::vector<std::string> GetModificationsDate();
00211   
00212   virtual SALOMEDSImpl_UseCaseBuilder* GetUseCaseBuilder();
00213   
00214   virtual void Close();
00215   
00216   void EnableUseCaseAutoFilling(bool isEnabled);
00217   
00218   virtual std::string GetErrorCode() { return _errorCode; }
00219   virtual bool IsError() { return _errorCode != ""; }
00220   
00221   virtual SALOMEDSImpl_SComponent GetSComponent(const std::string& theEntry);
00222   virtual SALOMEDSImpl_SComponent GetSComponent(const DF_Label& theLabel);
00223   virtual SALOMEDSImpl_SObject GetSObject(const std::string& theEntry);
00224   virtual SALOMEDSImpl_SObject GetSObject(const DF_Label& theEntryLabel);
00225   virtual DF_Attribute* GetAttribute(const std::string& theEntry, 
00226                                                      const std::string& theType);
00227 
00228   virtual bool HasCurrentContext() { return !_current.IsNull(); }
00229 
00230   virtual bool DumpStudy(const std::string& thePath, 
00231                          const std::string& theBaseName, 
00232                          bool isPublished,
00233                          bool isMultiFile,
00234                          SALOMEDSImpl_DriverFactory* theFactory);
00235 
00236   static std::string GetDumpStudyComment(const char* theComponentName = 0);
00237   
00238   virtual DF_Document* GetDocument() { return _doc; } 
00239 
00240   //The method dump creates a txt file that contain a dump of the study, for debug use
00241   void dump(const std::string& theFileName);
00242 
00243   //This method marks the study as being modified
00244   void Modify();
00245 
00246   SALOMEDSImpl_AttributeParameter* GetCommonParameters(const char* theID, int theSavePoint);
00247 
00248   SALOMEDSImpl_AttributeParameter* GetModuleParameters(const char* theID, 
00249                                                                               const char* theModuleName,
00250                                                                               int theSavePoint);
00251 
00252   //Locks the study, theLockerID is identificator of the of the one who locked the study for ex. IOR
00253   void SetStudyLock(const char* theLockerID);
00254 
00255   //Returns True if the study is locked
00256   bool IsStudyLocked();
00257 
00258   //Unlocks the study
00259   void UnLockStudy(const char* theLockerID);
00260   
00261   //Returns an ID of the study locker
00262   std::vector<std::string> GetLockerID();
00263 
00264   //Managing of variables
00265   void SetVariable(const std::string& theVarName,
00266                    const double theValue, 
00267                    const SALOMEDSImpl_GenericVariable::VariableTypes);
00268 
00269   void SetStringVariable(const std::string& theVarName,
00270                          const std::string& theValue, 
00271                          const SALOMEDSImpl_GenericVariable::VariableTypes);
00272 
00273   void SetStringVariableAsDouble(const std::string& theVarName,
00274                                  const double theValue, 
00275                                  const SALOMEDSImpl_GenericVariable::VariableTypes);
00276   
00277   double GetVariableValue(const std::string& theVarName);
00278 
00279   std::string GetStringVariableValue(const std::string& theVarName);
00280 
00281   bool IsTypeOf(const std::string& theVarName,
00282                 SALOMEDSImpl_GenericVariable::VariableTypes theType) const;
00283         
00284   bool IsVariable(const std::string& theVarName) const;
00285 
00286 
00287   std::vector<std::string> GetVariableNames() const;
00288 
00289   void AddVariable(SALOMEDSImpl_GenericVariable* theVariable);
00290 
00291   SALOMEDSImpl_GenericVariable* GetVariable(const std::string& theName) const;
00292 
00293   bool RemoveVariable(const std::string& theVarName);
00294 
00295   bool RenameVariable(const std::string& theVarName, const std::string& theNewVarName);
00296 
00297   bool IsVariableUsed(const std::string& theVarName);
00298 
00299   bool FindVariableAttribute(SALOMEDSImpl_StudyBuilder* theStudyBuilder,
00300                              SALOMEDSImpl_SObject theSObject,
00301                              const std::string& theName);
00302   bool FindVariableAttribute(const std::string& theName);
00303 
00304   void ReplaceVariableAttribute(SALOMEDSImpl_StudyBuilder* theStudyBuilder,
00305                                 SALOMEDSImpl_SObject theSObject,
00306                                 const std::string& theSource,
00307                                 const std::string& theDest);
00308   void ReplaceVariableAttribute(const std::string& theSource, const std::string& theDest);
00309 
00310   std::vector< std::vector<std::string> > ParseVariables(const std::string& theVariables) const;
00311 
00312   //Returns a callback 
00313   SALOMEDSImpl_Callback* GetCallback() { return _cb; }
00314 
00315   //Returns a list of IOR's stored in the study
00316   std::vector<std::string> GetIORs();
00317 
00318   // Notification mechanism
00319   virtual bool addSO_Notification(const SALOMEDSImpl_SObject& theSObject);
00320   virtual bool removeSO_Notification(const SALOMEDSImpl_SObject& theSObject);
00321   virtual bool modifySO_Notification(const SALOMEDSImpl_SObject& theSObject, int reason);
00322   virtual void setNotifier(SALOMEDSImpl_AbstractCallback* notifier);
00323 
00324 
00325   friend class SALOMEDSImpl_StudyManager;    
00326   friend class SALOMEDSImpl_GenericAttribute;
00327   friend class SALOMEDSImpl_GenericVariable;
00328 };
00329 #endif