bes  Updated for version 3.20.6
CmrModule.cc
1 // CSVModule.cc
2 
3 // This file is part of bes, A C++ back-end server implementation framework
4 // for the OPeNDAP Data Access Protocol.
5 
6 // Copyright (c) 2004-2009 University Corporation for Atmospheric Research
7 // Author: Stephan Zednik <zednik@ucar.edu> and Patrick West <pwest@ucar.edu>
8 // and Jose Garcia <jgarcia@ucar.edu>
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 //
24 // You can contact University Corporation for Atmospheric Research at
25 // 3080 Center Green Drive, Boulder, CO 80301
26 
27 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
28 // Please read the full copyright statement in the file COPYRIGHT_UCAR.
29 //
30 // Authors:
31 // zednik Stephan Zednik <zednik@ucar.edu>
32 // pwest Patrick West <pwest@ucar.edu>
33 // jgarcia Jose Garcia <jgarcia@ucar.edu>
34 
35 #include <iostream>
36 
37 using std::endl;
38 using std::ostream;
39 using std::string;
40 
41 #include <BESRequestHandlerList.h>
42 #include <BESResponseHandlerList.h>
43 #include <BESResponseNames.h>
44 
45 #include <BESContainerStorageList.h>
46 #include <BESFileContainerStorage.h>
47 #include <BESCatalogDirectory.h>
48 #include <BESCatalogList.h>
49 #include <BESDapService.h>
50 
51 #include <BESLog.h>
52 #include <BESDebug.h>
53 
54 // #include "CmrRequestHandler.h"
55 #include "CmrNames.h"
56 #include "CmrModule.h"
57 #include "CmrCatalog.h"
58 #include "CmrContainerStorage.h"
59 
60 #define prolog std::string("CmrModule::").append(__func__).append("() - ")
61 
62 void CmrModule::initialize(const string &modname)
63 {
64  BESDebug::Register(MODULE);
65  BESDEBUG(MODULE, prolog << "Initializing CMR Module: " << modname << endl);
66  if (!BESCatalogList::TheCatalogList()->ref_catalog(CMR_CATALOG_NAME)) {
68  }
69 
70  if (!BESContainerStorageList::TheList()->ref_persistence(CMR_CATALOG_NAME)) {
71  BESContainerStorageList::TheList()->add_persistence(new cmr::CmrContainerStorage(CMR_CATALOG_NAME));
72  }
73 
74 
75  // BESDEBUG(modname, prolog << "Adding " << modname << " container storage" << endl);
76  // BESContainerStorageList::TheList()->add_persistence(new cmr::CmrContainerStorage(modname));
77 
78  BESDEBUG(MODULE, "Done Initializing CMR Handler: " << modname << endl);
79 }
80 
81 void CmrModule::terminate(const string &modname)
82 {
83  BESDEBUG(MODULE, prolog << "Cleaning CMR Module: " << modname << endl);
84 
85  //BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
86  //if (rh) delete rh;
87 
88  BESContainerStorageList::TheList()->deref_persistence(CMR_CATALOG_NAME);
89 
90  BESCatalogList::TheCatalogList()->deref_catalog(CMR_CATALOG_NAME);
91 
92  BESDEBUG(MODULE, prolog << "Done Cleaning CMR Module: " << modname << endl);
93 }
94 
95 extern "C" {
96 BESAbstractModule *maker()
97 {
98  return new CmrModule;
99 }
100 }
101 
102 void CmrModule::dump(ostream &strm) const
103 {
104  strm << BESIndent::LMarg << prolog << "(" << (void *) this << ")" << endl;
105 }
106 
cmr::CmrCatalog
builds catalogs from a directory structure
Definition: CmrCatalog.h:50
cmr::CmrContainerStorage
implementation of BESContainerStorageVolatile that represents a list of remote requests
Definition: CmrContainerStorage.h:49
BESContainerStorageList::deref_persistence
virtual bool deref_persistence(const std::string &persist_name)
dereference a persistent store in the list.
Definition: BESContainerStorageList.cc:163
CmrModule
Definition: CmrModule.h:40
BESAbstractModule
Definition: BESAbstractModule.h:40
CmrModule::dump
virtual void dump(std::ostream &strm) const
dump the contents of this object to the specified ostream
Definition: CmrModule.cc:102
BESContainerStorageList::add_persistence
virtual bool add_persistence(BESContainerStorage *p)
Add a persistent store to the list.
Definition: BESContainerStorageList.cc:81
BESCatalogList::TheCatalogList
static BESCatalogList * TheCatalogList()
Get the singleton BESCatalogList instance.
Definition: BESCatalogList.cc:81
BESDebug::Register
static void Register(const std::string &flagName)
register the specified debug flag
Definition: BESDebug.h:138
BESCatalogList::add_catalog
virtual bool add_catalog(BESCatalog *catalog)
adds the specified catalog to the list
Definition: BESCatalogList.cc:162