BsUtility.h 1.5 KB

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