Salome HOME
Removed CASCatch
[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 "DF_Attribute.hxx"
28 #include "DF_Label.hxx"
29 #include "SALOMEDSImpl_GenericAttribute.hxx"
30
31 #include <vector>
32 #include <string>
33 #include <map>
34
35 enum Parameter_Types {PT_INTEGER, PT_REAL, PT_BOOLEAN, PT_STRING, PT_REALARRAY, PT_INTARRAY, PT_STRARRAY};
36
37 /*!
38  Class: SALOMEDSImpl_AttributeParameter
39  Description : AttributeParameter is a universal container of basic types 
40 */
41
42 class SALOMEDSImpl_AttributeParameter : public SALOMEDSImpl_GenericAttribute 
43 {
44
45 private:
46   
47   std::map<std::string, int>                          _ints;
48   std::map<std::string, double>                       _reals;
49   std::map<std::string, std::string>                  _strings;
50   std::map<std::string, bool>                         _bools;
51   std::map< std::string, std::vector<double> >        _realarrays;
52   std::map< std::string, std::vector<int> >           _intarrays;
53   std::map< std::string, std::vector<std::string> >   _strarrays;
54
55 public:
56   Standard_EXPORT static const std::string& GetID() ;
57
58   Standard_EXPORT  SALOMEDSImpl_AttributeParameter():SALOMEDSImpl_GenericAttribute("AttributeParameter") {}
59   Standard_EXPORT  static SALOMEDSImpl_AttributeParameter* Set (const DF_Label& L);
60
61
62   Standard_EXPORT void SetInt(const std::string& theID, const int& theValue);
63   Standard_EXPORT int GetInt(const std::string& theID);
64
65   Standard_EXPORT void SetReal(const std::string& theID, const double& theValue);
66   Standard_EXPORT double GetReal(const std::string& theID);
67
68   Standard_EXPORT void SetString(const std::string& theID, const std::string& theValue);
69   Standard_EXPORT std::string GetString(const std::string& theID);
70   
71   Standard_EXPORT void SetBool(const std::string& theID, const bool& theValue);
72   Standard_EXPORT bool GetBool(const std::string& theID);
73   
74   Standard_EXPORT void SetRealArray(const std::string& theID, const std::vector<double>& theArray);
75   Standard_EXPORT std::vector<double> GetRealArray(const std::string& theID);
76   
77   Standard_EXPORT void SetIntArray(const std::string& theID, const std::vector<int>& theArray);
78   Standard_EXPORT std::vector<int> GetIntArray(const std::string& theID);
79
80   Standard_EXPORT void SetStrArray(const std::string& theID, const std::vector<std::string>& theArray);
81   Standard_EXPORT std::vector<std::string> GetStrArray(const std::string& theID);
82
83   Standard_EXPORT bool IsSet(const std::string& theID, const Parameter_Types theType);
84   
85   Standard_EXPORT bool RemoveID(const std::string& theID, const Parameter_Types theType);
86
87   Standard_EXPORT SALOMEDSImpl_AttributeParameter* GetFather();
88   Standard_EXPORT bool HasFather();
89   Standard_EXPORT bool IsRoot();
90
91   Standard_EXPORT std::vector<std::string> GetIDs(const Parameter_Types theType);
92
93   Standard_EXPORT void Clear();
94
95   Standard_EXPORT  virtual std::string Save();
96   Standard_EXPORT  virtual void Load(const std::string& theValue); 
97
98   Standard_EXPORT  const std::string& ID() const;
99   Standard_EXPORT  void Restore(DF_Attribute* with) ;
100   Standard_EXPORT  DF_Attribute* NewEmpty() const;
101   Standard_EXPORT  void Paste(DF_Attribute* into);
102   
103   Standard_EXPORT ~SALOMEDSImpl_AttributeParameter() {}
104
105 };
106
107 #endif