svcore
1.9
|
A utility class designed to help decide whether to store cache data (for example FFT outputs) in memory or on disk in the TempDirectory. More...
#include <StorageAdviser.h>
Public Types | |
enum | Criteria { NoCriteria = 0, SpeedCritical = 1, PrecisionCritical = 2, LongRetentionLikely = 4, FrequentLookupLikely = 8 } |
enum | Recommendation { NoRecommendation = 0, UseMemory = 1, PreferMemory = 2, PreferDisc = 4, UseDisc = 8, ConserveSpace = 16, UseAsMuchAsYouLike = 32 } |
enum | AllocationArea { MemoryAllocation, DiscAllocation } |
Static Public Member Functions | |
static Recommendation | recommend (Criteria criteria, int minimumSize, int maximumSize) |
Recommend where to store some data, given certain storage and recall criteria. | |
static void | notifyPlannedAllocation (AllocationArea area, int size) |
Specify that we are planning to use a given amount of storage (in kilobytes), but haven't allocated it yet. | |
static void | notifyDoneAllocation (AllocationArea area, int size) |
Specify that we have now allocated, or abandoned the allocation of, the given amount (in kilobytes) of a storage area that was previously notified using notifyPlannedAllocation. | |
static void | setFixedRecommendation (Recommendation recommendation) |
Force all subsequent recommendations to use the (perhaps partial) specification given here. | |
Static Private Attributes | |
static long | m_discPlanned = 0 |
static long | m_memoryPlanned = 0 |
static Recommendation | m_baseRecommendation = StorageAdviser::NoRecommendation |
A utility class designed to help decide whether to store cache data (for example FFT outputs) in memory or on disk in the TempDirectory.
This is basically a compendium of simple rules of thumb.
Definition at line 26 of file StorageAdviser.h.
Definition at line 30 of file StorageAdviser.h.
NoRecommendation | |
UseMemory | |
PreferMemory | |
PreferDisc | |
UseDisc | |
ConserveSpace | |
UseAsMuchAsYouLike |
Definition at line 39 of file StorageAdviser.h.
Definition at line 63 of file StorageAdviser.h.
StorageAdviser::Recommendation StorageAdviser::recommend | ( | Criteria | criteria, |
int | minimumSize, | ||
int | maximumSize | ||
) | [static] |
Recommend where to store some data, given certain storage and recall criteria.
The minimum size is the approximate amount of data in kilobytes that will be stored if the recommendation is to ConserveSpace; the maximum size is approximately the amount that will be used if UseAsMuchAsYouLike is returned.
May throw InsufficientDiscSpace exception if there appears to be nowhere the minimum amount of data can be stored.
!! We have a potentially serious problem here if multiple
Definition at line 34 of file StorageAdviser.cpp.
References ConserveSpace, FrequentLookupLikely, GetDiscSpaceMBAvailable(), TempDirectory::getInstance(), TempDirectory::getPath(), GetRealMemoryMBAvailable(), LongRetentionLikely, m_baseRecommendation, m_discPlanned, m_memoryPlanned, NoRecommendation, PrecisionCritical, PreferDisc, PreferMemory, SpeedCritical, SVDEBUG, UseAsMuchAsYouLike, UseDisc, and UseMemory.
Referenced by FFTDataServer::getStorageAdvice().
void StorageAdviser::notifyPlannedAllocation | ( | AllocationArea | area, |
int | size | ||
) | [static] |
Specify that we are planning to use a given amount of storage (in kilobytes), but haven't allocated it yet.
Definition at line 188 of file StorageAdviser.cpp.
References DiscAllocation, m_discPlanned, m_memoryPlanned, and MemoryAllocation.
void StorageAdviser::notifyDoneAllocation | ( | AllocationArea | area, |
int | size | ||
) | [static] |
Specify that we have now allocated, or abandoned the allocation of, the given amount (in kilobytes) of a storage area that was previously notified using notifyPlannedAllocation.
Definition at line 197 of file StorageAdviser.cpp.
References DiscAllocation, m_discPlanned, m_memoryPlanned, and MemoryAllocation.
void StorageAdviser::setFixedRecommendation | ( | Recommendation | recommendation | ) | [static] |
Force all subsequent recommendations to use the (perhaps partial) specification given here.
If NoRecommendation given here, this will reset to the default free behaviour.
Definition at line 211 of file StorageAdviser.cpp.
References m_baseRecommendation.
long StorageAdviser::m_discPlanned = 0 [static, private] |
Definition at line 89 of file StorageAdviser.h.
Referenced by notifyDoneAllocation(), notifyPlannedAllocation(), and recommend().
long StorageAdviser::m_memoryPlanned = 0 [static, private] |
Definition at line 90 of file StorageAdviser.h.
Referenced by notifyDoneAllocation(), notifyPlannedAllocation(), and recommend().
StorageAdviser::Recommendation StorageAdviser::m_baseRecommendation = StorageAdviser::NoRecommendation [static, private] |
Definition at line 91 of file StorageAdviser.h.
Referenced by recommend(), and setFixedRecommendation().