AcFileDepMgr.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2015 Autodesk, Inc. All rights reserved.
  4. //
  5. // Use of this software is subject to the terms of the Autodesk license
  6. // agreement provided at the time of installation or download, or which
  7. // otherwise accompanies this software in either electronic or hard copy form.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. //
  11. // DESCRIPTION: Definition for AcFileDependencyManager, for ARX
  12. // and AcFileDependencyInfo, return data class
  13. //
  14. #ifndef _ACFILEDEPMGR_H
  15. #define _ACFILEDEPMGR_H
  16. #pragma pack(push, 8)
  17. /////////////////////////////////////////////////////
  18. ///////////// Data class - FDL Entry ////////////////
  19. /////////////////////////////////////////////////////
  20. class AcFileDependencyInfo {
  21. public:
  22. const ACHAR *mpFullFileName;
  23. const ACHAR *mpFileName;
  24. const ACHAR *mpFoundPath;
  25. const ACHAR *mpFingerprintGuid;
  26. const ACHAR *mpVersionGuid;
  27. const ACHAR *mpFeature;
  28. bool mIsModified;
  29. bool mAffectsGraphics;
  30. Adesk::Int32 mIndex;
  31. Adesk::Int32 mTimeStamp;
  32. Adesk::Int32 mFileSize;
  33. Adesk::Int32 mReferenceCount;
  34. };
  35. class ADESK_NO_VTABLE AcFileDependencyManager {
  36. public:
  37. virtual ~AcFileDependencyManager() {};
  38. ///////////////////////////////////////////////
  39. ///////////// Entry Management ////////////////
  40. ///////////////////////////////////////////////
  41. // createEntry:
  42. // Returns new, permanent (life-of-entry), unique index for this Entry,
  43. // that an app or feature can store in place of the filename
  44. // fullFileName does not have to contain a full-qualified path.
  45. // If it contains only a base filename, FDL will follow a set of
  46. // rules for locating the file, and the foundPathname field will
  47. // be filled in with the file's actual path.
  48. // For non-AutoCAD (3rd party) feature types, this rule consists of
  49. // simply searching the AutoCAD support path, and the current .dwg's directory.
  50. // For XRefs (featurename="ACAD:XRef"), createEntry will retrieve
  51. // the .dwg's FingerPrint and Version GUIDs, and store them for
  52. // later retrieval.
  53. // noIncrement should only be set true if you are going thru and "updating"
  54. // your data, createEntry()s if they don't exist, but leaving them alone
  55. // if they do. setting it to true will stop the reference count from being
  56. // incremented if the record already exists. It will still return the existing
  57. // index for the matching record found.
  58. virtual Adesk::Int32 createEntry(const ACHAR *feature,
  59. const ACHAR *fullFileName,
  60. const bool affectsGraphics = false,
  61. const bool noIncrement = false) = 0;
  62. // For these next 6, caller should check for eKeyNotFound on return.
  63. // getEntry:
  64. // Returns an AcFileDependencyInfo class that contains
  65. // all the relevant data on this entry.
  66. // if usedCachedInfo is set to true, the file will NOT be checked
  67. // for a new time/size/guid, using the OS - instead the last cached
  68. // values for this and the isModified flag will be returned.
  69. // This is useful when the entry is being checked repeatedly, as
  70. // actually checking the file is a time-expensive operation.
  71. virtual Acad::ErrorStatus getEntry(const ACHAR *feature,
  72. const ACHAR *fullFileName,
  73. AcFileDependencyInfo *&fileInfo,
  74. const bool useCachedInfo = false) = 0;
  75. virtual Acad::ErrorStatus getEntry(const Adesk::Int32 index,
  76. AcFileDependencyInfo *&fileInfo,
  77. const bool useCachedInfo = false) = 0;
  78. // updateEntry:
  79. // Forces this entry to store new (current) time/size/guid info,
  80. // effectively "resetting" the isModified flag.
  81. // It's a shortcut for erasing/re-creating a new Entry.
  82. // This is the ONLY method that will stop an entry from continuing
  83. // to report "modified" after it has started to.
  84. virtual Acad::ErrorStatus updateEntry(const ACHAR *feature,
  85. const ACHAR *fullFileName) = 0;
  86. virtual Acad::ErrorStatus updateEntry(const Adesk::Int32 index) = 0;
  87. // eraseEntry:
  88. // Remove an entry (or just decrements it's reference count if
  89. // greater than 1, unless forceRemove is true.)
  90. virtual Acad::ErrorStatus eraseEntry(const ACHAR *feature,
  91. const ACHAR *fullFileName,
  92. const bool forceRemove=false) = 0;
  93. virtual Acad::ErrorStatus eraseEntry(const Adesk::Int32 index,
  94. const bool forceRemove=false) = 0;
  95. // Returns current count of FDL Entries
  96. virtual Adesk::Int32 countEntries() = 0;
  97. ///////////////////////////////////////////////
  98. /////////// Iteration /////////////////////
  99. ///////////////////////////////////////////////
  100. // Iteration initialization
  101. // If graphicsOnly is true, only entries that affects on-screen graphics
  102. // are returned.
  103. // If featurename == NULL, all features entries returned
  104. // If modified is true, returns only records that have changed since last save
  105. // (i.e. since the entry was written)
  106. // WalkXRefTree is a special flag that will attempt to walk the entire xref
  107. // tree by opening each Xref's FDL and pulling those records, all the way down.
  108. // Any entry anywhere in the tree will be included in the iteration list, if it
  109. // matches the feature, graphicsOnly, and modified only arguments.
  110. // Note that any Xrefs that do not have an FDL (i.e. AutoCAD 2002 and earlier formats)
  111. // will get no entries returned. (Obviously.)
  112. // So GC call will look like:
  113. // IteratorInitialize(NULL, true, true, true);
  114. // long needRegen = IteratorNext(); // non-zero index if at least one entry
  115. // or "while (index = IteratorNext())"
  116. // Note that entries will continue to report as "modified" until the next
  117. // save (i.e. records are recreated), unless an app/feature wishes to delete
  118. // and recreate its entries.
  119. virtual void iteratorInitialize(const ACHAR *feature = NULL,
  120. const bool modifiedOnly = false,
  121. const bool affectsGraphicsOnly = false,
  122. const bool walkXRefTree = false) = 0;
  123. // Returns the actual entries' index, call until 0.
  124. // Note that this only returns the entry's index, because some features
  125. // will use the Iterator only to determine if any records exist.
  126. // If you want the actual record, just plug the index returned into
  127. // getEntryByIndex().
  128. // When index returned is 0, we're all done.
  129. virtual Adesk::Int32 iteratorNext() = 0;
  130. };
  131. #pragma pack(pop)
  132. #endif