comparison base/StorageAdviser.h @ 170:b23eea68357e

* flesh out StorageAdviser
author Chris Cannam
date Tue, 26 Sep 2006 12:58:12 +0000
parents 603991c63ff6
children 91fdc752e540
comparison
equal deleted inserted replaced
169:603991c63ff6 170:b23eea68357e
17 #define _STORAGE_ADVISER_H_ 17 #define _STORAGE_ADVISER_H_
18 18
19 /** 19 /**
20 * A utility class designed to help decide whether to store cache data 20 * A utility class designed to help decide whether to store cache data
21 * (for example FFT outputs) in memory or on disk in the TempDirectory. 21 * (for example FFT outputs) in memory or on disk in the TempDirectory.
22 * This is basically a compendium of simple rules of thumb.
22 */ 23 */
23 24
24 class StorageAdviser 25 class StorageAdviser
25 { 26 {
26 public: 27 public:
27 // pass to recommend() zero or more of these OR'd together 28 // pass to recommend() zero or more of these OR'd together
28 enum Criteria { 29 enum Criteria {
29 SpeedCritical = 1, 30 NoCriteria = 0,
30 PrecisionCritical = 2, 31 SpeedCritical = 1,
31 RepeatabilityUseful = 4 32 PrecisionCritical = 2,
33 LongRetentionLikely = 4,
34 FrequentLookupLikely = 8
32 }; 35 };
33 36
34 // recommend() returns one or two of these OR'd together 37 // recommend() returns one or two of these OR'd together
35 enum Recommendation { 38 enum Recommendation {
36 UseMemory = 1, 39 NoRecommendation = 0,
37 UseDisc = 2, 40 UseMemory = 1, // Disc is strongly contraindicated
38 ConserveSpace = 4, 41 PreferMemory = 2, // Either would do; memory probably better
39 UseAsMuchAsYouLike = 8 42 PreferDisc = 4, // Either would do; disc probably better
43 UseDisc = 8, // Probably won't fit in memory
44 ConserveSpace = 16,// Whatever you choose, keep it compact
45 UseAsMuchAsYouLike = 32 // Take my advice and there'll be space for all
40 }; 46 };
41
42 // May throw InsufficientDiscSpace exception if it looks like
43 // minimumSize won't fit on the disc.
44 47
45 /** 48 /**
46 * Recommend where to store some data, given certain storage and 49 * Recommend where to store some data, given certain storage and
47 * recall criteria. The minimum size is the approximate amount of 50 * recall criteria. The minimum size is the approximate amount of
48 * data in bytes that will be stored if the recommendation is to 51 * data in kilobytes that will be stored if the recommendation is
49 * ConserveSpace; the maximum size is approximately the amount 52 * to ConserveSpace; the maximum size is approximately the amount
50 * that will be used if UseAsMuchAsYouLike is returned. 53 * that will be used if UseAsMuchAsYouLike is returned.
51 **!!! sizes should be longer types 54 *
55 * May throw InsufficientDiscSpace exception if there appears to
56 * be nowhere the minimum amount of data can be stored.
52 */ 57 */
53 static Recommendation recommend(Criteria criteria, 58 static Recommendation recommend(Criteria criteria,
54 int minimumSize, 59 int minimumSize,
55 int maximumSize); 60 int maximumSize);
56 }; 61 };