occ
Loading...
Searching...
No Matches
occ::io::JsonCache Class Referenceabstract

Somewhere to keep expensive intermediate results (monomer energies, wavefunctions, solvation surfaces) as JSON documents, so a repeat calculation can skip them. More...

#include <json_cache.h>

Inheritance diagram for occ::io::JsonCache:
[legend]

Public Member Functions

virtual ~JsonCache ()=default
 
virtual std::optional< nlohmann::json > load (const std::string &key) const =0
 The document stored under key, or nothing if there is none.
 
virtual void store (const std::string &key, const nlohmann::json &doc)=0
 
virtual std::string location (const std::string &key) const =0
 Where key lives, for log messages: "file <key>" or "memory [<key>]".
 

Detailed Description

Somewhere to keep expensive intermediate results (monomer energies, wavefunctions, solvation surfaces) as JSON documents, so a repeat calculation can skip them.

A key names one document. The file backend uses it as the path, so the keys are the cache filenames the calculations have always written; the memory backend only needs them to be distinct. Checking that a cached document still matches the calculation (model, level of theory, ...) is the caller's job: the cache just stores what it is given.

Constructor & Destructor Documentation

◆ ~JsonCache()

virtual occ::io::JsonCache::~JsonCache ( )
virtualdefault

Member Function Documentation

◆ load()

virtual std::optional< nlohmann::json > occ::io::JsonCache::load ( const std::string &  key) const
pure virtual

The document stored under key, or nothing if there is none.

A document that exists but cannot be parsed is an error, not a miss.

Implemented in occ::io::FileJsonCache, and occ::io::MemoryJsonCache.

◆ location()

virtual std::string occ::io::JsonCache::location ( const std::string &  key) const
pure virtual

Where key lives, for log messages: "file <key>" or "memory [<key>]".

Implemented in occ::io::FileJsonCache, and occ::io::MemoryJsonCache.

◆ store()

virtual void occ::io::JsonCache::store ( const std::string &  key,
const nlohmann::json &  doc 
)
pure virtual

The documentation for this class was generated from the following file: