BsProjectResourceMeta.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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 "BsIReflectable.h"
  6. namespace BansheeEngine
  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 String& 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 String& 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. String 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. /** Removes a resource with the specified UUID from the file meta-data. */
  79. void remove(const String& UUID);
  80. /** Returns meta-data for all resources contained in the file represented by this meta-data object. */
  81. const Vector<SPtr<ProjectResourceMeta>>& getResourceMetaData() const { return mResourceMetaData; }
  82. /** Removes all resource meta-data stored by this object. */
  83. void clearResourceMetaData() { mResourceMetaData.clear(); }
  84. /** Returns the import options used for importing the resource this object is referencing. */
  85. const SPtr<ImportOptions>& getImportOptions() const { return mImportOptions; }
  86. /** Checks should this resource always be included in the build, regardless if it's being referenced or not. */
  87. bool getIncludeInBuild() const { return mIncludeInBuild; }
  88. /** Determines if this resource will always be included in the build, regardless if it's being referenced or not. */
  89. void setIncludeInBuild(bool include) { mIncludeInBuild = include; }
  90. /** Checks does the file contain a resource with the specified type id. */
  91. bool hasTypeId(UINT32 typeId) const;
  92. /** Checks does the file contain a resource with the specified UUID. */
  93. bool hasUUID(const String& uuid) const;
  94. private:
  95. friend class ProjectLibrary;
  96. Vector<SPtr<ProjectResourceMeta>> mResourceMetaData;
  97. SPtr<ImportOptions> mImportOptions;
  98. bool mIncludeInBuild;
  99. /************************************************************************/
  100. /* RTTI */
  101. /************************************************************************/
  102. /** Creates a new empty meta-data instance. Used only for serialization purposes. */
  103. static SPtr<ProjectFileMeta> createEmpty();
  104. public:
  105. friend class ProjectFileMetaRTTI;
  106. static RTTITypeBase* getRTTIStatic();
  107. RTTITypeBase* getRTTI() const override;
  108. };
  109. /** @} */
  110. }