bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
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
28class BESUncompressCache: public BESFileLockingCache {
29 friend class uncompressT;
30private:
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
44 BESUncompressCache();
45 BESUncompressCache(const BESUncompressCache &src);
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
53protected:
54
55 BESUncompressCache(const std::string &data_root_dir, const std::string &cache_dir, const std::string &prefix,
56 unsigned long long size);
57
58public:
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);
65 static BESUncompressCache *get_instance();
66
67 std::string get_cache_file_name(const std::string &src, bool mangle = true) override;
68
69 virtual ~BESUncompressCache();
70};
71
72#endif /* DISPATCH_BESUNCOMPRESSCACHE_H_ */
static BESUncompressCache * get_instance()
std::string get_cache_file_name(const std::string &src, bool mangle=true) override
Build the name of file that will holds the uncompressed data from 'src' in the cache.