bes  Updated for version 3.19.1
BESUncompressCache.h
1 // This file is part of bes, A C++ back-end server implementation framework
2 // for the OPeNDAP Data Access Protocol.
3 
4 // Copyright (c) 2015 OPeNDAP, Inc
5 // Author: Nathan Potter <npotter@opendap.org>
6 //
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Lesser General Public
9 // License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 //
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // Lesser General Public License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public
18 // License along with this library; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21 #ifndef DISPATCH_BESUNCOMPRESSCACHE_H_
22 #define DISPATCH_BESUNCOMPRESSCACHE_H_
23 
24 #include "BESFileLockingCache.h"
25 
27  friend class uncompressT;
28 private:
29  static bool d_enabled;
30  static BESUncompressCache * d_instance;
31  static void delete_instance()
32  {
33  delete d_instance;
34  d_instance = 0;
35  }
36 
37  string d_dimCacheDir;
38  string d_dataRootDir;
39  string d_dimCacheFilePrefix;
40  unsigned long d_maxCacheSize;
41 
44 
45  bool is_valid(const std::string &cache_file_name, const std::string &dataset_file_name);
46 
47  static string getCacheDirFromConfig();
48  static string getCachePrefixFromConfig();
49  static unsigned long getCacheSizeFromConfig();
50 
51 protected:
52 
53  BESUncompressCache(const string &data_root_dir, const string &cache_dir, const string &prefix,
54  unsigned long long size);
55 
56 public:
57  static const string DIR_KEY;
58  static const string PREFIX_KEY;
59  static const string SIZE_KEY;
60 
61  static BESUncompressCache *get_instance(const string &bes_catalog_root_dir, const string &cache_dir,
62  const string &prefix, unsigned long long size);
64 
65  virtual string get_cache_file_name(const string &src, bool mangle = true);
66 
67  virtual ~BESUncompressCache();
68 };
69 
70 #endif /* DISPATCH_BESUNCOMPRESSCACHE_H_ */
Implementation of a caching mechanism for compressed data.
virtual string get_cache_file_name(const string &src, bool mangle=true)
Build the name of file that will holds the uncompressed data from 'src' in the cache.
static BESUncompressCache * get_instance()