bes  Updated for version 3.19.1
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(),
45  _inbes( false ),
46  _inhandler( false ),
47  _info( 0 )
48 {
49  _info = BESInfoList::TheList()->build_info() ;
50 }
51 
52 BESVersionInfo::~BESVersionInfo()
53 {
54  if( _info ) delete _info ;
55 }
56 
57 void
58 BESVersionInfo::add_library( const string &name, const string &vers )
59 {
60  add_version( "library", name, vers ) ;
61 }
62 
63 void
64 BESVersionInfo::add_module( const string &name, const string &vers )
65 {
66  add_version( "module", name, vers ) ;
67 }
68 
69 void
70 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  {
79  add_tag( "version", (*i) ) ;
80  }
81  end_tag( "serviceVersion" ) ;
82 }
83 
84 void
85 BESVersionInfo::add_version( const string &type,
86  const string &name,
87  const string &vers )
88 {
89  map<string,string> attrs ;
90  attrs["name"] = name ;
91  add_tag( type, vers, &attrs ) ;
92 }
93 
101 void
102 BESVersionInfo::dump( ostream &strm ) const
103 {
104  strm << BESIndent::LMarg << "BESVersionInfo::dump - ("
105  << (void *)this << ")" << endl ;
106  BESIndent::Indent() ;
107  strm << BESIndent::LMarg << "in BES version? " << _inbes << endl ;
108  strm << BESIndent::LMarg << "in Handler version? " << _inhandler << endl ;
109  if( _info )
110  {
111  strm << BESIndent::LMarg << "redirection info object:" << endl ;
112  BESIndent::Indent() ;
113  _info->dump( strm ) ;
114  BESIndent::UnIndent() ;
115  }
116  else
117  {
118  strm << BESIndent::LMarg << "redirection info object: null" << endl ;
119  }
120  BESInfo::dump( strm ) ;
121  BESIndent::UnIndent() ;
122 }
123 
virtual void dump(ostream &strm) const
Displays debug information about this object.
Definition: BESInfo.cc:263
BESVersionInfo()
constructs a basic text information response object to write version information
informational response object
Definition: BESInfo.h:68
virtual void dump(ostream &strm) const
dumps information about this object