class Poco::JSON::TemplateCache

Overview

Use to cache parsed templates. More…

#include <TemplateCache.h>

class TemplateCache
{
public:
    // methods

    void
    addPath(const Path& path);

    Template::Ptr
    getTemplate(const Path& path);

    void
    setLogger(Logger& logger);

    static
    TemplateCache*
    instance();
};

Detailed Documentation

Use to cache parsed templates.

Templates are stored in a map with the full path as key. When a template file has changed, the cache will remove the old template from the cache and load a new one.

Construction

virtual
~TemplateCache()

Destroys the TemplateCache.

Methods

void
addPath(const Path& path)

Add a path for resolving template paths.

The order of check is FIFO.

Template::Ptr
getTemplate(const Path& path)

Returns a template from the cache.

When the template file is not yet loaded or when the file has changed, the template will be (re)loaded and parsed. A shared pointer is returned, so it is safe to use this template even when the template isn’t stored anymore in the cache.

void
setLogger(Logger& logger)

Sets the logger for the cache.

static
TemplateCache*
instance()

Returns the only instance of this cache.