Salome HOME
PR: last merge from BR_V5_DEV
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_StudyBuilder.hxx
1 //  Copyright (C) 2007-2008  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.
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 //  File   : SALOMEDSImpl_StudyBuilder.hxx
23 //  Author : Sergey RUIN
24 //  Module : SALOME
25 //
26 #ifndef __SALOMEDSImpl_STUDYBUILDER_H__
27 #define __SALOMEDSImpl_STUDYBUILDER_H__
28
29 #include "SALOMEDSImpl_Defines.hxx"
30 // std C++ headers
31 #include <iostream>
32 #include <string>
33 #include <vector>
34
35 #include "SALOMEDSImpl_Callback.hxx"
36 #include "SALOMEDSImpl_Driver.hxx"
37
38 class SALOMEDSImpl_Study;
39
40 class SALOMEDSIMPL_EXPORT SALOMEDSImpl_StudyBuilder
41 {
42 private:
43   DF_Document*             _doc;
44   SALOMEDSImpl_Study*      _study;  
45   SALOMEDSImpl_Callback*   _callbackOnAdd;
46   SALOMEDSImpl_Callback*   _callbackOnRemove;
47   std::string              _errorCode;
48
49 public:
50
51   SALOMEDSImpl_StudyBuilder(const SALOMEDSImpl_Study* theOwner);
52
53   ~SALOMEDSImpl_StudyBuilder();
54
55   virtual SALOMEDSImpl_SComponent NewComponent(const std::string& ComponentDataType);
56
57   virtual bool DefineComponentInstance (const SALOMEDSImpl_SComponent&, const std::string& ComponentIOR);
58
59   virtual bool RemoveComponent(const SALOMEDSImpl_SComponent& aComponent);
60
61   virtual SALOMEDSImpl_SObject NewObject(const SALOMEDSImpl_SObject& theFatherObject);
62
63   virtual SALOMEDSImpl_SObject NewObjectToTag(const SALOMEDSImpl_SObject& theFatherObject, 
64     const int theTag);
65
66   //! The methods adds a new subdirectory, the path can be absolute or relative (then the current context is used)
67   virtual bool AddDirectory(const std::string& thePath);
68
69   virtual bool LoadWith(const SALOMEDSImpl_SComponent& sco, SALOMEDSImpl_Driver* Engine);
70   virtual bool Load(const SALOMEDSImpl_SObject& sco);
71
72   virtual bool RemoveObject(const SALOMEDSImpl_SObject& anObject);
73   virtual bool RemoveObjectWithChildren(const SALOMEDSImpl_SObject& anObject);
74
75   virtual DF_Attribute* FindOrCreateAttribute(const SALOMEDSImpl_SObject& anObject, 
76                                               const std::string& aTypeOfAttribute);
77   virtual bool FindAttribute(const SALOMEDSImpl_SObject& anObject, 
78                              DF_Attribute*& anAttribute, 
79                              const std::string& aTypeOfAttribute);
80
81   virtual bool RemoveAttribute(const SALOMEDSImpl_SObject& anObject, const std::string& aTypeOfAttribute);
82
83   virtual bool Addreference(const SALOMEDSImpl_SObject& me, 
84                             const SALOMEDSImpl_SObject& thereferencedObject);
85
86   virtual bool RemoveReference(const SALOMEDSImpl_SObject& me);
87
88   virtual bool SetGUID(const SALOMEDSImpl_SObject& anObject, const std::string& theGUID);
89   virtual bool IsGUID(const SALOMEDSImpl_SObject& anObject, const std::string& theGUID);
90
91   virtual void NewCommand();
92   virtual void CommitCommand();
93   virtual bool HasOpenCommand();
94   virtual void AbortCommand();
95   virtual void Undo();
96   virtual void Redo();
97   bool GetAvailableUndos();
98   bool GetAvailableRedos();
99   bool IsSaved();
100   bool IsModified();
101   virtual int UndoLimit();
102   virtual void UndoLimit(const int);
103
104   void CheckLocked();
105
106   virtual SALOMEDSImpl_Callback* SetOnAddSObject(const SALOMEDSImpl_Callback* theCallback);
107   virtual SALOMEDSImpl_Callback* SetOnRemoveSObject(const SALOMEDSImpl_Callback* theCallback);
108
109   virtual bool SetName(const SALOMEDSImpl_SObject& theSO, const std::string& theValue);
110
111   virtual bool SetComment(const SALOMEDSImpl_SObject& theSO, const std::string& theValue);
112
113   virtual bool SetIOR(const SALOMEDSImpl_SObject& theSO, const std::string& theValue);
114
115   virtual std::string GetErrorCode() { return _errorCode; }
116   virtual bool IsError() { return _errorCode != ""; }
117
118   virtual SALOMEDSImpl_Study* GetOwner() { return _study; }
119 };
120 #endif