BsUtility.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. namespace BansheeEngine
  4. {
  5. /**
  6. * @brief Contains information about a resource dependency, including
  7. * the dependant resource and number of references to it.
  8. */
  9. struct ResourceDependency
  10. {
  11. ResourceDependency()
  12. :numReferences(0)
  13. { }
  14. HResource resource;
  15. UINT32 numReferences;
  16. };
  17. /**
  18. * @brief Static class containing various utility methods that do not
  19. * fit anywhere else.
  20. */
  21. class BS_CORE_EXPORT Utility
  22. {
  23. public:
  24. /**
  25. * @brief Finds all resources referenced by the specified object.
  26. *
  27. * @param object Object to search for resource dependencies.
  28. * @param recursive Determines whether or not child objects will also be
  29. * searched (if object has any children).
  30. *
  31. * @returns A list of unique, non-null resources.
  32. */
  33. static Vector<ResourceDependency> findResourceDependencies(IReflectable& object, bool recursive = true);
  34. private:
  35. /**
  36. * @brief Helper method for for recursion when finding resource dependencies.
  37. *
  38. * @see findDependencies
  39. */
  40. static void findResourceDependenciesInternal(IReflectable& object, bool recursive, Map<String, ResourceDependency>& dependencies);
  41. /**
  42. * @brief Checks if the specified type (or any of its derived classes) have any IReflectable pointer or value
  43. * types as their fields.
  44. */
  45. static bool hasReflectableChildren(RTTITypeBase* type);
  46. };
  47. }