StorageAdviser.h
Go to the documentation of this file.
1 
2 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
3 
4 /*
5  Sonic Visualiser
6  An audio file viewer and annotation editor.
7  Centre for Digital Music, Queen Mary, University of London.
8  This file copyright 2006 QMUL.
9 
10  This program is free software; you can redistribute it and/or
11  modify it under the terms of the GNU General Public License as
12  published by the Free Software Foundation; either version 2 of the
13  License, or (at your option) any later version. See the file
14  COPYING included with this distribution for more information.
15 */
16 
17 #ifndef SV_STORAGE_ADVISER_H
18 #define SV_STORAGE_ADVISER_H
19 
20 #include <cstdlib>
21 
22 #include <QString>
23 
31 {
32 public:
33  // pass to recommend() zero or more of these OR'd together
34  enum Criteria {
40  };
41 
42  // recommend() returns one or two of these OR'd together
45  UseMemory = 1, // Disc is strongly contraindicated
46  PreferMemory = 2, // Either would do; memory probably better
47  PreferDisc = 4, // Either would do; disc probably better
48  UseDisc = 8, // Probably won't fit in memory
49  ConserveSpace = 16,// Whatever you choose, keep it compact
50  UseAsMuchAsYouLike = 32 // Take my advice and there'll be space for all
51  };
52 
63  static Recommendation recommend(Criteria criteria,
64  size_t minimumSize,
65  size_t maximumSize);
66 
70  };
71 
76  static void notifyPlannedAllocation(AllocationArea area, size_t size);
77 
83  static void notifyDoneAllocation(AllocationArea area, size_t size);
84 
90  static void setFixedRecommendation(Recommendation recommendation);
91 
92 private:
93  static size_t m_discPlanned;
94  static size_t m_memoryPlanned;
96 
102  };
103 
104  static QString criteriaToString(int);
105  static QString recommendationToString(int);
106  static QString storageStatusToString(StorageStatus);
107 };
108 
109 #endif
110 
A utility class designed to help decide whether to store cache data (for example FFT outputs) in memo...
static Recommendation recommend(Criteria criteria, size_t minimumSize, size_t maximumSize)
Recommend where to store some data, given certain storage and recall criteria.
static QString criteriaToString(int)
static Recommendation m_baseRecommendation
static void notifyPlannedAllocation(AllocationArea area, size_t size)
Specify that we are planning to use a given amount of storage (in kilobytes), but haven&#39;t allocated i...
static void notifyDoneAllocation(AllocationArea area, size_t size)
Specify that we have now allocated, or abandoned the allocation of, the given amount (in kilobytes) o...
static void setFixedRecommendation(Recommendation recommendation)
Force all subsequent recommendations to use the (perhaps partial) specification given here...
static size_t m_discPlanned
static size_t m_memoryPlanned
static QString recommendationToString(int)
static QString storageStatusToString(StorageStatus)