2cd8ae84e006ebd8d7d78732a54079d931ba5179
[occt.git] / src / TDataStd / TDataStd_NamedData.hxx
1 // Created on: 2007-05-29
2 // Created by: Vlad Romashko
3 // Copyright (c) 2007-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _TDataStd_NamedData_HeaderFile
17 #define _TDataStd_NamedData_HeaderFile
18
19 #include <Standard.hxx>
20 #include <Standard_Type.hxx>
21
22 #include <TDF_Attribute.hxx>
23 #include <Standard_Boolean.hxx>
24 #include <Standard_Integer.hxx>
25 #include <TColStd_DataMapOfStringInteger.hxx>
26 #include <Standard_Real.hxx>
27 #include <TDataStd_DataMapOfStringReal.hxx>
28 #include <TDataStd_DataMapOfStringString.hxx>
29 #include <Standard_Byte.hxx>
30 #include <TDataStd_DataMapOfStringByte.hxx>
31 #include <TColStd_HArray1OfInteger.hxx>
32 #include <TDataStd_DataMapOfStringHArray1OfInteger.hxx>
33 #include <TColStd_HArray1OfReal.hxx>
34 #include <TDataStd_DataMapOfStringHArray1OfReal.hxx>
35 #include <Standard_OStream.hxx>
36 class TDataStd_HDataMapOfStringInteger;
37 class TDataStd_HDataMapOfStringReal;
38 class TDataStd_HDataMapOfStringString;
39 class TDataStd_HDataMapOfStringByte;
40 class TDataStd_HDataMapOfStringHArray1OfInteger;
41 class TDataStd_HDataMapOfStringHArray1OfReal;
42 class Standard_GUID;
43 class TDF_Label;
44 class TCollection_ExtendedString;
45 class TDF_Attribute;
46 class TDF_RelocationTable;
47
48
49 class TDataStd_NamedData;
50 DEFINE_STANDARD_HANDLE(TDataStd_NamedData, TDF_Attribute)
51
52 //! Contains a named data.
53 class TDataStd_NamedData : public TDF_Attribute
54 {
55
56 public:
57
58   
59   //! Static methods
60   //! ==============
61   //! Returns the ID of the named data attribute.
62   Standard_EXPORT static const Standard_GUID& GetID();
63   
64   //! Finds or creates a named data attribute.
65   Standard_EXPORT static Handle(TDataStd_NamedData) Set (const TDF_Label& label);
66   
67   Standard_EXPORT TDataStd_NamedData();
68   
69   //! Returns true if at least one named integer value is
70   //! kept in the attribute.
71     Standard_Boolean HasIntegers() const;
72   
73   //! Returns true if the attribute contains specified by Name
74   //! integer value.
75   Standard_EXPORT Standard_Boolean HasInteger (const TCollection_ExtendedString& theName) const;
76   
77   //! Returns the integer value specified by the Name.
78   //! It returns 0 if internal map doesn't contain the specified
79   //! integer (use HasInteger() to check before).
80   Standard_EXPORT Standard_Integer GetInteger (const TCollection_ExtendedString& theName);
81   
82   //! Defines a named integer.
83   //! If the integer already exists, it changes its value to <theInteger>.
84   Standard_EXPORT void SetInteger (const TCollection_ExtendedString& theName, const Standard_Integer theInteger);
85   
86   //! Returns the internal container of named integers.
87   Standard_EXPORT const TColStd_DataMapOfStringInteger& GetIntegersContainer();
88   
89   //! Replace the container content by new content of the <theIntegers>.
90   Standard_EXPORT void ChangeIntegers (const TColStd_DataMapOfStringInteger& theIntegers);
91   
92   //! Returns true if at least one named real value is
93   //! kept in the attribute.
94     Standard_Boolean HasReals() const;
95   
96   //! Returns true if the attribute contains a real specified by Name.
97   Standard_EXPORT Standard_Boolean HasReal (const TCollection_ExtendedString& theName) const;
98   
99   //! Returns the named real.
100   //! It returns 0.0 if there is no such a named real
101   //! (use HasReal()).
102   Standard_EXPORT Standard_Real GetReal (const TCollection_ExtendedString& theName);
103   
104   //! Defines a named real.
105   //! If the real already exists, it changes its value to <theReal>.
106   Standard_EXPORT void SetReal (const TCollection_ExtendedString& theName, const Standard_Real theReal);
107   
108   //! Returns the internal container of named reals.
109   Standard_EXPORT const TDataStd_DataMapOfStringReal& GetRealsContainer();
110   
111   //! Replace the container content by new content of the <theReals>.
112   Standard_EXPORT void ChangeReals (const TDataStd_DataMapOfStringReal& theReals);
113   
114   //! Returns true if there are some named strings in the attribute.
115     Standard_Boolean HasStrings() const;
116   
117   //! Returns true if the attribute contains this named string.
118   Standard_EXPORT Standard_Boolean HasString (const TCollection_ExtendedString& theName) const;
119   
120   //! Returns the named string.
121   //! It returns an empty string if there is no such a named string
122   //! (use HasString()).
123   Standard_EXPORT const TCollection_ExtendedString& GetString (const TCollection_ExtendedString& theName);
124   
125   //! Defines a named string.
126   //! If the string already exists, it changes its value to <theString>.
127   Standard_EXPORT void SetString (const TCollection_ExtendedString& theName, const TCollection_ExtendedString& theString);
128   
129   //! Returns the internal container of named strings.
130   Standard_EXPORT const TDataStd_DataMapOfStringString& GetStringsContainer();
131   
132   //! Replace the container content by new content of the <theStrings>.
133   Standard_EXPORT void ChangeStrings (const TDataStd_DataMapOfStringString& theStrings);
134   
135   //! Returns true if there are some named bytes in the attribute.
136     Standard_Boolean HasBytes() const;
137   
138   //! Returns true if the attribute contains this named byte.
139   Standard_EXPORT Standard_Boolean HasByte (const TCollection_ExtendedString& theName) const;
140   
141   //! Returns the named byte.
142   //! It returns 0 if there is no such a named byte
143   //! (use HasByte()).
144   Standard_EXPORT Standard_Byte GetByte (const TCollection_ExtendedString& theName);
145   
146   //! Defines a named byte.
147   //! If the byte already exists, it changes its value to <theByte>.
148   Standard_EXPORT void SetByte (const TCollection_ExtendedString& theName, const Standard_Byte theByte);
149   
150   //! Returns the internal container of named bytes.
151   Standard_EXPORT const TDataStd_DataMapOfStringByte& GetBytesContainer();
152   
153   //! Replace the container content by new content of the <theBytes>.
154   Standard_EXPORT void ChangeBytes (const TDataStd_DataMapOfStringByte& theBytes);
155   
156   //! Returns true if there are some named arrays of integer values in the attribute.
157     Standard_Boolean HasArraysOfIntegers() const;
158   
159   //! Returns true if the attribute contains this named array of integer values.
160   Standard_EXPORT Standard_Boolean HasArrayOfIntegers (const TCollection_ExtendedString& theName) const;
161   
162   //! Returns the named array of integer values.
163   //! It returns a NULL Handle if there is no such a named array of integers
164   //! (use HasArrayOfIntegers()).
165   Standard_EXPORT const Handle(TColStd_HArray1OfInteger)& GetArrayOfIntegers (const TCollection_ExtendedString& theName);
166   
167   //! Defines a named array of integer values.
168   //! If the array already exists, it changes its value to <theArrayOfIntegers>.
169   Standard_EXPORT void SetArrayOfIntegers (const TCollection_ExtendedString& theName, const Handle(TColStd_HArray1OfInteger)& theArrayOfIntegers);
170   
171   //! Returns the internal container of named arrays of integer values.
172   Standard_EXPORT const TDataStd_DataMapOfStringHArray1OfInteger& GetArraysOfIntegersContainer();
173   
174   //! Replace the container content by new content of the <theArraysOfIntegers>.
175   Standard_EXPORT void ChangeArraysOfIntegers (const TDataStd_DataMapOfStringHArray1OfInteger& theArraysOfIntegers);
176   
177   //! Returns true if there are some named arrays of real values in the attribute.
178     Standard_Boolean HasArraysOfReals() const;
179   
180   //! Returns true if the attribute contains this named array of real values.
181   Standard_EXPORT Standard_Boolean HasArrayOfReals (const TCollection_ExtendedString& theName) const;
182   
183   //! Returns the named array of real values.
184   //! It returns a NULL Handle if there is no such a named array of reals
185   //! (use HasArrayOfReals()).
186   Standard_EXPORT const Handle(TColStd_HArray1OfReal)& GetArrayOfReals (const TCollection_ExtendedString& theName);
187   
188   //! Defines a named array of real values.
189   //! If the array already exists, it changes its value to <theArrayOfReals>.
190   Standard_EXPORT void SetArrayOfReals (const TCollection_ExtendedString& theName, const Handle(TColStd_HArray1OfReal)& theArrayOfReals);
191   
192   //! Returns the internal container of named arrays of real values.
193   Standard_EXPORT const TDataStd_DataMapOfStringHArray1OfReal& GetArraysOfRealsContainer();
194   
195   //! Replace the container content by new content of the <theArraysOfReals>.
196   Standard_EXPORT void ChangeArraysOfReals (const TDataStd_DataMapOfStringHArray1OfReal& theArraysOfReals);
197   
198   Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
199   
200   Standard_EXPORT void Restore (const Handle(TDF_Attribute)& With) Standard_OVERRIDE;
201   
202   Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
203   
204   Standard_EXPORT void Paste (const Handle(TDF_Attribute)& Into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
205   
206   Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& anOS) const Standard_OVERRIDE;
207
208
209
210
211   DEFINE_STANDARD_RTTIEXT(TDataStd_NamedData,TDF_Attribute)
212
213 protected:
214
215
216
217
218 private:
219
220
221   Handle(TDataStd_HDataMapOfStringInteger) myIntegers;
222   Handle(TDataStd_HDataMapOfStringReal) myReals;
223   Handle(TDataStd_HDataMapOfStringString) myStrings;
224   Handle(TDataStd_HDataMapOfStringByte) myBytes;
225   Handle(TDataStd_HDataMapOfStringHArray1OfInteger) myArraysOfIntegers;
226   Handle(TDataStd_HDataMapOfStringHArray1OfReal) myArraysOfReals;
227
228
229 };
230
231
232 #include <TDataStd_NamedData.lxx>
233
234
235
236
237
238 #endif // _TDataStd_NamedData_HeaderFile