BsProjectResourceMeta.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. /** Contains meta-data for a resource stored in the ProjectLibrary. */
  9. class BS_ED_EXPORT ProjectResourceMeta : public IReflectable
  10. {
  11. private:
  12. struct ConstructPrivately {};
  13. public:
  14. explicit ProjectResourceMeta(const ConstructPrivately&);
  15. /**
  16. * Creates a new project library resource meta-data entry.
  17. *
  18. * @param name Name of the resource, unique within the file containing the resource.
  19. * @param uuid UUID of the resource.
  20. * @param typeId RTTI type id of the resource.
  21. * @param resourceMetaData Non-project library specific meta-data.
  22. *
  23. * @return New project library resource meta data instance.
  24. */
  25. static ProjectResourceMetaPtr create(const WString& name, const String& uuid, UINT32 typeId,
  26. const ResourceMetaDataPtr& resourceMetaData);
  27. /** Returns the name of the resource, unique within the file containing the resource. */
  28. const WString& getUniqueName() const { return mName; }
  29. /** Returns the UUID of the resource this meta data belongs to. */
  30. const String& getUUID() const { return mUUID; }
  31. /** Returns the non-project library specific meta-data. */
  32. ResourceMetaDataPtr getResourceMetaData() const { return mResourceMeta; }
  33. /** Returns the RTTI type ID of the resource this object is referencing. */
  34. UINT32 getTypeID() const { return mTypeId; }
  35. private:
  36. friend class ProjectLibrary;
  37. WString mName;
  38. String mUUID;
  39. ResourceMetaDataPtr mResourceMeta;
  40. UINT32 mTypeId;
  41. /************************************************************************/
  42. /* RTTI */
  43. /************************************************************************/
  44. /**
  45. * @brief Creates a new empty meta-data instance. Used only for serialization purposes.
  46. */
  47. static ProjectResourceMetaPtr createEmpty();
  48. public:
  49. friend class ProjectResourceMetaRTTI;
  50. static RTTITypeBase* getRTTIStatic();
  51. virtual RTTITypeBase* getRTTI() const override;
  52. };
  53. /**
  54. * Contains meta-data for a file stored in the ProjectLibrary. A single file meta-data can contain one or multiple
  55. * ProjectResourceMeta instances.
  56. */
  57. class BS_ED_EXPORT ProjectFileMeta : public IReflectable
  58. {
  59. private:
  60. struct ConstructPrivately {};
  61. public:
  62. explicit ProjectFileMeta(const ConstructPrivately&);
  63. /**
  64. * Creates a new project library file meta-data entry.
  65. *
  66. * @param importOptions Import options used for importing the resource.
  67. *
  68. * @return New project library file meta data instance.
  69. */
  70. static ProjectFileMetaPtr create(const ImportOptionsPtr& importOptions);
  71. /** Registers a new resource in the file meta-data. */
  72. void add(const ProjectResourceMetaPtr& resourceMeta);
  73. /** Removes a resource with the specified UUID from the file meta-data. */
  74. void remove(const String& UUID);
  75. /** Returns meta-data for all resources contained in the file represented by this meta-data object. */
  76. const Vector<ProjectResourceMetaPtr>& getResourceMetaData() const { return mResourceMetaData; }
  77. /** Removes all resource meta-data stored by this object. */
  78. void clearResourceMetaData() { mResourceMetaData.clear(); }
  79. /** Returns the import options used for importing the resource this object is referencing. */
  80. const ImportOptionsPtr& getImportOptions() const { return mImportOptions; }
  81. /** Checks should this resource always be included in the build, regardless if it's being referenced or not. */
  82. bool getIncludeInBuild() const { return mIncludeInBuild; }
  83. /** Determines if this resource will always be included in the build, regardless if it's being referenced or not. */
  84. void setIncludeInBuild(bool include) { mIncludeInBuild = include; }
  85. /** Checks does the file contain a resource with the specified type id. */
  86. bool hasTypeId(UINT32 typeId) const;
  87. /** Checks does the file contain a resource with the specified UUID. */
  88. bool hasUUID(const String& uuid) const;
  89. private:
  90. friend class ProjectLibrary;
  91. Vector<ProjectResourceMetaPtr> mResourceMetaData;
  92. ImportOptionsPtr mImportOptions;
  93. bool mIncludeInBuild;
  94. /************************************************************************/
  95. /* RTTI */
  96. /************************************************************************/
  97. /**
  98. * @brief Creates a new empty meta-data instance. Used only for serialization purposes.
  99. */
  100. static ProjectFileMetaPtr createEmpty();
  101. public:
  102. friend class ProjectFileMetaRTTI;
  103. static RTTITypeBase* getRTTIStatic();
  104. virtual RTTITypeBase* getRTTI() const override;
  105. };
  106. }