BsProjectResourceMeta.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsEditorPrerequisites.h"
  5. #include "Reflection/BsIReflectable.h"
  6. namespace bs
  7. {
  8. /** @addtogroup Library
  9. * @{
  10. */
  11. /** Contains meta-data for a resource stored in the ProjectLibrary. */
  12. class BS_ED_EXPORT ProjectResourceMeta : public IReflectable
  13. {
  14. private:
  15. struct ConstructPrivately {};
  16. public:
  17. explicit ProjectResourceMeta(const ConstructPrivately&);
  18. /**
  19. * Creates a new project library resource meta-data entry.
  20. *
  21. * @param[in] name Name of the resource, unique within the file containing the resource.
  22. * @param[in] uuid UUID of the resource.
  23. * @param[in] typeId RTTI type id of the resource.
  24. * @param[in] resourceMetaData Non-project library specific meta-data.
  25. * @return New project library resource meta data instance.
  26. */
  27. static SPtr<ProjectResourceMeta> create(const WString& name, const UUID& uuid, UINT32 typeId,
  28. const SPtr<ResourceMetaData>& resourceMetaData);
  29. /** Returns the name of the resource, unique within the file containing the resource. */
  30. const WString& getUniqueName() const { return mName; }
  31. /** Returns the UUID of the resource this meta data belongs to. */
  32. const UUID& getUUID() const { return mUUID; }
  33. /** Returns the non-project library specific meta-data. */
  34. SPtr<ResourceMetaData> getResourceMetaData() const { return mResourceMeta; }
  35. /** Returns the RTTI type ID of the resource this object is referencing. */
  36. UINT32 getTypeID() const { return mTypeId; }
  37. /**
  38. * Returns additional data attached to the resource meta by the user. This is non-specific data and can contain
  39. * anything the user requires.
  40. */
  41. SPtr<IReflectable> getUserData() const { return mUserData; }
  42. private:
  43. friend class ProjectLibrary;
  44. WString mName;
  45. UUID mUUID;
  46. SPtr<ResourceMetaData> mResourceMeta;
  47. UINT32 mTypeId;
  48. SPtr<IReflectable> mUserData;
  49. /************************************************************************/
  50. /* RTTI */
  51. /************************************************************************/
  52. /** Creates a new empty meta-data instance. Used only for serialization purposes. */
  53. static SPtr<ProjectResourceMeta> createEmpty();
  54. public:
  55. friend class ProjectResourceMetaRTTI;
  56. static RTTITypeBase* getRTTIStatic();
  57. RTTITypeBase* getRTTI() const override;
  58. };
  59. /**
  60. * Contains meta-data for a file stored in the ProjectLibrary. A single file meta-data can contain one or multiple
  61. * ProjectResourceMeta instances.
  62. */
  63. class BS_ED_EXPORT ProjectFileMeta : public IReflectable
  64. {
  65. private:
  66. struct ConstructPrivately {};
  67. public:
  68. explicit ProjectFileMeta(const ConstructPrivately&);
  69. /**
  70. * Creates a new project library file meta-data entry.
  71. *
  72. * @param[in] importOptions Import options used for importing the resource.
  73. * @return New project library file meta data instance.
  74. */
  75. static SPtr<ProjectFileMeta> create(const SPtr<ImportOptions>& importOptions);
  76. /** Registers a new resource in the file meta-data. */
  77. void add(const SPtr<ProjectResourceMeta>& resourceMeta);
  78. /**
  79. * Registers an inactive resource in the file meta-data. Inactive meta-data is stored for resources that used
  80. * to exist, but do not exist currently, in order to restore their handles if they get restored at a later date.
  81. */
  82. void addInactive(const SPtr<ProjectResourceMeta>& resourceMeta);
  83. /** Returns meta-data for all active resources contained in the file represented by this meta-data object. */
  84. const Vector<SPtr<ProjectResourceMeta>>& getResourceMetaData() const { return mResourceMetaData; }
  85. /**
  86. * Returns meta-data for all resources (both active and inactive) contained in the file represented by this
  87. * meta-data object.
  88. */
  89. Vector<SPtr<ProjectResourceMeta>> getAllResourceMetaData() const;
  90. /**
  91. * Removes all resource meta-data stored by this object. This includes meta-data for both active and inactive
  92. * resources.
  93. */
  94. void clearResourceMetaData() { mResourceMetaData.clear(); }
  95. /** Returns the import options used for importing the resource this object is referencing. */
  96. const SPtr<ImportOptions>& getImportOptions() const { return mImportOptions; }
  97. /** Checks should this resource always be included in the build, regardless if it's being referenced or not. */
  98. bool getIncludeInBuild() const { return mIncludeInBuild; }
  99. /** Determines if this resource will always be included in the build, regardless if it's being referenced or not. */
  100. void setIncludeInBuild(bool include) { mIncludeInBuild = include; }
  101. /** Checks does the file contain a resource with the specified type id. */
  102. bool hasTypeId(UINT32 typeId) const;
  103. /** Checks does the file contain a resource with the specified UUID. */
  104. bool hasUUID(const UUID& uuid) const;
  105. private:
  106. friend class ProjectLibrary;
  107. Vector<SPtr<ProjectResourceMeta>> mResourceMetaData;
  108. Vector<SPtr<ProjectResourceMeta>> mInactiveResourceMetaData;
  109. SPtr<ImportOptions> mImportOptions;
  110. bool mIncludeInBuild;
  111. /************************************************************************/
  112. /* RTTI */
  113. /************************************************************************/
  114. /** Creates a new empty meta-data instance. Used only for serialization purposes. */
  115. static SPtr<ProjectFileMeta> createEmpty();
  116. public:
  117. friend class ProjectFileMetaRTTI;
  118. static RTTITypeBase* getRTTIStatic();
  119. RTTITypeBase* getRTTI() const override;
  120. };
  121. /** @} */
  122. }