Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

aflibMemCache.h

Go to the documentation of this file.
00001 /*
00002  * Copyright: (C) 2000-2001 Bruce W. Forsberg
00003  *
00004  *   This library is free software; you can redistribute it and/or
00005  *   modify it under the terms of the GNU Lesser General Public
00006  *   License as published by the Free Software Foundation; either
00007  *   version 2.1 of the License, or any later version.
00008  *
00009  *   This library is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *   Lesser General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU Lesser General Public
00015  *   License along with this library; if not, write to the Free Software
00016  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00017  *
00018  *   Bruce Forsberg  forsberg@tns.net
00019  *
00020  */
00021 
00022 
00023 #ifndef _AFLIBMEMCACHE_H
00024 #define _AFLIBMEMCACHE_H
00025 
00050 class aflibData;
00051 class aflibMemNode;
00052 
00053 #include <map>
00054 #if __GNUC__ >= 3
00055 using std::map;
00056 #endif
00057 
00058 class aflibMemCache {
00059 
00060 public:
00061 
00062    aflibMemCache();
00063 
00064    virtual
00065    ~aflibMemCache();
00066 
00067    bool
00068    getCacheEnable();
00069 
00070    void
00071    setCacheEnable(bool enable);
00072 
00073    long long
00074    getCacheMax() const;
00075 
00076    long long
00077    getCacheTotal() const;
00078 
00079    long long
00080    getCacheLocal() const;
00081 
00082    void
00083    clearCache();
00084 
00085 protected:
00086 
00087    void
00088    lookupData(
00089       long long& position,
00090       int& num_samples);
00091 
00092    void
00093    fillDataFromCache(
00094       aflibData& data,
00095       long long& position,
00096       int& num_samples,
00097       long long orig_position,
00098       int orig_num_samples);
00099 
00100 private:
00101 
00102    aflibMemCache(aflibMemCache& op);
00103 
00104    const aflibMemCache&
00105    operator=(const aflibMemCache& op);
00106 
00107    void
00108    calcPosition(
00109       long long& position,
00110       int&       num_samples,
00111       map< long long, aflibMemNode* >::iterator it);
00112 
00113    void
00114    reduceCache();
00115 
00116    bool
00117    checkExistingNode(
00118       long long position,
00119       aflibData& data);
00120 
00121    void
00122    createNewNode(
00123       int start_element,
00124       int stop_element,
00125       long long position,
00126       aflibData& data); 
00127 
00128    void
00129    cacheData(
00130       long long position,
00131       aflibData& data);
00132 
00133 long long _cache_counter;
00134 long long _cache_size_max;
00135 static long long _cache_size_total;
00136 long long _cache_size_local;
00137 bool      _enable;
00138 map< long long, aflibMemNode* >  _node_array;
00139 
00140 
00141 };
00142 
00143 #endif
00144 
00145 

Generated at Tue Aug 7 22:18:06 2001 for Open Source Audio Library Project by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001