FMT 1.2.0
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMTYieldsCache.h
Go to the documentation of this file.
1/*
2Copyright (c) 2019 Gouvernement du Québec
3
4SPDX-License-Identifier: LiLiQ-R-1.1
5License-Filename: LICENSES/EN/LiLiQ-R11unicode.txt
6*/
7
8#ifndef FMTYIELDSCACHE_Hm_included
9#define FMTYIELDSCACHE_Hm_included
10
11
12#include <boost/unordered/concurrent_flat_map.hpp>
13#include <boost/dynamic_bitset.hpp>
14#include <memory>
15#include <string>
16#include "FMTutility.h"
17
18namespace Core
19 {
20 class FMTDevelopment;
21 class FMTYieldDevelopment;
22 class FMTYieldRequest;
23 // DocString: FMTYieldsCache
28 {
29 public:
30 // DocString: FMTYieldsCache()
34 FMTYieldsCache()=default;
35 // DocString: FMTYieldsCache(const FMTYieldsCache&)
40 FMTYieldsCache(const FMTYieldsCache& rhs)=default;
41 // DocString: FMTYieldsCache::operator=
48 // DocString: ~FMTYieldsCache()
52 ~FMTYieldsCache() = default;
53 // DocString: FMTYieldsCache::inCache
60 bool inCache(const FMTYieldRequest& p_request,
61 const std::string& p_yield) const;
62 // DocString: FMTYieldsCache::get
69 double get(const FMTYieldRequest& p_request,
70 const std::string& p_yield) const;
71 // DocString: FMTYieldsCache::set
78 void set(double p_value,
79 const FMTYieldRequest& p_request,
80 const std::string& p_yield);
81 // DocString: FMTYieldsCache::reserve
86 void reserve(const FMTYieldRequest& p_request);
87 private:
88 static std::unique_ptr<boost::concurrent_flat_map<FMTYieldDevelopment,double>> m_cache;
89 // DocString: FMTYieldsCache::_getKey
96 FMTYieldDevelopment _getKey(const FMTYieldRequest& p_request,
97 const std::string& p_yield) const;
98 // DocString: FMTYieldsCache::_clearIfTooBig
102 void _clearIfTooBig();
103 };
104 }
105
106
107
108#endif // FMTDATA_Hm_included
Development keyed by age, period, mask and yield, used to cache yield values.
Definition: FMTYieldDevelopment.h:23
Request for yield values using a development and optionally a graph vertex.
Definition: FMTYieldRequest.h:37
Cache of yield values keyed by development and yield name.
Definition: FMTYieldsCache.h:28
void set(double p_value, const FMTYieldRequest &p_request, const std::string &p_yield)
Cache a value for a request and yield.
double get(const FMTYieldRequest &p_request, const std::string &p_yield) const
Get the cached value for a request and yield.
void reserve(const FMTYieldRequest &p_request)
Reserve memory in the cache for a request.
FMTYieldsCache(const FMTYieldsCache &rhs)=default
Copy constructor for FMTYieldsCache.
FMTYieldsCache()=default
Default constructor for FMTYieldsCache.
~FMTYieldsCache()=default
Default destructor for FMTYieldsCache.
FMTYieldsCache & operator=(const FMTYieldsCache &rhs)=default
Copy assignment operator for FMTYieldsCache.
bool inCache(const FMTYieldRequest &p_request, const std::string &p_yield) const
Return true if the value for a request and yield is cached.
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTAction.h:34