zjf
2023-03-06 392b76515f40376b6d36f40a114850ef63650384
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
/////////////////////////////////////////////////////////////////////////////// 
// Copyright (C) 2002-2016, Open Design Alliance (the "Alliance"). 
// All rights reserved. 
// 
// This software and its documentation and related materials are owned by 
// the Alliance. The software may only be incorporated into application 
// programs owned by members of the Alliance, subject to a signed 
// Membership Agreement and Supplemental Software License Agreement with the
// Alliance. The structure and organization of this software are the valuable  
// trade secrets of the Alliance and its suppliers. The software is also 
// protected by copyright law and international treaty provisions. Application  
// programs incorporating this software must include the following statement 
// with their copyright notices:
//   
//   This application incorporates Teigha(R) software pursuant to a license 
//   agreement with Open Design Alliance.
//   Teigha(R) Copyright (C) 2002-2016 by Open Design Alliance. 
//   All rights reserved.
//
// By use of this software, its documentation or related materials, you 
// acknowledge and accept the above terms.
///////////////////////////////////////////////////////////////////////////////
 
 
 
 
#ifndef _ODDBDICTIONARY_INCLUDED_
#define _ODDBDICTIONARY_INCLUDED_
 
#include "TD_PackPush.h"
 
#include "RxIterator.h"
#include "RxDefs.h"
#include "DbObject.h"
 
class OdDbDictionaryImpl;
class OdDbObjectId;
class OdString;
 
/** \details
    This class implements Iterator objects that traverse entries in OdDbDictionary objects in an OdDbDatabase instance.
    
    Library: TD_Db
    
    \remarks
    An OdDbDictionaryIterator maintains a "current position" within the entries
    of the associated dictionary, and can provide access to the key value and object at the
    current position.
 
    <group OdDb_Classes>
*/
class TOOLKIT_EXPORT OdDbDictionaryIterator : public OdRxIterator
{
public:
  ODRX_DECLARE_MEMBERS(OdDbDictionaryIterator);
 
  virtual ~OdDbDictionaryIterator() {}
 
  /** \details
      Returns the name (key) of the dictionary entry currently referenced
      by this Iterator object.
  */
  virtual OdString name() const = 0;
 
  /** \details
      Opens the dictionary entry currently referenced by this Iterator object.    
 
      \param mode [in]  Mode in which to open the object.
 
      \remarks
      Returns a SmartPointer to the opened object.
  */
  virtual OdDbObjectPtr getObject(
    OdDb::OpenMode openMode = OdDb::kForRead) = 0;
 
  /** \details
      Returns the Object ID of the dictionary entry currently referenced by
      this Iterator object.
  */
  virtual OdDbObjectId objectId() const = 0;
 
  /** \details
      Sets the current position of this Iterator to the dictionary entry containing the
      specified ObjectId.
 
      \param objectId [in]  Object ID of item to which the current position will be set.
 
      \remarks
      Returns true if and only if the current position was set to the specified item.
  */
  virtual bool setPosition(
    OdDbObjectId objectId) = 0;
 
  /** \details
      Opens the dictionary entry currently referenced by this Iterator object in OdDb::kForRead mode.
 
      \remarks
      Returns a SmartPointer to the opened object.
  */
  virtual OdRxObjectPtr object() const;
 
protected:
  
  OdDbDictionaryIterator() {}
};
 
/** \details
  This template class is a specialization of the OdSmartPtr class for OdDbDictionaryIterator object pointers..
*/
typedef OdSmartPtr<OdDbDictionaryIterator> OdDbDictionaryIteratorPtr;
 
/** \details
    This class implements database -resident object dictionaries.
    
    \remarks
    
    * Each instance of OdDbDictionary is a single container object, in which
       entries are searched, added, modified, and deleted.  
    * Each OdDbDictionary entry associates a unique name (key) string with a unique OdDbObject.
    * Anonymous names are signified by specifying a name starting with an asterisk; e.g., *U. 
       A unique name (also starting with an asterisk) will be constructed for the entry.
    * Entry names honor the rules of Symbol names:
      * Names may be any length.
      * Names are case-insensitve.
      * Names may not contain any of the following characters: | * \ : ; < > ? " , equals.
 
    \sa
    OdDbDictionaryIterator
    
    Library: TD_Db
    
    <group OdDb_Classes>
*/
class TOOLKIT_EXPORT OdDbDictionary : public OdDbObject
{
  ODDB_DECLARE_MEMBERS(OdDbDictionary);
 
protected:
  OdDbDictionary();
 
public:
  /** \details
    Returns the OdDbObject associated with the specified name (key) in this Dictionary object.
 
    \param name [in]  Entry name.
    \param mode [in]  Mode in which to open the object.
    \param pStatus [out]  Receives eOk if successful, or an appropriate error code if not.
 
    \remarks
    Opens the associated OdDbObject in the specified mode.
    
    Returns a null SmartPointer or Object ID if the specified entry could not be opened.
  */
  OdDbObjectPtr getAt(
    const OdString& name, 
    OdDb::OpenMode mode) const;
 
