bes  Updated for version 3.20.6
CSVModule.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 "CSVRequestHandler.h"
55 #include "CSVModule.h"
56 
57 #define CSV_NAME "csv"
58 #define CSV_CATALOG "catalog"
59 
60 void CSVModule::initialize(const string &modname)
61 {
62  BESDEBUG("csv", "Initializing CSV Module: " << modname << endl);
63 
64  BESRequestHandlerList::TheList()->add_handler(modname, new CSVRequestHandler(modname));
65 
67 
68  if (!BESCatalogList::TheCatalogList()->ref_catalog(CSV_CATALOG)) {
70  }
71 
72  if (!BESContainerStorageList::TheList()->ref_persistence(CSV_CATALOG)) {
73  BESContainerStorageList::TheList()->add_persistence(new BESFileContainerStorage(CSV_CATALOG));
74  }
75 
76  BESDebug::Register("csv");
77 
78  BESDEBUG("csv", "Done Initializing CSV Handler: " << modname << endl);
79 }
80 
81 void CSVModule::terminate(const string &modname)
82 {
83  BESDEBUG("csv", "Cleaning CSV Module: " << modname << endl);
84 
85  BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
86  if (rh) delete rh;
87 
88  BESContainerStorageList::TheList()->deref_persistence(CSV_CATALOG);
89 
90  BESCatalogList::TheCatalogList()->deref_catalog(CSV_CATALOG);
91 
92  BESDEBUG("csv", "Done Cleaning CSV Module: " << modname << endl);
93 }
94 
95 extern "C" {
96 BESAbstractModule *maker()
97 {
98  return new CSVModule;
99 }
100 }
101 
102 void CSVModule::dump(ostream &strm) const
103 {
104  strm << BESIndent::LMarg << "CSVModule::dump - (" << (void *) this << ")" << endl;
105 }
106 
BESRequestHandler
Represents a specific data type request handler.
Definition: BESRequestHandler.h:74
CSVModule::dump
virtual void dump(std::ostream &strm) const
dump the contents of this object to the specified ostream
Definition: CSVModule.cc:102
BESRequestHandlerList::remove_handler
virtual BESRequestHandler * remove_handler(const std::string &handler_name)
remove and return the specified request handler
Definition: BESRequestHandlerList.cc:76
BESContainerStorageList::deref_persistence
virtual bool deref_persistence(const std::string &persist_name)
dereference a persistent store in the list.
Definition: BESContainerStorageList.cc:163
CSVModule
Definition: CSVModule.h:40
BESCatalogDirectory
Catalogs from a directory structure.
Definition: BESCatalogDirectory.h:52
BESAbstractModule
Definition: BESAbstractModule.h:40
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
BESFileContainerStorage
implementation of BESContainerStorage that represents a data within a catalog repository
Definition: BESFileContainerStorage.h:77
BESRequestHandlerList::add_handler
virtual bool add_handler(const std::string &handler_name, BESRequestHandler *handler)
add a request handler to the list of registered handlers for this server
Definition: BESRequestHandlerList.cc:54
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
CSVRequestHandler
Definition: CSVRequestHandler.h:40
BESDapService::handle_dap_service
static void handle_dap_service(const std::string &handler)
static function to register a handler to handle the dap services
Definition: BESDapService.cc:40