bes  Updated for version 3.20.5
BESVersionInfo.cc
1 // BESVersionInfo.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 "BESVersionInfo.h"
34 #include "BESInfoList.h"
35 #include "BESInternalError.h"
36 
44  BESInfo(), _inbes(false), _inhandler(false), _info(0)
45 {
46  _info = BESInfoList::TheList()->build_info();
47 }
48 
49 BESVersionInfo::~BESVersionInfo()
50 {
51  if (_info) delete _info;
52 }
53 
54 void BESVersionInfo::add_library(const string &name, const string &vers)
55 {
56  add_version("library", name, vers);
57 }
58 
59 void BESVersionInfo::add_module(const string &name, const string &vers)
60 {
61  add_version("module", name, vers);
62 }
63 
64 void BESVersionInfo::add_service(const string &name, const list<string> &vers)
65 {
66  map<string, string> props;
67  props["name"] = name;
68  begin_tag("serviceVersion", &props);
69  list<string>::const_iterator i = vers.begin();
70  list<string>::const_iterator e = vers.end();
71  for (; i != e; i++) {
72  add_tag("version", (*i));
73  }
74  end_tag("serviceVersion");
75 }
76 
77 void BESVersionInfo::add_version(const string &type, const string &name, const string &vers)
78 {
79  map<string, string> attrs;
80  attrs["name"] = name;
81  add_tag(type, vers, &attrs);
82 }
83 
91 void BESVersionInfo::dump(ostream &strm) const
92 {
93  strm << BESIndent::LMarg << "BESVersionInfo::dump - (" << (void *) this << ")" << endl;
94  BESIndent::Indent();
95  strm << BESIndent::LMarg << "in BES version? " << _inbes << endl;
96  strm << BESIndent::LMarg << "in Handler version? " << _inhandler << endl;
97  if (_info) {
98  strm << BESIndent::LMarg << "redirection info object:" << endl;
99  BESIndent::Indent();
100  _info->dump(strm);
101  BESIndent::UnIndent();
102  }
103  else {
104  strm << BESIndent::LMarg << "redirection info object: null" << endl;
105  }
106  BESInfo::dump(strm);
107  BESIndent::UnIndent();
108 }
109 
BESInfo
informational response object
Definition: BESInfo.h:68
BESInfo::dump
virtual void dump(ostream &strm) const
Displays debug information about this object.
Definition: BESInfo.cc:275
BESVersionInfo::BESVersionInfo
BESVersionInfo()
constructs a basic text information response object to write version information
Definition: BESVersionInfo.cc:43
BESVersionInfo::dump
virtual void dump(ostream &strm) const
dumps information about this object
Definition: BESVersionInfo.cc:91