svcore  1.9
StorageAdviser Class Reference

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. More...
 
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. More...
 
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. More...
 
static void setFixedRecommendation (Recommendation recommendation)
 Force all subsequent recommendations to use the (perhaps partial) specification given here. More...
 

Static Private Attributes

static long m_discPlanned = 0
 
static long m_memoryPlanned = 0
 
static Recommendation m_baseRecommendation = StorageAdviser::NoRecommendation
 

Detailed Description

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.

Member Enumeration Documentation

◆ Criteria

Enumerator
NoCriteria 
SpeedCritical 
PrecisionCritical 
LongRetentionLikely 
FrequentLookupLikely 

Definition at line 30 of file StorageAdviser.h.

◆ Recommendation

Enumerator
NoRecommendation 
UseMemory 
PreferMemory 
PreferDisc 
UseDisc 
ConserveSpace 
UseAsMuchAsYouLike 

Definition at line 39 of file StorageAdviser.h.

◆ AllocationArea

Enumerator
MemoryAllocation 
DiscAllocation 

Definition at line 63 of file StorageAdviser.h.

Member Function Documentation

◆ recommend()

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().

◆ notifyPlannedAllocation()

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.

◆ notifyDoneAllocation()

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.

◆ setFixedRecommendation()

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.

Member Data Documentation

◆ m_discPlanned

long StorageAdviser::m_discPlanned = 0
staticprivate

Definition at line 89 of file StorageAdviser.h.

Referenced by notifyDoneAllocation(), notifyPlannedAllocation(), and recommend().

◆ m_memoryPlanned

long StorageAdviser::m_memoryPlanned = 0
staticprivate

Definition at line 90 of file StorageAdviser.h.

Referenced by notifyDoneAllocation(), notifyPlannedAllocation(), and recommend().

◆ m_baseRecommendation

StorageAdviser::Recommendation StorageAdviser::m_baseRecommendation = StorageAdviser::NoRecommendation
staticprivate

Definition at line 91 of file StorageAdviser.h.

Referenced by recommend(), and setFixedRecommendation().


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