TemplateCache.h 727 B

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include "../../Include/RmlUi/Core/Types.h"
  3. namespace Rml {
  4. class Template;
  5. /**
  6. Manages requests for loading templates, caching as it goes.
  7. */
  8. class TemplateCache {
  9. public:
  10. /// Initialisation and Shutdown
  11. static bool Initialise();
  12. static void Shutdown();
  13. /// Load the named template from the given path, if its already loaded get the cached copy
  14. static Template* LoadTemplate(const String& path);
  15. /// Get the template by id
  16. static Template* GetTemplate(const String& id);
  17. /// Clear the template cache.
  18. static void Clear();
  19. private:
  20. TemplateCache();
  21. ~TemplateCache();
  22. using Templates = UnorderedMap<String, Template*>;
  23. Templates templates;
  24. Templates template_ids;
  25. };
  26. } // namespace Rml