0027961: Visualization - remove unused and no more working OpenGl_AVIWriter
[occt.git] / src / Dico / Dico_DictionaryOfInteger.hxx
1 // Created on: 1992-07-28
2 // Created by: Christian CAILLET
3 // Copyright (c) 1992-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 _Dico_DictionaryOfInteger_HeaderFile
18 #define _Dico_DictionaryOfInteger_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <Standard_Character.hxx>
24 #include <Standard_Integer.hxx>
25 #include <MMgt_TShared.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <Standard_CString.hxx>
28 #include <Standard_Size.hxx>
29 class Standard_NoSuchObject;
30 class Dico_IteratorOfDictionaryOfInteger;
31 class Dico_StackItemOfDictionaryOfInteger;
32 class TCollection_AsciiString;
33
34
35 class Dico_DictionaryOfInteger;
36 DEFINE_STANDARD_HANDLE(Dico_DictionaryOfInteger, MMgt_TShared)
37
38
39 class Dico_DictionaryOfInteger : public MMgt_TShared
40 {
41
42 public:
43
44   
45   //! Creates a Dictionary cell.
46   //! A Dictionary is always created then handled by its first cell
47   //! After creating a Dictionary, user can call methods HasItem,
48   //! Item, SetItem ... (internal cells and entries are also
49   //! defined as objects from the same class)
50   //! Also iteration can be made, by an Iterator on this Dictionary
51   Standard_EXPORT Dico_DictionaryOfInteger();
52   
53   //! Returns True if an Item is bound to a Name in the Dictionnary
54   //! <exact> : if True, commands exact matching
55   //! if False, accept completion, only if ONE AND ONLY ONE
56   //! Dictionnary Entry has <name> as beginning of its name
57   Standard_EXPORT Standard_Boolean HasItem (const Standard_CString name, const Standard_Boolean exact = Standard_False) const;
58   
59   //! Works as above method but accepts a String from TCollection
60   Standard_EXPORT Standard_Boolean HasItem (const TCollection_AsciiString& name, const Standard_Boolean exact = Standard_True) const;
61   
62   //! Returns item bound to a name in the Dictionnary
63   //! <exact> : same as for HasItem
64   Standard_EXPORT const Standard_Integer& Item (const Standard_CString name, const Standard_Boolean exact = Standard_True) const;
65   
66   //! Works as above method but accepts a String from TCollection
67   Standard_EXPORT const Standard_Integer& Item (const TCollection_AsciiString& name, const Standard_Boolean exact = Standard_True) const;
68   
69   //! Gathers HasItem and Item, in a less regular but faster way
70   //! If return is True, <anitem> is returned too, else it is not
71   //! <exact> : same as for HasItem
72   Standard_EXPORT Standard_Boolean GetItem (const Standard_CString name, Standard_Integer& anitem, const Standard_Boolean exact = Standard_True) const;
73   
74   //! Works as above method but accepts a String from TCollection
75   Standard_EXPORT Standard_Boolean GetItem (const TCollection_AsciiString& name, Standard_Integer& anitem, const Standard_Boolean exact = Standard_True) const;
76   
77   //! Binds an item to a dictionnary entry
78   //! If <name> is already known in the dictionary, its value
79   //! is changed. Else, the dictionary entry is created.
80   //! If <exact> is given False, completion is tried, it is accepted
81   //! If it gives a UNIQUE entry : hence this one will be modified
82   //! Else, new entry is created with the exact name given
83   Standard_EXPORT void SetItem (const Standard_CString name, const Standard_Integer& anitem, const Standard_Boolean exact = Standard_True);
84   
85   //! Works as above method but accepts a String from TCollection
86   Standard_EXPORT void SetItem (const TCollection_AsciiString& name, const Standard_Integer& anitem, const Standard_Boolean exact = Standard_True);
87   
88   //! Returns the Item AS AN ADDRESS which corresponds to a Name,
89   //! in order to be changed or set.
90   //! If this name is not yet recorded, the Dictionary creates it.
91   //! <isvalued> is returned True if the Item is recorded in the
92   //! Dictionary, False else, in that case the Item is reserved and
93   //! the name is noted as beeing valued now.
94   Standard_EXPORT Standard_Integer& NewItem (const Standard_CString name, Standard_Boolean& isvalued, const Standard_Boolean exact = Standard_True);
95   
96   //! Works as above method but accepts a String from TCollection
97   Standard_EXPORT Standard_Integer& NewItem (const TCollection_AsciiString& name, Standard_Boolean& isvalued, const Standard_Boolean exact = Standard_True);
98   
99   //! Removes a dictionary entry given by its name then Returns True
100   //! If the entry does not exists, Does nothing then Returns False
101   //! <exact> : as for HasItem, if completion works, the found entry
102   //! is removed (else returned value is False)
103   //! <cln> commands cleaning dictionary (to recover memory space)
104   //! For an isolated call, it is recommanded to give it at True
105   //! For a sequence of calls, rather give False, then call Clean
106   Standard_EXPORT Standard_Boolean RemoveItem (const Standard_CString name, const Standard_Boolean cln = Standard_True, const Standard_Boolean exact = Standard_True);
107   
108   //! Works as above method but accepts a String from TCollection
109   Standard_EXPORT Standard_Boolean RemoveItem (const TCollection_AsciiString& name, const Standard_Boolean cln = Standard_True, const Standard_Boolean exact = Standard_True);
110   
111   //! Deletes physically in one step the entries which were removed
112   //! (can be used for a more efficient Memory Management : first
113   //! Remove several Items (<cln> = False), then Clean the Memory)
114   Standard_EXPORT void Clean();
115   
116   //! Returns True if no Item is recorded
117   Standard_EXPORT Standard_Boolean IsEmpty() const;
118   
119   //! Clears all the Dictionary : all recorded Items are removed
120   Standard_EXPORT void Clear();
121   
122   //! Copies the Dictionary as a Tree, without Copying the Items
123   Standard_EXPORT Handle(Dico_DictionaryOfInteger) Copy() const;
124   
125   //! Internal routine used for completion (returns True if success)
126   Standard_EXPORT Standard_Boolean Complete (Handle(Dico_DictionaryOfInteger)& acell) const;
127
128
129 friend class Dico_IteratorOfDictionaryOfInteger;
130
131
132   DEFINE_STANDARD_RTTI_INLINE(Dico_DictionaryOfInteger,MMgt_TShared)
133
134 protected:
135
136
137
138
139 private:
140
141   
142   //! Defines cell's character (internal use, to build dict. tree)
143   Standard_EXPORT void SetChar (const Standard_Character car);
144   
145   //! Returns True if this cell has a subcell
146   Standard_EXPORT Standard_Boolean HasSub() const;
147   
148   //! Returns subcell
149   Standard_EXPORT Handle(Dico_DictionaryOfInteger) Sub() const;
150   
151   //! Returns True if this cell has a next cell
152   Standard_EXPORT Standard_Boolean HasNext() const;
153   
154   //! Returns next cell
155   Standard_EXPORT Handle(Dico_DictionaryOfInteger) Next() const;
156   
157   //! Defines subcell
158   Standard_EXPORT void SetSub (const Handle(Dico_DictionaryOfInteger)& acell);
159   
160   //! Defines next cell
161   Standard_EXPORT void SetNext (const Handle(Dico_DictionaryOfInteger)& acell);
162   
163   //! Internal method used to get an entry from a given name
164   Standard_EXPORT void SearchCell (const Standard_CString name, const Standard_Size lmax, const Standard_Character car, const Standard_Size level, Handle(Dico_DictionaryOfInteger)& acell, Standard_Size& reslev, Standard_Integer& stat) const;
165   
166   //! Internal method used to create a new entry for a name
167   Standard_EXPORT void NewCell (const Standard_CString name, const Standard_Size namlen, Handle(Dico_DictionaryOfInteger)& acell, const Standard_Size reslev, const Standard_Integer stat);
168   
169   //! Returns True if a cell has an associated item value
170   Standard_EXPORT Standard_Boolean HasIt() const;
171   
172   //! Returns item value associated to a cell
173   Standard_EXPORT const Standard_Integer& It() const;
174   
175   //! Returns item address associated to a cell
176   Standard_EXPORT Standard_Integer& ItAdr();
177   
178   //! Binds an item value to a cell
179   Standard_EXPORT void SetIt (const Standard_Integer& anitem);
180   
181   //! Declares a cell as Valued : used by NewItem (when an Item
182   //! is created if it did not exist and is returned)
183   Standard_EXPORT void DeclIt();
184   
185   //! Removes item bound to a cell (cancels effect of DeclIt)
186   Standard_EXPORT void RemoveIt();
187   
188   //! Returns cell's character as a node feature
189   Standard_EXPORT Standard_Character CellChar() const;
190   
191   //! Performs Copy from an original <fromcell> to <me>
192   //! Called by Copy
193   Standard_EXPORT void GetCopied (const Handle(Dico_DictionaryOfInteger)& fromcell);
194
195   Standard_Character thecars[4];
196   Handle(Dico_DictionaryOfInteger) thesub;
197   Handle(Dico_DictionaryOfInteger) thenext;
198   Standard_Integer theitem;
199
200
201 };
202
203
204
205
206
207
208
209 #endif // _Dico_DictionaryOfInteger_HeaderFile