CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
RxDictionary.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
3// All rights reserved.
4//
5// This software and its documentation and related materials are owned by
6// the Alliance. The software may only be incorporated into application
7// programs owned by members of the Alliance, subject to a signed
8// Membership Agreement and Supplemental Software License Agreement with the
9// Alliance. The structure and organization of this software are the valuable
10// trade secrets of the Alliance and its suppliers. The software is also
11// protected by copyright law and international treaty provisions. Application
12// programs incorporating this software must include the following statement
13// with their copyright notices:
14//
15// This application incorporates Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
18// All rights reserved.
19//
20// By use of this software, its documentation or related materials, you
21// acknowledge and accept the above terms.
23
24
25
26
27#ifndef _RXDICTIONARY_INC_
28#define _RXDICTIONARY_INC_
29
30
31#include "RxObject.h"
32#include "RxIterator.h"
33#include "RxDefs.h"
34#include "RxNames.h"
35
36class OdString;
37
38#include "TD_PackPush.h"
39
61{
62public:
64
71 virtual OdString getKey() const = 0;
72
79 virtual OdUInt32 id() const = 0;
80};
81
86
87
113class FIRSTDLL_EXPORT OdRxDictionary : public OdRxObject
114{
115public:
117
129 virtual void reserve(
130 OdUInt32 minSize);
131
148 const OdString& key) const = 0;
149
166 OdUInt32 id) const = 0;
167
187 const OdString& key,
188 OdRxObject* pObject,
189 OdUInt32* pRetId = 0) = 0;
190
209 OdUInt32 id,
210 OdRxObject* pObject) = 0;
211
227 virtual bool resetKey(
228 OdUInt32 id,
229 const OdString& newKey) = 0;
230
247 const OdString& key) = 0;
248
265 OdUInt32 id) = 0;
266
267 void removeAll() { OdUInt32 n = numEntries(); while(n--) remove(n); }
268
280 virtual bool has(
281 const OdString& key) const = 0;
282
294 virtual bool has(
295 OdUInt32 id) const = 0;
296
297
312 virtual OdUInt32 idAt(
313 const OdString& key) const = 0;
314
330 OdUInt32 id) const = 0;
331
341 virtual OdUInt32 numEntries() const = 0;
342
369
377 virtual bool isCaseSensitive() const = 0;
378
379 inline OdSmartPtr<OdRxDictionary> subDict(const OdString* path, int numSteps);
380};
381
387
388
393
394
404
405inline OdRxClass* odrxGetClassDesc(const OdString& className) {
406 return (OdRxClass*)(odrxClassDictionary()->getAt(className).get());
407}
408
409inline OdRxClass* odrxSafeGetClassDesc(const OdString& className) {
410 OdRxClass* cls = (OdRxClass*)(odrxClassDictionary()->getAt(className).get());
411 if (cls)
412 return cls;
413 throw OdError( className + OD_T( " class not registered" ) ); //FELIX_CHANGE
414}
415
416template <class TClass>
417inline OdSmartPtr<TClass> odrxCastByClassName(const OdRxObject* obj, const OdString& className) {
418 if(!obj || obj->isKindOf(odrxGetClassDesc(className)))
419 return (TClass*)obj;
420 return OdSmartPtr<TClass>();
421}
422
423template <class TClass>
424inline OdSmartPtr<TClass> odrxSafeCastByClassName(const OdRxObject* obj, const OdString& className) {
425 if(!obj || obj->isKindOf(odrxSafeGetClassDesc(className)))
426 return (TClass*)obj;
427 return OdSmartPtr<TClass>();
428}
429
434
435
441
442
448
449
450inline OdRxDictionaryPtr OdRxDictionary::subDict(const OdString* path, int numSteps) {
451 OdRxDictionaryPtr dir(this);
452 for (int i = 0; !dir.isNull() && i < numSteps; ++i)
453 dir = OdRxDictionary::cast(dir->getAt(path[i]));
454 return dir;
455}
456
457#include "TD_PackPop.h"
458
459#endif // _RXDICTIONARY_INC_
460
OdSmartPtr< OdRxDictionary > OdRxDictionaryPtr
Definition Gs.h:93
#define OD_T(x)
unsigned int OdUInt32
#define FIRSTDLL_EXPORT
Definition RootExport.h:39
FIRSTDLL_EXPORT OdRxDictionary * odrxSysRegistry()
OdSmartPtr< OdRxDictionaryIterator > OdRxDictionaryIteratorPtr
FIRSTDLL_EXPORT OdRxDictionaryPtr odrxServiceDictionary()
FIRSTDLL_EXPORT OdRxDictionaryPtr odrxClassDictionary()
OdRxClass * odrxGetClassDesc(const OdString &className)
OdSmartPtr< TClass > odrxSafeCastByClassName(const OdRxObject *obj, const OdString &className)
FIRSTDLL_EXPORT OdRxDictionaryPtr odrxCreateRxDictionary()
FIRSTDLL_EXPORT OdRxDictionaryPtr odrxCreateSyncRxDictionary()
OdRxClass * odrxSafeGetClassDesc(const OdString &className)
OdSmartPtr< OdRxDictionary > OdRxDictionaryPtr
OdSmartPtr< TClass > odrxCastByClassName(const OdRxObject *obj, const OdString &className)
bool isNull() const
virtual OdUInt32 idAt(const OdString &key) const =0
virtual OdRxObjectPtr getAt(OdUInt32 id) const =0
virtual OdRxObjectPtr remove(OdUInt32 id)=0
virtual OdRxObjectPtr getAt(const OdString &key) const =0
OdSmartPtr< OdRxDictionary > subDict(const OdString *path, int numSteps)
virtual OdRxObjectPtr putAt(OdUInt32 id, OdRxObject *pObject)=0
virtual OdRxObjectPtr remove(const OdString &key)=0
virtual bool isCaseSensitive() const =0
virtual OdUInt32 numEntries() const =0
virtual bool has(OdUInt32 id) const =0
ODRX_DECLARE_MEMBERS(OdRxDictionary)
virtual bool resetKey(OdUInt32 id, const OdString &newKey)=0
virtual OdRxDictionaryIteratorPtr newIterator(OdRx::DictIterType iterType=OdRx::kDictCollated)=0
virtual OdRxObjectPtr putAt(const OdString &key, OdRxObject *pObject, OdUInt32 *pRetId=0)=0
virtual bool has(const OdString &key) const =0
virtual void reserve(OdUInt32 minSize)
virtual OdString keyAt(OdUInt32 id) const =0
virtual OdUInt32 id() const =0
virtual OdString getKey() const =0
ODRX_DECLARE_MEMBERS(OdRxDictionaryIterator)
static OdRxObjectPtr cast(const OdRxObject *pointer)
Definition RxObject.h:640
bool isKindOf(const OdRxClass *pClass) const
Definition RxObject.h:1109
OdRxObject * get()
Definition RxObject.h:503
DictIterType
Definition RxDefs.h:38
@ kDictCollated
Definition RxDefs.h:40