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