1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SALOME_Notebook.hxx
23 // Author : Alexandre SOLOVYOV
26 #ifndef __SALOME_NOTEBOOK_H__
27 #define __SALOME_NOTEBOOK_H__
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 <Utils_Mutex.hxx>
39 class SALOME_Parameter;
41 class SALOME_Notebook : public virtual POA_SALOME::Notebook, public virtual SALOME::GenericObj_i
44 SALOME_Notebook( PortableServer::POA_ptr thePOA, SALOMEDS::Study_ptr theStudy );
46 virtual CORBA::Boolean AddDependency( SALOME::ParameterizedObject_ptr theObj, SALOME::ParameterizedObject_ptr theRef );
47 virtual CORBA::Boolean RemoveDependency( SALOME::ParameterizedObject_ptr theObj, SALOME::ParameterizedObject_ptr theRef );
48 virtual void ClearDependencies( SALOME::ParameterizedObject_ptr theObj, SALOME::DependenciesType theType );
49 virtual void SetToUpdate( SALOME::ParameterizedObject_ptr theObj );
50 virtual void Update();
52 virtual CORBA::Boolean AddExpression( const char* theExpr );
53 virtual CORBA::Boolean AddNamedExpression( const char* theName, const char* theExpr );
54 virtual CORBA::Boolean AddBoolean( const char* theName, CORBA::Boolean theValue );
55 virtual CORBA::Boolean AddInteger( const char* theName, CORBA::Long theValue );
56 virtual CORBA::Boolean AddReal( const char* theName, CORBA::Double theValue );
57 virtual CORBA::Boolean AddString( const char* theName, const char* theValue );
58 virtual CORBA::Boolean Remove( const char* theParamName );
59 virtual CORBA::Boolean Rename( const char* theOldName, const char* theNewName );
60 virtual SALOME::Parameter_ptr GetParameter( const char* theParamName );
61 virtual SALOME::StringArray* Parameters();
62 virtual SALOME::StringArray* AbsentParameters();
64 virtual CORBA::Boolean Save( const char* theFileName );
65 virtual CORBA::Boolean Load( const char* theFileName );
66 virtual char* DumpPython();
69 SALOME_Parameter* GetParameterPtr( const char* theParamName ) const;
70 void UpdateAnonymous( const char* theOldName, SALOME_Parameter* theParam );
72 static std::vector<std::string> Split( const std::string& theData, const std::string& theSeparator, bool theIsKeepEmpty );
75 bool AddParameter( SALOME_Parameter* theParam );
76 bool AddDependencies( SALOME_Parameter* theParam );
77 bool AddDependency( const std::string& theObjKey, const std::string& theRefKey );
78 void ClearDependencies( const std::string& theObjKey, SALOME::DependenciesType theType );
79 bool CheckParamName( const std::string& theParamName ) const;
80 SALOME::StringArray* GenerateList( const std::list<std::string>& theList ) const;
81 std::string GetComponent( const std::string& theKey, std::string& theEntry ) const;
82 bool ParseDependencies( const std::string& theData );
85 std::string GetKey( SALOME::ParameterizedObject_ptr theObj );
86 std::string GetKey( const std::string& theParamName );
87 std::list<std::string> GetAllDependingOn( const std::string& theKey );
88 SALOME::ParameterizedObject_ptr FindObject( const std::string& theKey );
91 friend class KeyHelper;
95 KeyHelper( const std::string& theKey, SALOME_Notebook* theNotebook );
96 std::string key() const;
97 bool operator < ( const KeyHelper& theKH ) const;
98 bool operator == ( const std::string& theKey ) const;
102 SALOME_Notebook* myNotebook;
107 std::string myName, myExpr;
108 std::list< KeyHelper > myObjects;
113 void Sort( std::list< KeyHelper >& theList ) const;
114 bool Substitute( SubstitutionInfo& theSubstitution );
115 SubstitutionInfo CreateSubstitution( const std::string& theName, const std::string& theExpr, bool theIsRename );
116 void AddSubstitution( const std::string& theName, const std::string& theExpr, bool theIsRename );
119 std::map< std::string, std::list<std::string> > myDependencies;
120 std::map< std::string, SALOME_Parameter* > myParameters;
121 std::list< KeyHelper > myToUpdate;
122 std::list<SubstitutionInfo> mySubstitutions;
123 SALOMEDS::Study_var myStudy;