bes  Updated for version 3.17.0
BESCatalogEntry.cc
1 // BESCatalogEntry.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 "config.h"
34 
35 #include <sstream>
36 
37 using std::ostringstream;
38 
39 #include "BESCatalogEntry.h"
40 #include "BESInfo.h"
41 
42 BESCatalogEntry::BESCatalogEntry(const string &name, const string &catalog) :
43  _name(name), _catalog(catalog)
44 {
45 }
46 
47 BESCatalogEntry::~BESCatalogEntry()
48 {
49  // iterate through the entry list and delete them all
50  map<string, BESCatalogEntry *>::iterator i = _entry_list.begin();
51  map<string, BESCatalogEntry *>::iterator e = _entry_list.end();
52  for (; i != e; i++) {
53  BESCatalogEntry *e = (*i).second;
54  delete e;
55  (*i).second = 0;
56  }
57 }
58 
59 void BESCatalogEntry::set_size(off_t size)
60 {
61  ostringstream strm;
62  strm << size;
63  _size = strm.str();
64 }
65 
73 void BESCatalogEntry::dump(ostream &strm) const
74 {
75  strm << BESIndent::LMarg << "BESCatalogEntry::dump - (" << (void *) this << ")" << endl;
76  BESIndent::Indent();
77 
78  strm << BESIndent::LMarg << "name: " << _name << endl;
79  strm << BESIndent::LMarg << "catalog: " << _catalog << endl;
80  strm << BESIndent::LMarg << "size: " << _size << endl;
81  strm << BESIndent::LMarg << "modification date: " << _mod_date << endl;
82  strm << BESIndent::LMarg << "modification time: " << _mod_time << endl;
83  strm << BESIndent::LMarg << "services: ";
84  if (_services.size()) {
85  strm << endl;
86  BESIndent::Indent();
87  list<string>::const_iterator si = _services.begin();
88  list<string>::const_iterator se = _services.end();
89  for (; si != se; si++) {
90  strm << BESIndent::LMarg << (*si) << endl;
91  }
92  BESIndent::UnIndent();
93  }
94  else {
95  strm << "none" << endl;
96  }
97 
98  strm << BESIndent::LMarg << "metadata: ";
99  if (_metadata.size()) {
100  strm << endl;
101  BESIndent::Indent();
102  map<string, string>::const_iterator mi = _metadata.begin();
103  map<string, string>::const_iterator me = _metadata.end();
104  for (; mi != me; mi++) {
105  strm << BESIndent::LMarg << (*mi).first << " = " << (*mi).second << endl;
106  }
107  BESIndent::UnIndent();
108  }
109  else {
110  strm << "none" << endl;
111  }
112 
113  strm << BESIndent::LMarg << "is collection? ";
114  if (_entry_list.size() > 0)
115  strm << "yes" << endl;
116  else
117  strm << "no" << endl;
118  strm << BESIndent::LMarg << "count: " << _entry_list.size() << endl;
119 
120  // display this entries information, then the list
121  BESIndent::Indent();
122  map<string, BESCatalogEntry *>::const_iterator i = _entry_list.begin();
123  map<string, BESCatalogEntry *>::const_iterator e = _entry_list.end();
124  for (; i != e; i++) {
125  BESCatalogEntry *e = (*i).second;
126  e->dump(strm);
127  }
128  BESIndent::UnIndent();
129 
130  BESIndent::UnIndent();
131 }
132 
virtual void dump(ostream &strm) const
dumps information about this object