OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
DapModule.cc
Go to the documentation of this file.
1 // DapModule.cc
2 
3 #include <iostream>
4 
5 using std::endl ;
6 
7 #include "DapModule.h"
8 #include "DapRequestHandler.h"
9 #include "DapResponseNames.h"
10 
11 #include <BESRequestHandlerList.h>
12 #include <BESDebug.h>
13 #include <BESResponseHandlerList.h>
14 #include <BESResponseNames.h>
17 #include <BESCatalogDirectory.h>
18 #include <BESCatalogList.h>
19 
20 #define DAP_CATALOG "catalog"
21 
22 void
23 DapModule::initialize( const string &modname )
24 {
25  BESDEBUG( modname, "Initializing Dap Module "
26  << modname << endl ) ;
27 
28  BESDEBUG( modname, " adding dap request handler" << endl ) ;
29  BESRequestHandlerList::TheList()->add_handler( modname, new DapRequestHandler( modname ) ) ;
30 
31  BESDEBUG( "nc", " adding " << DAP_CATALOG << " catalog" << endl ) ;
32  if( !BESCatalogList::TheCatalogList()->ref_catalog( DAP_CATALOG ) )
33  {
35  add_catalog( new BESCatalogDirectory( DAP_CATALOG ) ) ;
36  }
37  else
38  {
39  BESDEBUG( "nc", " catalog already exists, skipping" << endl ) ;
40  }
41 
42  BESDEBUG( "nc", " adding catalog container storage " << DAP_CATALOG
43  << endl ) ;
44  if( !BESContainerStorageList::TheList()->ref_persistence( DAP_CATALOG ) )
45  {
49  }
50  else
51  {
52  BESDEBUG( "nc", " storage already exists, skipping" << endl ) ;
53  }
54 
55  BESDEBUG( modname, " adding Dap debug context" << endl ) ;
56  BESDebug::Register( modname ) ;
57 
58  BESDEBUG( modname, "Done Initializing Dap Module "
59  << modname << endl ) ;
60 }
61 
62 void
63 DapModule::terminate( const string &modname )
64 {
65  BESDEBUG( modname, "Cleaning Dap module " << modname << endl ) ;
66 
67  BESRequestHandler *rh = 0 ;
68 
69  BESDEBUG( modname, " removing dap request handler" << endl ) ;
71  if( rh ) delete rh ; rh = 0 ;
72 
73  BESDEBUG( "nc", " removing catalog container storage"
74  << DAP_CATALOG << endl ) ;
76 
77  BESDEBUG( "nc", " removing " << DAP_CATALOG << " catalog" << endl ) ;
79 
80  BESDEBUG( modname, "Done Cleaning Dap module "
81  << modname << endl ) ;
82 }
83 
84 extern "C"
85 {
87  {
88  return new DapModule ;
89  }
90 }
91 
92 void
93 DapModule::dump( ostream &strm ) const
94 {
95  strm << BESIndent::LMarg << "DapModule::dump - ("
96  << (void *)this << ")" << endl ;
97 }
98 
virtual bool add_handler(const 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.
virtual void dump(ostream &strm) const
dump the contents of this object to the specified ostream
Definition: DapModule.cc:93
implementation of BESContainerStorage that represents a data within a catalog repository ...
virtual void terminate(const string &modname)
Definition: DapModule.cc:63
virtual bool deref_catalog(const string &catalog_name)
de-reference the specified catalog and remove from list if no longer referenced
builds catalogs from a directory structure
static ostream & LMarg(ostream &strm)
Definition: BESIndent.cc:73
virtual bool deref_persistence(const string &persist_name)
dereference a persistent store in the list.
Represents a specific data type request handler.
static BESRequestHandlerList * TheList()
static BESContainerStorageList * TheList()
BESAbstractModule * maker()
Definition: DapModule.cc:86
#define DAP_CATALOG
Definition: DapModule.cc:20
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
Definition: BESDebug.h:64
virtual void initialize(const string &modname)
Definition: DapModule.cc:23
static BESCatalogList * TheCatalogList()
returns the singleton BESCatalogList instance
static void Register(const string &flagName)
register the specified debug flag
Definition: BESDebug.h:138
virtual BESRequestHandler * remove_handler(const string &handler_name)
remove and return the specified request handler