BsUtility.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsCorePrerequisites.h"
  5. namespace BansheeEngine
  6. {
  7. /** @addtogroup Utility-Core-Internal
  8. * @{
  9. */
  10. /** Contains information about a resource dependency, including the dependant resource and number of references to it. */
  11. struct ResourceDependency
  12. {
  13. ResourceDependency()
  14. :numReferences(0)
  15. { }
  16. HResource resource;
  17. UINT32 numReferences;
  18. };
  19. /** Static class containing various utility methods that do not fit anywhere else. */
  20. class BS_CORE_EXPORT Utility
  21. {
  22. public:
  23. /**
  24. * Finds all resources referenced by the specified object.
  25. *
  26. * @param[in] object Object to search for resource dependencies.
  27. * @param[in] recursive Determines whether or not child objects will also be searched (if the object has any
  28. * children).
  29. * @return A list of unique, non-null resources.
  30. */
  31. static Vector<ResourceDependency> findResourceDependencies(IReflectable& object, bool recursive = true);
  32. /** Calculates how deep in the scene object hierarchy is the provided object. Zero means root. */
  33. static UINT32 getSceneObjectDepth(const HSceneObject& so);
  34. private:
  35. /**
  36. * 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. * Checks if the specified type (or any of its derived classes) have any IReflectable pointer or value types as
  43. * their fields.
  44. */
  45. static bool hasReflectableChildren(RTTITypeBase* type);
  46. };
  47. /** @} */
  48. }