BsUtility.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. private:
  34. /**
  35. * Helper method for for recursion when finding resource dependencies.
  36. *
  37. * @see findDependencies
  38. */
  39. static void findResourceDependenciesInternal(IReflectable& object, bool recursive, Map<String, ResourceDependency>& dependencies);
  40. /**
  41. * Checks if the specified type (or any of its derived classes) have any IReflectable pointer or value types as
  42. * their fields.
  43. */
  44. static bool hasReflectableChildren(RTTITypeBase* type);
  45. };
  46. /** @} */
  47. /** @endcond */
  48. }