bes  Updated for version 3.20.6
FitsModule.cc
1 // FitsModule.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,2005 University Corporation for Atmospheric Research
7 // Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu>
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 University Corporation for Atmospheric Research at
24 // 3080 Center Green Drive, Boulder, CO 80301
25 
26 // (c) COPYRIGHT University Corporation for Atmostpheric Research 2004-2005
27 // Please read the full copyright statement in the file COPYRIGHT_UCAR.
28 //
29 // Authors:
30 // pwest Patrick West <pwest@ucar.edu>
31 // jgarcia Jose Garcia <jgarcia@ucar.edu>
32 
33 #include <iostream>
34 
35 using std::endl;
36 using std::ostream;
37 using std::string;
38 
39 #include "FitsModule.h"
40 #include <BESRequestHandlerList.h>
41 #include "FitsRequestHandler.h"
42 #include <BESDapService.h>
43 #include <BESDebug.h>
44 #include <BESContainerStorageList.h>
45 #include <BESFileContainerStorage.h>
46 #include <BESCatalogDirectory.h>
47 #include <BESCatalogList.h>
48 //#include "FitsResponseNames.h"
49 
50 #define FITS_CATALOG "catalog"
51 
52 void FitsModule::initialize(const string &modname)
53 {
54  BESDEBUG("fits", "Initializing Fits module " << modname << endl);
55 
56  BESRequestHandlerList::TheList()->add_handler(modname, new FitsRequestHandler(modname));
57 
59 
60  if (!BESCatalogList::TheCatalogList()->ref_catalog(FITS_CATALOG)) {
62  }
63  else {
64  BESDEBUG("fits", " catalog already exists, skipping" << endl);
65  }
66 
67  if (!BESContainerStorageList::TheList()->ref_persistence(FITS_CATALOG)) {
68  BESFileContainerStorage *csc = new BESFileContainerStorage(FITS_CATALOG);
69  BESContainerStorageList::TheList()->add_persistence(csc);
70  }
71  else {
72  BESDEBUG("fits", " storage already exists, skipping" << endl);
73  }
74 
75  BESDebug::Register("fits");
76 
77  BESDEBUG("fits", "Done Initializing Fits module " << modname << endl);
78 }
79 
80 void FitsModule::terminate(const string &modname)
81 {
82  BESDEBUG("fits", "Cleaning Fits module " << modname << endl);
83 
84  BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler(modname);
85  if (rh) delete rh;
86 
87  BESContainerStorageList::TheList()->deref_persistence(FITS_CATALOG);
88 
89  BESCatalogList::TheCatalogList()->deref_catalog(FITS_CATALOG);
90 
91  BESDEBUG("fits", "Done Cleaning Fits module " << modname << endl);
92 }
93 
100 void FitsModule::dump(ostream &strm) const
101 {
102  strm << BESIndent::LMarg << "FitsModule::dump - (" << (void *) this << ")" << endl;
103 }
104 
105 extern "C" {
106 BESAbstractModule *maker()
107 {
108  return new FitsModule;
109 }
110 }
111 
BESRequestHandler
Represents a specific data type request handler.
Definition: BESRequestHandler.h:74
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
FitsModule
Definition: FitsModule.h:38
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
FitsModule::dump
virtual void dump(std::ostream &strm) const
dumps information about this object
Definition: FitsModule.cc:100
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
FitsRequestHandler
Definition: FitsRequestHandler.h:38
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