Salome HOME
PAL13000: Crash with 'import CALCULATOR_TEST_STUDY_WITHOUTIHM'
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_AttributeParameter.hxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 //  File   : SALOMEDSImpl_AttributeIOR.hxx
21 //  Author : Sergey RUIN
22 //  Module : SALOME
23
24 #ifndef _SALOMEDSImpl_AttributeParameter_HeaderFile
25 #define _SALOMEDSImpl_AttributeParameter_HeaderFile
26
27 #include <Standard_DefineHandle.hxx>
28 #include <TDF_Attribute.hxx>
29 #include <TCollection_AsciiString.hxx>
30 #include <TCollection_ExtendedString.hxx>
31 #include <TDF_Label.hxx> 
32 #include "SALOMEDSImpl_GenericAttribute.hxx"
33
34 #include <vector>
35 #include <string>
36 #include <map>
37
38 class Standard_GUID;
39 class Handle(TDF_Attribute);
40 class Handle(TDF_RelocationTable);
41
42
43 DEFINE_STANDARD_HANDLE( SALOMEDSImpl_AttributeParameter, SALOMEDSImpl_GenericAttribute )
44
45 enum Parameter_Types {PT_INTEGER, PT_REAL, PT_BOOLEAN, PT_STRING, PT_REALARRAY, PT_INTARRAY, PT_STRARRAY};
46
47 /*!
48  Class: SALOMEDSImpl_AttributeParameter
49  Description : AttributeParameter is a universal container of basic types 
50 */
51
52 class SALOMEDSImpl_AttributeParameter : public SALOMEDSImpl_GenericAttribute 
53 {
54
55 private:
56   
57   std::map<std::string, int>                     _ints;
58   std::map<std::string, double>                  _reals;
59   std::map<std::string, std::string>             _strings;
60   std::map<std::string, bool>                    _bools;
61   std::map< std::string, vector<double> >        _realarrays;
62   std::map< std::string, vector<int> >           _intarrays;
63   std::map< std::string, vector<std::string> >   _strarrays;
64
65 public:
66   Standard_EXPORT static const Standard_GUID& GetID() ;
67
68   Standard_EXPORT  SALOMEDSImpl_AttributeParameter():SALOMEDSImpl_GenericAttribute("AttributeParameter") {}
69   Standard_EXPORT  static Handle(SALOMEDSImpl_AttributeParameter) Set (const TDF_Label& L);
70
71
72   Standard_EXPORT void SetInt(const std::string& theID, const int& theValue);
73   Standard_EXPORT int GetInt(const std::string& theID);
74
75   Standard_EXPORT void SetReal(const std::string& theID, const double& theValue);
76   Standard_EXPORT double GetReal(const std::string& theID);
77
78   Standard_EXPORT void SetString(const std::string& theID, const std::string& theValue);
79   Standard_EXPORT std::string GetString(const std::string& theID);
80   
81   Standard_EXPORT void SetBool(const std::string& theID, const bool& theValue);
82   Standard_EXPORT bool GetBool(const std::string& theID);
83   
84   Standard_EXPORT void SetRealArray(const std::string& theID, const std::vector<double>& theArray);
85   Standard_EXPORT std::vector<double> GetRealArray(const std::string& theID);
86   
87   Standard_EXPORT void SetIntArray(const std::string& theID, const std::vector<int>& theArray);
88   Standard_EXPORT std::vector<int> GetIntArray(const std::string& theID);
89
90   Standard_EXPORT void SetStrArray(const std::string& theID, const std::vector<std::string>& theArray);
91   Standard_EXPORT std::vector<std::string> GetStrArray(const std::string& theID);
92
93   Standard_EXPORT bool IsSet(const std::string& theID, const Parameter_Types theType);
94   
95   Standard_EXPORT bool RemoveID(const std::string& theID, const Parameter_Types theType);
96
97   Standard_EXPORT Handle(SALOMEDSImpl_AttributeParameter) GetFather();
98   Standard_EXPORT bool HasFather();
99   Standard_EXPORT bool IsRoot();
100
101   Standard_EXPORT std::vector<std::string> GetIDs(const Parameter_Types theType);
102
103   Standard_EXPORT void Clear();
104
105   Standard_EXPORT  virtual TCollection_AsciiString Save();
106   Standard_EXPORT  virtual void Load(const TCollection_AsciiString& theValue); 
107
108   Standard_EXPORT  const Standard_GUID& ID() const;
109   Standard_EXPORT  void Restore(const Handle(TDF_Attribute)& with) ;
110   Standard_EXPORT  Handle_TDF_Attribute NewEmpty() const;
111   Standard_EXPORT  void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_RelocationTable)& RT) const;
112   
113   Standard_EXPORT ~SALOMEDSImpl_AttributeParameter() {}
114
115 public:
116   DEFINE_STANDARD_RTTI( SALOMEDSImpl_AttributeParameter )
117 };
118
119 #endif