BsProjectResourceMeta.h 5.0 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. /** @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 ProjectResourceMetaPtr create(const WString& name, const String& uuid, UINT32 typeId,
  28. const ResourceMetaDataPtr& 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. ResourceMetaDataPtr getResourceMetaData() const { return mResourceMeta; }
  35. /** Returns the RTTI type ID of the resource this object is referencing. */
  36. UINT32 getTypeID() const { return mTypeId; }
  37. private:
  38. friend class ProjectLibrary;
  39. WString mName;
  40. String mUUID;
  41. ResourceMetaDataPtr mResourceMeta;
  42. UINT32 mTypeId;
  43. /************************************************************************/
  44. /* RTTI */
  45. /************************************************************************/
  46. /** Creates a new empty meta-data instance. Used only for serialization purposes. */
  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[in] importOptions Import options used for importing the resource.
  67. * @return New project library file meta data instance.
  68. */
  69. static ProjectFileMetaPtr create(const ImportOptionsPtr& importOptions);
  70. /** Registers a new resource in the file meta-data. */
  71. void add(const ProjectResourceMetaPtr& resourceMeta);
  72. /** Removes a resource with the specified UUID from the file meta-data. */
  73. void remove(const String& UUID);
  74. /** Returns meta-data for all resources contained in the file represented by this meta-data object. */
  75. const Vector<ProjectResourceMetaPtr>& getResourceMetaData() const { return mResourceMetaData; }
  76. /** Removes all resource meta-data stored by this object. */
  77. void clearResourceMetaData() { mResourceMetaData.clear(); }
  78. /** Returns the import options used for importing the resource this object is referencing. */
  79. const ImportOptionsPtr& getImportOptions() const { return mImportOptions; }
  80. /** Checks should this resource always be included in the build, regardless if it's being referenced or not. */
  81. bool getIncludeInBuild() const { return mIncludeInBuild; }
  82. /** Determines if this resource will always be included in the build, regardless if it's being referenced or not. */
  83. void setIncludeInBuild(bool include) { mIncludeInBuild = include; }
  84. /** Checks does the file contain a resource with the specified type id. */
  85. bool hasTypeId(UINT32 typeId) const;
  86. /** Checks does the file contain a resource with the specified UUID. */
  87. bool hasUUID(const String& uuid) const;
  88. private:
  89. friend class ProjectLibrary;
  90. Vector<ProjectResourceMetaPtr> mResourceMetaData;
  91. ImportOptionsPtr mImportOptions;
  92. bool mIncludeInBuild;
  93. /************************************************************************/
  94. /* RTTI */
  95. /************************************************************************/
  96. /** Creates a new empty meta-data instance. Used only for serialization purposes. */
  97. static ProjectFileMetaPtr createEmpty();
  98. public:
  99. friend class ProjectFileMetaRTTI;
  100. static RTTITypeBase* getRTTIStatic();
  101. virtual RTTITypeBase* getRTTI() const override;
  102. };
  103. /** @} */
  104. }