bes  Updated for version 3.20.6
DmrppMetadataStore.h
1 // -*- mode: c++; c-basic-offset:4 -*-
2 
3 // This file is part of Hyrax, A C++ implementation of the OPeNDAP Data
4 // Access Protocol.
5 
6 // Copyright (c) 2018 OPeNDAP, Inc.
7 // Author: James Gallagher <jgallagher@opendap.org>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 //
23 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24 
25 #ifndef _dmrpp_metadata_store_h
26 #define _dmrpp_metadata_store_h
27 
28 #include <string>
29 //#include <functional>
30 
31 #include "GlobalMetadataStore.h"
32 
33 //#include "DMRpp.h"
34 
35 namespace libdap {
36 class DMR;
37 }
38 
39 namespace dmrpp {
40 class DMRpp;
41 }
42 
43 namespace bes {
44 
84 private:
85  static bool d_enabled;
86  static DmrppMetadataStore *d_instance;
87 
88  // Called by atexit()
89  static void delete_instance() {
90  delete d_instance;
91  d_instance = 0;
92  }
93 
94  friend class DmrppMetadataStoreTest;
95 
96 protected:
98  struct StreamDMRpp : public StreamDAP {
99  StreamDMRpp(libdap::DMR *dmrpp) : StreamDAP(dmrpp) {}
100  // Use the DMR to write the DMR++ when the DMR has variables of the correct
101  // type. Look for this by checking the type of the object at runtime.
102  virtual void operator()(std::ostream &os);
103  };
104 
105  DmrppMetadataStore(const DmrppMetadataStore &src) : bes::GlobalMetadataStore(src) { }
106 
107  // Only get_instance() should be used to instantiate this class
109  DmrppMetadataStore(const std::string &cache_dir, const std::string &prefix, unsigned long long size) :
110  bes::GlobalMetadataStore(cache_dir, prefix, size) { }
111 
112 public:
113  static DmrppMetadataStore *get_instance(const std::string &cache_dir, const std::string &prefix, unsigned long long size);
114  static DmrppMetadataStore *get_instance();
115 
116  virtual ~DmrppMetadataStore()
117  {
118  }
119 
120  virtual bool add_responses(libdap::DMR *dmrpp, const std::string &name);
121  virtual bool add_dmrpp_response(libdap::DMR *dmrpp, const std::string &name);
122 
123  virtual libdap::DMR *get_dmr_object(const string &name);
124 
125  virtual dmrpp::DMRpp *get_dmrpp_object(const std::string &name);
126 };
127 
128 } // namespace bes
129 
130 #endif // _dmrpp_metadata_store_h
bes::DmrppMetadataStore::StreamDMRpp
Hack use a DMR to write a DMR++ response. WIP.
Definition: DmrppMetadataStore.h:98
StreamDAP
bes::DmrppMetadataStore::get_dmr_object
virtual libdap::DMR * get_dmr_object(const string &name)
Use the DMR response to build a DMR with Dmrpp Types.
Definition: DmrppMetadataStore.cc:242
libdap
Definition: BESDapFunctionResponseCache.h:35
bes::GlobalMetadataStore
Store the DAP metadata responses.
Definition: GlobalMetadataStore.h:89
bes::GlobalMetadataStore::GlobalMetadataStore
GlobalMetadataStore()
Definition: GlobalMetadataStore.cc:399
bes::DmrppMetadataStore::get_instance
static DmrppMetadataStore * get_instance()
Definition: DmrppMetadataStore.cc:137
bes::DmrppMetadataStore
Store the DAP DMR++ metadata responses.
Definition: DmrppMetadataStore.h:83
bes::DmrppMetadataStore::add_responses
virtual bool add_responses(libdap::DMR *dmrpp, const std::string &name)
Add the DAP4 metadata responses using a DMR.
Definition: DmrppMetadataStore.cc:196
dmrpp::DMRpp
Provide a way to print the DMR++ response.
Definition: DMRpp.h:42
bes::DmrppMetadataStore::get_dmrpp_object
virtual dmrpp::DMRpp * get_dmrpp_object(const std::string &name)
Build a DMR++ object from the cached Response.
Definition: DmrppMetadataStore.cc:274