bes  Updated for version 3.20.6
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 <string>
25 
26 #include "BESFileLockingCache.h"
27 
29  friend class uncompressT;
30 private:
31  static bool d_enabled;
32  static BESUncompressCache * d_instance;
33  static void delete_instance()
34  {
35  delete d_instance;
36  d_instance = 0;
37  }
38 
39  std::string d_dimCacheDir;
40  std::string d_dataRootDir;
41  std::string d_dimCacheFilePrefix;
42  unsigned long d_maxCacheSize;
43 
46 
47  bool is_valid(const std::string &cache_file_name, const std::string &dataset_file_name);
48 
49  static std::string getCacheDirFromConfig();
50  static std::string getCachePrefixFromConfig();
51  static unsigned long getCacheSizeFromConfig();
52 
53 protected:
54 
55  BESUncompressCache(const std::string &data_root_dir, const std::string &cache_dir, const std::string &prefix,
56  unsigned long long size);
57 
58 public:
59  static const std::string DIR_KEY;
60  static const std::string PREFIX_KEY;
61  static const std::string SIZE_KEY;
62 
63  static BESUncompressCache *get_instance(const std::string &bes_catalog_root_dir, const std::string &cache_dir,
64  const std::string &prefix, unsigned long long size);
66 
67  virtual std::string get_cache_file_name(const std::string &src, bool mangle = true);
68 
69  virtual ~BESUncompressCache();
70 };
71 
72 #endif /* DISPATCH_BESUNCOMPRESSCACHE_H_ */
BESUncompressCache
Definition: BESUncompressCache.h:28
BESUncompressCache::get_cache_file_name
virtual std::string get_cache_file_name(const std::string &src, bool mangle=true)
Build the name of file that will holds the uncompressed data from 'src' in the cache.
Definition: BESUncompressCache.cc:123
BESUncompressCache::get_instance
static BESUncompressCache * get_instance()
Definition: BESUncompressCache.cc:203
BESFileLockingCache
Implementation of a caching mechanism for compressed data.
Definition: BESFileLockingCache.h:85