dbdict.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. #ifndef AD_DBDICT_H
  2. #define AD_DBDICT_H
  3. //
  4. //
  5. //////////////////////////////////////////////////////////////////////////////
  6. //
  7. // Copyright 2015 Autodesk, Inc. All rights reserved.
  8. //
  9. // Use of this software is subject to the terms of the Autodesk license
  10. // agreement provided at the time of installation or download, or which
  11. // otherwise accompanies this software in either electronic or hard copy form.
  12. //
  13. //////////////////////////////////////////////////////////////////////////////
  14. //
  15. //
  16. // DESCRIPTION: Class header for AcDbDictionary, a database-resident
  17. // dictionary. A concerete API class whose implementation
  18. // can be inherited at runtime.
  19. //
  20. // An instance of this class represents a single
  21. // "Drawing Symbol Table"-like object, to which
  22. // AcDbObject instances can be added, accessed and
  23. // removed.
  24. //
  25. // Object pointers retrieved from the database represent
  26. // indivudual object are currently opened in the requested
  27. // mode.
  28. // The return status indicates the status for opening
  29. // the entry object. If the status is not AcDb::eOpenOK,
  30. // the returned pointer is NULL.
  31. //
  32. // CONTRACTS:
  33. // Objects added to an AcDbDictionary instance must not
  34. // have a presence in the database, i.e. they must have
  35. // null handles.
  36. //
  37. // Objects removed or replaced in the dictionary are
  38. // erased via AcDbObject::erase().
  39. //
  40. #include "dbmain.h"
  41. #pragma pack(push, 8)
  42. class AcDbImpDictionary;
  43. class AcString;
  44. class ADESK_NO_VTABLE AcDbDictionaryIterator: public AcRxObject
  45. //
  46. // This class allows one to sequentially retrieve the objects in
  47. // the dictionary, and keeps track of what the last object retrieved was.
  48. //
  49. // It is similar to AcRxDictionary Iterator, except the casting
  50. // of returned elements is stronger, and it has a member which
  51. // returns the status of the entry member when the attempt to
  52. // open it was made. If the status is Acad::ErrorStatus eOk, then
  53. // AcDbDictionaryIterator::getValue() will return a non-null
  54. // pointer, otherwise not.
  55. //
  56. {
  57. public:
  58. ACRX_DECLARE_MEMBERS(AcDbDictionaryIterator);
  59. virtual ~AcDbDictionaryIterator() {}
  60. virtual const ACHAR* name () const = 0;
  61. virtual Acad::ErrorStatus getObject (AcDbObject*& pObject,
  62. AcDb::OpenMode mode) = 0;
  63. virtual AcDbObjectId objectId () const = 0;
  64. virtual bool done () const = 0;
  65. virtual bool next () = 0;
  66. virtual bool setPosition(AcDbObjectId objId) = 0;
  67. protected:
  68. AcDbDictionaryIterator() {}
  69. };
  70. class AcDbDictionary: public AcDbObject
  71. {
  72. public:
  73. ACDB_DECLARE_MEMBERS(AcDbDictionary);
  74. AcDbDictionary();
  75. virtual ~AcDbDictionary();
  76. // Get an entry by name.
  77. //
  78. Acad::ErrorStatus getAt(const ACHAR* entryName,
  79. AcDbObject*& entryObj,
  80. AcDb::OpenMode mode) const;
  81. Acad::ErrorStatus getAt(const ACHAR* entryName,
  82. AcDbObjectId& entryObj) const;
  83. // Find name corresponding to object id.
  84. //
  85. Acad::ErrorStatus nameAt(AcDbObjectId objId,
  86. ACHAR*& name) const;
  87. Acad::ErrorStatus nameAt(AcDbObjectId objId,
  88. AcString & name) const;
  89. // Query contents of dictionary
  90. //
  91. bool has (const ACHAR* entryName) const;
  92. bool has (AcDbObjectId objId) const;
  93. Adesk::UInt32 numEntries() const;
  94. // Remove entries.
  95. //
  96. Acad::ErrorStatus remove(const ACHAR * key);
  97. Acad::ErrorStatus remove(const ACHAR * key,
  98. AcDbObjectId& returnId);
  99. Acad::ErrorStatus remove(AcDbObjectId objId);
  100. // Reset an entry.
  101. //
  102. bool setName(const ACHAR* oldName,
  103. const ACHAR* newName);
  104. Acad::ErrorStatus setAt (const ACHAR* srchKey,
  105. AcDbObject* newValue,
  106. AcDbObjectId& retObjId);
  107. // Test/Set treatment of elements.
  108. //
  109. bool isTreatElementsAsHard () const;
  110. void setTreatElementsAsHard(bool doIt);
  111. // Get an iterator for this dictionary.
  112. //
  113. AcDbDictionaryIterator* newIterator() const;
  114. // AcDbObject Protocol
  115. //
  116. virtual Acad::ErrorStatus subErase (Adesk::Boolean pErasing
  117. = Adesk::kTrue);
  118. virtual Acad::ErrorStatus dwgInFields (AcDbDwgFiler* pFiler);
  119. virtual Acad::ErrorStatus dwgOutFields (AcDbDwgFiler* pFiler) const;
  120. virtual Acad::ErrorStatus dxfInFields (AcDbDxfFiler* pFiler);
  121. virtual Acad::ErrorStatus dxfOutFields (AcDbDxfFiler* pFiler) const;
  122. virtual AcDb::DuplicateRecordCloning mergeStyle() const;
  123. virtual void setMergeStyle(AcDb::DuplicateRecordCloning style);
  124. // Support for persistant reactor to annotation.
  125. //
  126. virtual void goodbye(const AcDbObject* pObject);
  127. virtual void erased (const AcDbObject* pObject,
  128. Adesk::Boolean pErasing = Adesk::kTrue);
  129. // Support for saving to previous releases' formats.
  130. //
  131. virtual Acad::ErrorStatus decomposeForSave(
  132. AcDb::AcDbDwgVersion ver,
  133. AcDbObject*& replaceObj,
  134. AcDbObjectId& replaceId,
  135. Adesk::Boolean& exchangeXData);
  136. protected:
  137. virtual Acad::ErrorStatus subGetClassID(CLSID* pClsid) const;
  138. };
  139. #pragma pack(pop)
  140. #endif