svcore  1.9
StorageAdviser.h
Go to the documentation of this file.
00001 
00002 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00003 
00004 /*
00005     Sonic Visualiser
00006     An audio file viewer and annotation editor.
00007     Centre for Digital Music, Queen Mary, University of London.
00008     This file copyright 2006 QMUL.
00009     
00010     This program is free software; you can redistribute it and/or
00011     modify it under the terms of the GNU General Public License as
00012     published by the Free Software Foundation; either version 2 of the
00013     License, or (at your option) any later version.  See the file
00014     COPYING included with this distribution for more information.
00015 */
00016 
00017 #ifndef _STORAGE_ADVISER_H_
00018 #define _STORAGE_ADVISER_H_
00019 
00026 class StorageAdviser
00027 {
00028 public:
00029     // pass to recommend() zero or more of these OR'd together
00030     enum Criteria {
00031         NoCriteria           = 0,
00032         SpeedCritical        = 1,
00033         PrecisionCritical    = 2,
00034         LongRetentionLikely  = 4,
00035         FrequentLookupLikely = 8
00036     };
00037 
00038     // recommend() returns one or two of these OR'd together
00039     enum Recommendation {
00040         NoRecommendation   = 0,
00041         UseMemory          = 1, // Disc is strongly contraindicated
00042         PreferMemory       = 2, // Either would do; memory probably better
00043         PreferDisc         = 4, // Either would do; disc probably better
00044         UseDisc            = 8, // Probably won't fit in memory
00045         ConserveSpace      = 16,// Whatever you choose, keep it compact
00046         UseAsMuchAsYouLike = 32 // Take my advice and there'll be space for all
00047     };
00048 
00059     static Recommendation recommend(Criteria criteria,
00060                                     int minimumSize,
00061                                     int maximumSize);
00062 
00063     enum AllocationArea {
00064         MemoryAllocation,
00065         DiscAllocation
00066     };
00067 
00072     static void notifyPlannedAllocation(AllocationArea area, int size);
00073 
00079     static void notifyDoneAllocation(AllocationArea area, int size);
00080 
00086     static void setFixedRecommendation(Recommendation recommendation);
00087 
00088 private:
00089     static long m_discPlanned;
00090     static long m_memoryPlanned;
00091     static Recommendation m_baseRecommendation;
00092 };
00093 
00094 #endif
00095