  OdDbObjectId getAt(
    const OdString& name, 
    OdResult* pStatus = 0) const;
 
  /** \details
    Returns the entry name (key) of the specified object in this Dictionary object.
 
    \param objectId [in]  Object ID.
    
    \remarks
    Returns an empty string if objectId is not in this Dictionary object.
  */
  OdString nameAt(
    const OdDbObjectId& objectId) const;
 
  /** \details
    Returns true if and only if this Dictionary object has an entry with the specified name (key) or Object ID.
 
    \param name [in]  Entry name.
    \param objectId [in]  Object ID.
  */
  bool has(
    const OdString& name) const;
  bool has(
    const OdDbObjectId& objectId) const;
 
  /** \details
    Returns the number of entries in this Dictionary object.
  */
  OdUInt32 numEntries() const;
 
  /** \details
    Removes the entry with the specified name (key) or Object ID from this Dictionary object, and returns
    the Object ID of the removed entry.
 
    \param name [in]  Entry name.
    \param objectId [in]  Object ID.
    
    \note
    Only the dictionary entry is removed; the associated object remains in the database without an owner.
 
    The dictionary is removed as a persistent reactor on the associated object. 
  */
  OdDbObjectId remove(
    const OdString& name);
  void remove(
    const OdDbObjectId& objectId);
 
  /** \details
    Changes the name (key) of the specified entry in this Dictionary object.
 
    \param oldName [in]  Name of entry to change.
    \param newName [in]  New name for the entry.
 
    \remarks
    Returns true and only if the entry name was successfully changed.
  */
  bool setName(
    const OdString& oldName, 
    const OdString& newName);
 
  /** \details
    Sets the value for the specified entry in this Dictionary object.
 
    \remarks
    Returns the Object ID of the newly added entry.
    
    If an entry the specified name exists in the dictionary, it is
    erased, and a new entry created.
 
    If an entry for this name does not exist in this dictionary, 
    a new entry is created. 
 
    \param name [in]  Name of entry to be changed.
    \param newValue [in]  Database object to be added.
  */
  OdDbObjectId setAt(
    const OdString& name, 
    OdDbObject* newValue);
 
  /** \details
    Returns true if and only if this Dictionary object is the hard owner of its elements.
     
    \remarks
    Hard ownership protects the elements from purge. Soft ownership does not. 
  */
  bool isTreatElementsAsHard() const;
 
  /** \details
    Sets the hard ownership property for this Dictionary object.
 
    \param hard [in]  Controls ownership.
 
    \remarks
    Hard ownership protects the elements from purge. Soft ownership does not. 
  */
  void setTreatElementsAsHard(
    bool doIt);
 
  /** \details
    Returns a new interator that can be used to traverse the entries in this Dictionary object.
 
    \param iterType [in]  Type of Iterator.
 
    \remarks
    The Iterator type can be one of the following:
 
    <table>
    Name                      Description
    OdRx::kDictCollated       Traverses the entries in the order they were added to the dictionary.
    OdRx::kDictSorted         Traverses the entries in alphabetical order by key value.
    </table>
  */
  OdDbDictionaryIteratorPtr newIterator(
    OdRx::DictIterType iterType = OdRx::kDictCollated) const;
 
  enum 
  { 
    kMaxSuggestNameSize = 2049 
  };
  /** \details
    Returns a string suitable to be used as dictionary Key for this dictionary object.
    The string is unique for this dictionary object and is as close to file name as possible.
 
    \param strFilePath [in]  File path.
    \param nMaxLength [in]  Maximum length of name generated.
  */
  OdString suggestName(const OdString& strFilePath, const int nMaxLength = kMaxSuggestNameSize) const;
 
  virtual OdResult dwgInFields(
    OdDbDwgFiler* pFiler);
 
  virtual void dwgOutFields(
    OdDbDwgFiler* pFiler) const;
 
  virtual OdResult dxfInFields(
    OdDbDxfFiler* pFiler);
 
  virtual void dxfOutFields(
    OdDbDxfFiler* pFiler) const;
 
  /** \details
      Returns the merge style for this dictionary object.
  */
  virtual OdDb::DuplicateRecordCloning mergeStyle() const;
 
  /** \details
      Sets the merge style for this dictionary object.
      
      \param mergeStyle [in]  Merge style.
  */
  virtual void setMergeStyle(
    OdDb::DuplicateRecordCloning mergeStyle);
 
  virtual void goodbye(
    const OdDbObject* pObject);
 
  virtual void erased(
    const OdDbObject* pObject, 
    bool erasing = true);
 
  virtual OdResult subGetClassID(
    void* pClsid) const;
 
  virtual void applyPartialUndo(
    OdDbDwgFiler* pFiler,
    OdRxClass* pClass);
 
  virtual void subClose();
};
 
/** \details
  This template class is a specialization of the OdSmartPtr class for OdDbDictionary object pointers.
*/
typedef OdSmartPtr<OdDbDictionary> OdDbDictionaryPtr;
 
#include "TD_PackPop.h"
 
#endif