bes  Updated for version 3.20.6
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 
37 using std::endl;
38 using std::list;
39 using std::string;
40 using std::map;
41 using std::ostream;
42 
50  BESInfo(), _inbes(false), _inhandler(false), _info(0)
51 {
52  _info = BESInfoList::TheList()->build_info();
53 }
54 
55 BESVersionInfo::~BESVersionInfo()
56 {
57  if (_info) delete _info;
58 }
59 
60 void BESVersionInfo::add_library(const string &name, const string &vers)
61 {
62  add_version("library", name, vers);
63 }
64 
65 void BESVersionInfo::add_module(const string &name, const string &vers)
66 {
67  add_version("module", name, vers);
68 }
69 
70 void BESVersionInfo::add_service(const string &name, const list<string> &vers)
71 {
72  map<string, string> props;
73  props["name"] = name;
74  begin_tag("serviceVersion", &props);
75  list<string>::const_iterator i = vers.begin();
76  list<string>::const_iterator e = vers.end();
77  for (; i != e; i++) {
78  add_tag("version", (*i));
79  }
80  end_tag("serviceVersion");
81 }
82 
83 void BESVersionInfo::add_version(const string &type, const string &name, const string &vers)
84 {
85  map<string, string> attrs;
86  attrs["name"] = name;
87  attrs["version"] = vers;
88  add_tag(type, "", &attrs);
89 }
90 
98 void BESVersionInfo::dump(ostream &strm) const
99 {
100  strm << BESIndent::LMarg << "BESVersionInfo::dump - (" << (void *) this << ")" << endl;
101  BESIndent::Indent();
102  strm << BESIndent::LMarg << "in BES version? " << _inbes << endl;
103  strm << BESIndent::LMarg << "in Handler version? " << _inhandler << endl;
104  if (_info) {
105  strm << BESIndent::LMarg << "redirection info object:" << endl;
106  BESIndent::Indent();
107  _info->dump(strm);
108  BESIndent::UnIndent();
109  }
110  else {
111  strm << BESIndent::LMarg << "redirection info object: null" << endl;
112  }
113  BESInfo::dump(strm);
114  BESIndent::UnIndent();
115 }
116 
BESVersionInfo::dump
virtual void dump(std::ostream &strm) const
dumps information about this object
Definition: BESVersionInfo.cc:98
BESInfo
informational response object
Definition: BESInfo.h:63
BESVersionInfo::BESVersionInfo
BESVersionInfo()
constructs a basic text information response object to write version information
Definition: BESVersionInfo.cc:49
BESInfo::dump
virtual void dump(std::ostream &strm) const
Displays debug information about this object.
Definition: BESInfo.cc:275