annotate base/StorageAdviser.h @ 178:0e266fa2510f

* pthread_mutex -> QMutex
author Chris Cannam
date Thu, 05 Oct 2006 11:02:05 +0000
parents b23eea68357e
children 91fdc752e540
rev   line source
Chris@168 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@168 2
Chris@168 3 /*
Chris@168 4 Sonic Visualiser
Chris@168 5 An audio file viewer and annotation editor.
Chris@168 6 Centre for Digital Music, Queen Mary, University of London.
Chris@168 7 This file copyright 2006 Chris Cannam.
Chris@168 8
Chris@168 9 This program is free software; you can redistribute it and/or
Chris@168 10 modify it under the terms of the GNU General Public License as
Chris@168 11 published by the Free Software Foundation; either version 2 of the
Chris@168 12 License, or (at your option) any later version. See the file
Chris@168 13 COPYING included with this distribution for more information.
Chris@168 14 */
Chris@168 15
Chris@168 16 #ifndef _STORAGE_ADVISER_H_
Chris@168 17 #define _STORAGE_ADVISER_H_
Chris@168 18
Chris@168 19 /**
Chris@168 20 * A utility class designed to help decide whether to store cache data
Chris@168 21 * (for example FFT outputs) in memory or on disk in the TempDirectory.
Chris@170 22 * This is basically a compendium of simple rules of thumb.
Chris@168 23 */
Chris@168 24
Chris@168 25 class StorageAdviser
Chris@168 26 {
Chris@168 27 public:
Chris@168 28 // pass to recommend() zero or more of these OR'd together
Chris@168 29 enum Criteria {
Chris@170 30 NoCriteria = 0,
Chris@170 31 SpeedCritical = 1,
Chris@170 32 PrecisionCritical = 2,
Chris@170 33 LongRetentionLikely = 4,
Chris@170 34 FrequentLookupLikely = 8
Chris@168 35 };
Chris@168 36
Chris@168 37 // recommend() returns one or two of these OR'd together
Chris@168 38 enum Recommendation {
Chris@170 39 NoRecommendation = 0,
Chris@170 40 UseMemory = 1, // Disc is strongly contraindicated
Chris@170 41 PreferMemory = 2, // Either would do; memory probably better
Chris@170 42 PreferDisc = 4, // Either would do; disc probably better
Chris@170 43 UseDisc = 8, // Probably won't fit in memory
Chris@170 44 ConserveSpace = 16,// Whatever you choose, keep it compact
Chris@170 45 UseAsMuchAsYouLike = 32 // Take my advice and there'll be space for all
Chris@168 46 };
Chris@168 47
Chris@169 48 /**
Chris@169 49 * Recommend where to store some data, given certain storage and
Chris@169 50 * recall criteria. The minimum size is the approximate amount of
Chris@170 51 * data in kilobytes that will be stored if the recommendation is
Chris@170 52 * to ConserveSpace; the maximum size is approximately the amount
Chris@169 53 * that will be used if UseAsMuchAsYouLike is returned.
Chris@170 54 *
Chris@170 55 * May throw InsufficientDiscSpace exception if there appears to
Chris@170 56 * be nowhere the minimum amount of data can be stored.
Chris@169 57 */
Chris@168 58 static Recommendation recommend(Criteria criteria,
Chris@168 59 int minimumSize,
Chris@168 60 int maximumSize);
Chris@168 61 };
Chris@168 62
Chris@168 63 #endif
Chris@168 64