chigraph  master
Systems programming language written for beginners in LLVM
ModuleCache.hpp
Go to the documentation of this file.
1 
3 #pragma once
4 
5 #ifndef CHI_MODULE_CACHE_HPP
6 #define CHI_MODULE_CACHE_HPP
7 
8 #include <chi/Fwd.hpp>
9 
10 #include <boost/filesystem/path.hpp>
11 #include <ctime>
12 
13 namespace chi {
14 
16 struct ModuleCache {
18  explicit ModuleCache(Context& ctx) : mContext{&ctx} {}
19 
21  virtual ~ModuleCache() = default;
22 
23  // No copy or move
24  ModuleCache(const ModuleCache&) = delete;
25  ModuleCache(ModuleCache&&) = delete;
26  ModuleCache& operator=(const ModuleCache&) = delete;
27  ModuleCache& operator=(ModuleCache&&) = delete;
28 
36  virtual Result cacheModule(const boost::filesystem::path& moduleName,
37  llvm::Module& compiledModule, std::time_t timeAtFileRead) = 0;
38 
42  virtual void invalidateCache(const boost::filesystem::path& moduleName) = 0;
43 
47  virtual std::time_t cacheUpdateTime(const boost::filesystem::path& moduleName) const = 0;
48 
54  virtual std::unique_ptr<llvm::Module> retrieveFromCache(
55  const boost::filesystem::path& moduleName, std::time_t atLeastThisNew) = 0;
56 
59  Context& context() const { return *mContext; }
60 
61 private:
62  Context* mContext;
63 };
64 
65 } // namespace chi
66 
67 #endif // CHI_MODULE_CACHE_HPP
ModuleCache(Context &ctx)
Create a module cache with a bound context.
Definition: ModuleCache.hpp:18
Forward declares all the chigraph data types.
virtual Result cacheModule(const boost::filesystem::path &moduleName, llvm::Module &compiledModule, std::time_t timeAtFileRead)=0
Cache a module.
The class that handles the loading, creation, storing, and compilation of modules It also stores a LL...
Definition: Context.hpp:55
virtual std::unique_ptr< llvm::Module > retrieveFromCache(const boost::filesystem::path &moduleName, std::time_t atLeastThisNew)=0
Retrieve a module from the cache.
virtual std::time_t cacheUpdateTime(const boost::filesystem::path &moduleName) const =0
Get the time that a cache was updated.
virtual ~ModuleCache()=default
Destructor.
This class provides an interface for creating module caches.
Definition: ModuleCache.hpp:16
Context & context() const
Get the context this cache is bound to.
Definition: ModuleCache.hpp:59
The namespace where chigraph lives.
The result object, used for identifiying errors with good diagnostics.
Definition: Result.hpp:72
virtual void invalidateCache(const boost::filesystem::path &moduleName)=0
Inavlidate the cache, ie.