BsUtility.h 1.9 KB

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