PathfinderCache.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * PathfinderCache.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "PathfinderOptions.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class IGameInfoCallback;
  14. class CGHeroInstance;
  15. class PathfinderConfig;
  16. struct CPathsInfo;
  17. class DLL_LINKAGE PathfinderCache
  18. {
  19. const IGameInfoCallback * cb;
  20. std::mutex pathCacheMutex;
  21. std::map<const CGHeroInstance *, std::shared_ptr<CPathsInfo>> pathCache;
  22. PathfinderOptions options;
  23. std::shared_ptr<PathfinderConfig> createConfig(const CGHeroInstance *h, CPathsInfo &out);
  24. std::shared_ptr<CPathsInfo> buildPaths(const CGHeroInstance *h);
  25. public:
  26. PathfinderCache(const IGameInfoCallback * cb, const PathfinderOptions & options);
  27. /// Invalidates and erases all existing paths from the cache
  28. void invalidatePaths();
  29. /// Returns compute path information for requested hero
  30. std::shared_ptr<const CPathsInfo> getPathsInfo(const CGHeroInstance * h);
  31. };
  32. VCMI_LIB_NAMESPACE_END