OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
BESReturnManager.cc
Go to the documentation of this file.
1 // BESReturnManager.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: 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 Atmospheric 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 "BESReturnManager.h"
34 
35 BESReturnManager *BESReturnManager::_instance = 0;
36 
38 {
39 }
40 
42 {
44  BESTransmitter *t = 0;
45  for (i = _transmitter_list.begin(); i != _transmitter_list.end(); i++) {
46  t = (*i).second;
47  delete t;
48  }
49 }
50 
51 bool BESReturnManager::add_transmitter(const string &name, BESTransmitter *transmitter)
52 {
53  if (find_transmitter(name) == 0) {
54  _transmitter_list[name] = transmitter;
55  return true;
56  }
57  return false;
58 }
59 
60 bool BESReturnManager::del_transmitter(const string &name)
61 {
62  bool ret = false;
64  i = _transmitter_list.find(name);
65  if (i != _transmitter_list.end()) {
66  BESTransmitter *obj = (*i).second;
67  _transmitter_list.erase(i);
68  if (obj) delete obj;
69  ret = true;
70  }
71  return ret;
72 }
73 
76 {
78  i = _transmitter_list.find(name);
79  if (i != _transmitter_list.end()) {
80  return (*i).second;
81  }
82  return 0;
83 }
84 
92 void BESReturnManager::dump(ostream &strm) const
93 {
94  strm << BESIndent::LMarg << "BESReturnManager::dump - (" << (void *) this << ")" << endl;
96  if (_transmitter_list.size()) {
97  strm << BESIndent::LMarg << "registered transmitters:" << endl;
99  BESReturnManager::Transmitter_citer i = _transmitter_list.begin();
100  BESReturnManager::Transmitter_citer ie = _transmitter_list.end();
101  for (; i != ie; i++) {
102  strm << BESIndent::LMarg << (*i).first << endl;
104  (*i).second->dump(strm);
106  }
108  }
109  else {
110  strm << BESIndent::LMarg << "registered transmitters: none" << endl;
111  }
113 }
114 
117 {
118  if (_instance == 0) {
119  _instance = new BESReturnManager;
120  }
121  return _instance;
122 }
123 
virtual BESTransmitter * find_transmitter(const string &name)
virtual bool del_transmitter(const string &name)
virtual bool add_transmitter(const string &name, BESTransmitter *transmitter)
map< string, BESTransmitter * >::iterator Transmitter_iter
static void Indent()
Definition: BESIndent.cc:38
static BESReturnManager * TheManager()
ReturnManager holds the list of response object transmitter that knows how to transmit response objec...
static ostream & LMarg(ostream &strm)
Definition: BESIndent.cc:73
map< string, BESTransmitter * >::const_iterator Transmitter_citer
virtual ~BESReturnManager()
static void UnIndent()
Definition: BESIndent.cc:44
virtual void dump(ostream &strm) const
dumps information about this object