Salome HOME
Base implementation of Notebook
[modules/kernel.git] / src / Notebook / SALOME_Notebook.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   : SALOME_Notebook.hxx
23 //  Author : Alexandre SOLOVYOV
24 //  Module : SALOME
25 //
26 #ifndef __SALOME_NOTEBOOK_H__
27 #define __SALOME_NOTEBOOK_H__
28
29 #include <SALOMEconfig.h>
30 #include CORBA_SERVER_HEADER(SALOME_Notebook)
31 #include CORBA_SERVER_HEADER(SALOMEDS)
32 #include <SALOME_GenericObj_i.hh>
33 #include <string>
34 #include <list>
35 #include <map>
36
37 class SALOME_Parameter;
38
39 class SALOME_Notebook : public virtual POA_SALOME::Notebook, public virtual SALOME::GenericObj_i
40 {
41 public:
42   SALOME_Notebook( SALOMEDS::Study_ptr theStudy );
43
44   virtual CORBA::Boolean AddDependency( SALOME::ParameterizedObject_ptr theObj, SALOME::ParameterizedObject_ptr theRef );
45   virtual void RemoveDependency( SALOME::ParameterizedObject_ptr theObj, SALOME::ParameterizedObject_ptr theRef );
46   virtual void ClearDependencies( SALOME::ParameterizedObject_ptr theObj );
47   virtual void SetToUpdate( SALOME::ParameterizedObject_ptr theObj );
48   virtual void Update();
49
50   virtual CORBA::Boolean AddExpr( const char* theExpr );
51   virtual CORBA::Boolean AddNameExpr( const char* theName, const char* theExpr );
52   virtual CORBA::Boolean AddValue( const char* theName, CORBA::Double theValue );
53   virtual void Remove( const char* theParamName );
54   virtual SALOME::Parameter_ptr Param( const char* theParamName );
55
56   SALOME_Parameter* ParamPtr( const char* theParamName ) const;
57
58 protected:
59   bool AddParam( SALOME_Parameter* theParam );
60   bool AddDependencies( SALOME_Parameter* theParam );
61   bool AddDependency( const std::string& theObjKey, const std::string& theRefKey );
62   void ClearDependencies( const std::string& theObjKey );
63
64 private:
65   std::string GetKey( SALOME::ParameterizedObject_ptr theObj );
66   std::string GetKey( const std::string& theParamName );
67
68   //! return list of objects that depend on object with given key
69   std::list<std::string> GetAllDependingOn( const std::string& theKey );
70   SALOME::ParameterizedObject_ptr FindObject( const std::string& theKey );
71
72 private:
73   std::map< std::string, std::list<std::string> > myDeps;
74   std::map< std::string, SALOME_Parameter* > myParams;
75
76   friend class KeyHelper;
77   class KeyHelper
78   {
79   public:
80     KeyHelper( const std::string& theKey, SALOME_Notebook* theNotebook );
81     std::string key() const;
82     bool operator < ( const KeyHelper& theKH ) const;
83     bool operator == ( const std::string& theKey ) const;
84
85   private:
86     std::string myKey;
87     SALOME_Notebook* myNotebook;
88   };
89   std::list< KeyHelper > myToUpdate;
90
91   SALOMEDS::Study_var myStudy;
92 };
93
94 #endif