0031939: Coding - correction of spelling errors in comments [part 3]
[occt.git] / src / MoniTool / MoniTool_AttrList.hxx
1 // Created on: 1994-11-04
2 // Created by: Christian CAILLET
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _MoniTool_AttrList_HeaderFile
18 #define _MoniTool_AttrList_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <Standard_CString.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <Standard_Type.hxx>
27 #include <MoniTool_ValueType.hxx>
28 #include <Standard_Integer.hxx>
29 #include <Standard_Real.hxx>
30 #include <NCollection_DataMap.hxx>
31 #include <Standard_Transient.hxx>
32 #include <TCollection_AsciiString.hxx>
33
34 //! a AttrList allows to record a list of attributes as Transients
35 //! which can be edited, changed ...
36 //! Each one is identified by a name
37 class MoniTool_AttrList 
38 {
39 public:
40
41   DEFINE_STANDARD_ALLOC
42
43   
44   //! Creates an AttrList, empty
45   Standard_EXPORT MoniTool_AttrList();
46   
47   //! Creates an AttrList from another one, definitions are shared
48   //! (calls SameAttributes)
49   Standard_EXPORT MoniTool_AttrList(const MoniTool_AttrList& other);
50   
51   //! Adds an attribute with a given name (replaces the former one
52   //! with the same name if already exists)
53   Standard_EXPORT void SetAttribute (const Standard_CString name, const Handle(Standard_Transient)& val);
54   
55   //! Removes an attribute
56   //! Returns True when done, False if this attribute did not exist
57   Standard_EXPORT Standard_Boolean RemoveAttribute (const Standard_CString name);
58   
59   //! Returns an attribute from its name, filtered by a type
60   //! If no attribute has this name, or if it is not kind of this
61   //! type, <val> is Null and returned value is False
62   //! Else, it is True
63   Standard_EXPORT Standard_Boolean GetAttribute (const Standard_CString name, const Handle(Standard_Type)& type, Handle(Standard_Transient)& val) const;
64   
65   //! Returns an attribute from its name. Null Handle if not
66   //! recorded         (whatever Transient, Integer, Real ...)
67   //! Integer is recorded as IntVal
68   //! Real is recorded as RealVal
69   //! Text is recorded as HAsciiString
70   Standard_EXPORT Handle(Standard_Transient) Attribute (const Standard_CString name) const;
71   
72   //! Returns the type of an attribute :
73   //! ValueInt , ValueReal , ValueText (String) , ValueIdent (any)
74   //! or ValueVoid (not recorded)
75   Standard_EXPORT MoniTool_ValueType AttributeType (const Standard_CString name) const;
76   
77   //! Adds an integer value for an attribute
78   Standard_EXPORT void SetIntegerAttribute (const Standard_CString name, const Standard_Integer val);
79   
80   //! Returns an attribute from its name, as integer
81   //! If no attribute has this name, or not an integer,
82   //! <val> is 0 and returned value is False
83   //! Else, it is True
84   Standard_EXPORT Standard_Boolean GetIntegerAttribute (const Standard_CString name, Standard_Integer& val) const;
85   
86   //! Returns an integer attribute from its name. 0 if not recorded
87   Standard_EXPORT Standard_Integer IntegerAttribute (const Standard_CString name) const;
88   
89   //! Adds a real value for an attribute
90   Standard_EXPORT void SetRealAttribute (const Standard_CString name, const Standard_Real val);
91   
92   //! Returns an attribute from its name, as real
93   //! If no attribute has this name, or not a real
94   //! <val> is 0.0 and returned value is False
95   //! Else, it is True
96   Standard_EXPORT Standard_Boolean GetRealAttribute (const Standard_CString name, Standard_Real& val) const;
97   
98   //! Returns a real attribute from its name. 0.0 if not recorded
99   Standard_EXPORT Standard_Real RealAttribute (const Standard_CString name) const;
100   
101   //! Adds a String value for an attribute
102   Standard_EXPORT void SetStringAttribute (const Standard_CString name, const Standard_CString val);
103   
104   //! Returns an attribute from its name, as String
105   //! If no attribute has this name, or not a String
106   //! <val> is 0.0 and returned value is False
107   //! Else, it is True
108   Standard_EXPORT Standard_Boolean GetStringAttribute (const Standard_CString name, Standard_CString& val) const;
109   
110   //! Returns a String attribute from its name. "" if not recorded
111   Standard_EXPORT Standard_CString StringAttribute (const Standard_CString name) const;
112   
113   //! Returns the exhaustive list of attributes
114   Standard_EXPORT const NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>& AttrList() const;
115   
116   //! Gets the list of attributes from <other>, as such, i.e.
117   //! not copied : attributes are shared, any attribute edited,
118   //! added, or removed in <other> is also in <me> and vice versa
119   //! The former list of attributes of <me> is dropped
120   Standard_EXPORT void SameAttributes (const MoniTool_AttrList& other);
121   
122   //! Gets the list of attributes from <other>, by copying it
123   //! By default, considers all the attributes from <other>
124   //! If <fromname> is given, considers only the attributes with
125   //! name beginning by <fromname>
126   //!
127   //! For each attribute, if <copied> is True (D), its value is also
128   //! copied if it is a basic type (Integer,Real,String), else it
129   //! remains shared between <other> and <me>
130   //!
131   //! These new attributes are added to the existing ones in <me>,
132   //! in case of same name, they replace the existing ones
133   Standard_EXPORT void GetAttributes (const MoniTool_AttrList& other, const Standard_CString fromname = "", const Standard_Boolean copied = Standard_True);
134
135
136
137
138 protected:
139
140
141
142
143
144 private:
145
146
147
148   NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> theattrib;
149
150
151 };
152
153
154
155
156
157
158
159 #endif // _MoniTool_AttrList_HeaderFile