CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
RxDictionary.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, 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-2022 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
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, bool createIfNotFound);
380
381 inline OdSmartPtr<OdRxDictionary> subDictCr(const OdString* path, int numSteps);
382};
383
389
390
395
396
406
407inline OdRxClass* odrxGetClassDesc(const OdString& className) {
408 return (OdRxClass*)(odrxClassDictionary()->getAt(className).get());
409}
410
411inline OdRxClass* odrxSafeGetClassDesc(const OdString& className) {
412 OdRxClass* cls = (OdRxClass*)(odrxClassDictionary()->getAt(className).get());
413 if (cls)
414 return cls;
415 throw OdError( className + OD_T( " class not registered" ) ); //FELIX_CHANGE
416}
417
418template <class TClass>
419inline OdSmartPtr<TClass> odrxCastByClassName(const OdRxObject* obj, const OdString& className) {
420 if(!obj || obj->isKindOf(odrxGetClassDesc(className)))
421 return (TClass*)obj;
422 return OdSmartPtr<TClass>();
423}
424
425template <class TClass>
426inline OdSmartPtr<TClass> odrxSafeCastByClassName(const OdRxObject* obj, const OdString& className) {
427 if(!obj || obj->isKindOf(odrxSafeGetClassDesc(className)))
428 return (TClass*)obj;
429 return OdSmartPtr<TClass>();
430}
431
436
437
443
444
450
451
452inline OdRxDictionaryPtr OdRxDictionary::subDict(const OdString* path, int numSteps, bool createIfNotFound) {
453 OdRxDictionaryPtr dir(this);
454 for(int i=0; dir.get() && i<numSteps; ++i)
455 dir = dir->getAt(path[i]);
456 return dir;
457}
458inline OdRxDictionaryPtr OdRxDictionary::subDictCr(const OdString* path, int numSteps) {
459 return subDict(path, numSteps, true);
460}
461
462#include "TD_PackPop.h"
463
464#endif // _RXDICTIONARY_INC_
465
#define OD_T(x)
unsigned int OdUInt32
#define FIRSTDLL_EXPORT
Definition: RootExport.h:39
FIRSTDLL_EXPORT OdRxDictionary * odrxSysRegistry()
OdSmartPtr< OdRxDictionaryIterator > OdRxDictionaryIteratorPtr
Definition: RxDictionary.h:85
FIRSTDLL_EXPORT OdRxDictionaryPtr odrxServiceDictionary()
FIRSTDLL_EXPORT OdRxDictionaryPtr odrxClassDictionary()
OdRxClass * odrxGetClassDesc(const OdString &className)
Definition: RxDictionary.h:407
OdSmartPtr< TClass > odrxSafeCastByClassName(const OdRxObject *obj, const OdString &className)
Definition: RxDictionary.h:426
FIRSTDLL_EXPORT OdRxDictionaryPtr odrxCreateRxDictionary()
FIRSTDLL_EXPORT OdRxDictionaryPtr odrxCreateSyncRxDictionary()
OdRxClass * odrxSafeGetClassDesc(const OdString &className)
Definition: RxDictionary.h:411
OdSmartPtr< OdRxDictionary > OdRxDictionaryPtr
Definition: RxDictionary.h:388
OdSmartPtr< TClass > odrxCastByClassName(const OdRxObject *obj, const OdString &className)
Definition: RxDictionary.h:419
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 > subDictCr(const OdString *path, int numSteps)
Definition: RxDictionary.h:458
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
OdSmartPtr< OdRxDictionary > subDict(const OdString *path, int numSteps, bool createIfNotFound)
Definition: RxDictionary.h:452
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)
bool isKindOf(const OdRxClass *pClass) const
Definition: RxObject.h:1104
OdRxObject * get()
Definition: RxObject.h:503
const T * get() const
Definition: SmartPtr.h:339
DictIterType
Definition: RxDefs.h:38
@ kDictCollated
Definition: RxDefs.h:40