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