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