]> SALOME platform Git repositories - modules/kernel.git/blob - src/Notebook/SALOME_Notebook.hxx
Salome HOME
803f3163bea96c6e746c2e30872400326ae4ce98
[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( PortableServer::POA_ptr thePOA, SALOMEDS::Study_ptr theStudy );
43
44   virtual CORBA::Boolean AddDependency( SALOME::ParameterizedObject_ptr theObj, SALOME::ParameterizedObject_ptr theRef );
45   virtual CORBA::Boolean RemoveDependency( SALOME::ParameterizedObject_ptr theObj, SALOME::ParameterizedObject_ptr theRef );
46   virtual void ClearDependencies( SALOME::ParameterizedObject_ptr theObj, SALOME::DependenciesType theType );
47   virtual void SetToUpdate( SALOME::ParameterizedObject_ptr theObj );
48   virtual void Update();
49
50   virtual CORBA::Boolean AddExpression( const char* theExpr );
51   virtual CORBA::Boolean AddNamedExpression( const char* theName, const char* theExpr );
52   virtual CORBA::Boolean AddBoolean( const char* theName, CORBA::Boolean theValue );
53   virtual CORBA::Boolean AddInteger( const char* theName, CORBA::Long theValue );
54   virtual CORBA::Boolean AddReal( const char* theName, CORBA::Double theValue );
55   virtual CORBA::Boolean AddString( const char* theName, const char* theValue );
56   virtual CORBA::Boolean Remove( const char* theParamName );
57   virtual SALOME::Parameter_ptr GetParameter( const char* theParamName );
58   virtual SALOME::StringArray* Parameters();
59   virtual SALOME::StringArray* AbsentParameters();
60
61   virtual CORBA::Boolean Save( const char* theFileName );
62   virtual CORBA::Boolean Load( const char* theFileName );
63   virtual CORBA::Boolean DumpPython( const char* theFileName );
64
65   SALOME_Parameter* GetParameterPtr( const char* theParamName ) const;
66
67 protected:
68   bool AddParam( SALOME_Parameter* theParam );
69   bool AddDependencies( SALOME_Parameter* theParam );
70   bool AddDependency( const std::string& theObjKey, const std::string& theRefKey );
71   void ClearDependencies( const std::string& theObjKey, SALOME::DependenciesType theType );
72   bool CheckParamName( const std::string& theParamName ) const;
73   SALOME::StringArray* GenerateList( const std::list<std::string>& theList ) const;
74   std::string GetComponent( const std::string& theKey, std::string& theEntry ) const;
75
76 private:
77   std::string GetKey( SALOME::ParameterizedObject_ptr theObj );
78   std::string GetKey( const std::string& theParamName );
79   std::list<std::string> GetAllDependingOn( const std::string& theKey );
80   SALOME::ParameterizedObject_ptr FindObject( const std::string& theKey );
81
82 private:
83   friend class KeyHelper;
84   class KeyHelper
85   {
86   public:
87     KeyHelper( const std::string& theKey, SALOME_Notebook* theNotebook );
88     std::string key() const;
89     bool operator < ( const KeyHelper& theKH ) const;
90     bool operator == ( const std::string& theKey ) const;
91
92   private:
93     std::string myKey;
94     SALOME_Notebook* myNotebook;
95   };
96
97   void Sort( std::list< KeyHelper >& theList ) const;
98
99 private:
100   std::map< std::string, std::list<std::string> > myDeps;
101   std::map< std::string, SALOME_Parameter* > myParams;
102   std::list< KeyHelper > myToUpdate;
103   SALOMEDS::Study_var myStudy;
104 };
105
106 #endif