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 
00026 
00027 #ifdef HAVE_CONFIG_H
00028 #include <config.h>
00029 #endif
00030 
00055 class aflibData;
00056 class aflibMemNode;
00057 
00058 #include <map>
00059 using std::map;
00060 
00061 class aflibMemCache {
00062 
00063 public:
00064 
00065    aflibMemCache();
00066 
00067    virtual
00068    ~aflibMemCache();
00069 
00070    bool
00071    getCacheEnable();
00072 
00073    void
00074    setCacheEnable(bool enable);
00075 
00076    long long
00077    getCacheMax() const;
00078 
00079    long long
00080    getCacheTotal() const;
00081 
00082    long long
00083    getCacheLocal() const;
00084 
00085    void
00086    clearCache();
00087 
00088 protected:
00089 
00090    void
00091    lookupData(
00092       long long& position,
00093       int& num_samples);
00094 
00095    void
00096    fillDataFromCache(
00097       aflibData& data,
00098       long long& position,
00099       int& num_samples,
00100       long long orig_position,
00101       int orig_num_samples);
00102 
00103 private:
00104 
00105    aflibMemCache(aflibMemCache& op);
00106 
00107    const aflibMemCache&
00108    operator=(const aflibMemCache& op);
00109 
00110    void
00111    calcPosition(
00112       long long& position,
00113       int&       num_samples,
00114       map< long long, aflibMemNode* >::iterator it);
00115 
00116    void
00117    reduceCache();
00118 
00119    bool
00120    checkExistingNode(
00121       long long position,
00122       aflibData& data);
00123 
00124    void
00125    createNewNode(
00126       int start_element,
00127       int stop_element,
00128       long long position,
00129       aflibData& data); 
00130 
00131    void
00132    cacheData(
00133       long long position,
00134       aflibData& data);
00135 
00136 long long _cache_counter;
00137 long long _cache_size_max;
00138 static long long _cache_size_total;
00139 long long _cache_size_local;
00140 bool      _enable;
00141 map< long long, aflibMemNode* >  _node_array;
00142 
00143 
00144 };
00145 
00146 #endif
00147 
00148 

Generated on Sat Feb 23 13:56:37 2008 for Open Source Audio Library Project by  doxygen 1.5.1