OPeNDAP Hyrax Back End Server (BES) Updated for version 3.8.3
|
00001 // BESReturnManager.cc 00002 00003 // This file is part of bes, A C++ back-end server implementation framework 00004 // for the OPeNDAP Data Access Protocol. 00005 00006 // Copyright (c) 2004-2009 University Corporation for Atmospheric Research 00007 // Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu> 00008 // 00009 // This library is free software; you can redistribute it and/or 00010 // modify it under the terms of the GNU Lesser General Public 00011 // License as published by the Free Software Foundation; either 00012 // version 2.1 of the License, or (at your option) any later version. 00013 // 00014 // This library is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 // Lesser General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU Lesser General Public 00020 // License along with this library; if not, write to the Free Software 00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 // 00023 // You can contact University Corporation for Atmospheric Research at 00024 // 3080 Center Green Drive, Boulder, CO 80301 00025 00026 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005 00027 // Please read the full copyright statement in the file COPYRIGHT_UCAR. 00028 // 00029 // Authors: 00030 // pwest Patrick West <pwest@ucar.edu> 00031 // jgarcia Jose Garcia <jgarcia@ucar.edu> 00032 00033 #include "BESReturnManager.h" 00034 00035 BESReturnManager *BESReturnManager::_instance = 0 ; 00036 00037 BESReturnManager::BESReturnManager() 00038 { 00039 } 00040 00041 BESReturnManager::~BESReturnManager() 00042 { 00043 BESReturnManager::Transmitter_iter i ; 00044 BESTransmitter *t = 0 ; 00045 for( i = _transmitter_list.begin(); i != _transmitter_list.end(); i++ ) 00046 { 00047 t = (*i).second ; 00048 delete t ; 00049 } 00050 } 00051 00052 bool 00053 BESReturnManager::add_transmitter( const string &name, 00054 BESTransmitter *transmitter ) 00055 { 00056 if( find_transmitter( name ) == 0 ) 00057 { 00058 _transmitter_list[name] = transmitter ; 00059 return true ; 00060 } 00061 return false ; 00062 } 00063 00064 bool 00065 BESReturnManager::del_transmitter( const string &name ) 00066 { 00067 bool ret = false ; 00068 BESReturnManager::Transmitter_iter i ; 00069 i = _transmitter_list.find( name ) ; 00070 if( i != _transmitter_list.end() ) 00071 { 00072 BESTransmitter *obj = (*i).second; 00073 _transmitter_list.erase( i ) ; 00074 if( obj ) delete obj ; 00075 ret = true ; 00076 } 00077 return ret ; 00078 } 00079 00080 BESTransmitter * 00081 BESReturnManager::find_transmitter( const string &name ) 00082 { 00083 BESReturnManager::Transmitter_citer i ; 00084 i = _transmitter_list.find( name ) ; 00085 if( i != _transmitter_list.end() ) 00086 { 00087 return (*i).second; 00088 } 00089 return 0 ; 00090 } 00091 00099 void 00100 BESReturnManager::dump( ostream &strm ) const 00101 { 00102 strm << BESIndent::LMarg << "BESReturnManager::dump - (" 00103 << (void *)this << ")" << endl ; 00104 BESIndent::Indent() ; 00105 if( _transmitter_list.size() ) 00106 { 00107 strm << BESIndent::LMarg << "registered transmitters:" << endl ; 00108 BESIndent::Indent() ; 00109 BESReturnManager::Transmitter_citer i = _transmitter_list.begin() ; 00110 BESReturnManager::Transmitter_citer ie = _transmitter_list.end() ; 00111 for( ; i != ie; i++ ) 00112 { 00113 strm << BESIndent::LMarg << (*i).first << endl ; 00114 BESIndent::Indent() ; 00115 (*i).second->dump( strm ) ; 00116 BESIndent::UnIndent() ; 00117 } 00118 BESIndent::UnIndent() ; 00119 } 00120 else 00121 { 00122 strm << BESIndent::LMarg << "registered transmitters: none" << endl ; 00123 } 00124 BESIndent::UnIndent() ; 00125 } 00126 00127 BESReturnManager * 00128 BESReturnManager::TheManager() 00129 { 00130 if( _instance == 0 ) 00131 { 00132 _instance = new BESReturnManager ; 00133 } 00134 return _instance ; 00135 } 00136