bes  Updated for version 3.20.6
CatalogItem.cc
1 // -*- mode: c++; c-basic-offset:4 -*-
2 
3 // This file is part of the OPeNDAP Back-End Server (BES)
4 
5 // Copyright (c) 2018 OPeNDAP, Inc.
6 // Author: James Gallagher <jgallagher@opendap.org>
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 //
22 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
23 
24 #include "config.h"
25 
26 #include <string>
27 #include <ostream>
28 #include <sstream>
29 
30 #include "BESInfo.h"
31 #include "BESIndent.h"
32 
33 #include "CatalogItem.h"
34 
35 using namespace bes;
36 using namespace std;
37 
52 void
54 {
55  map<string, string> props;
56 
57  props["name"] = get_name();
58  props["type"] = get_type() == leaf ? "leaf": "node";
59  props["lastModified"] = get_lmt();
60  if (get_type() == leaf) {
61  ostringstream oss;
62  oss << get_size();
63  props["size"] = oss.str();
64  props["isData"] = is_data() ? "true" : "false";
65  }
66 
67  info->begin_tag("item", &props);
68 
69  info->end_tag("item");
70 
71 #if 0
72  // TODO Should we support the serviceRef element? jhrg 7/22/18
73  list<string> services = entry->get_service_list();
74  if (services.size()) {
75  list<string>::const_iterator si = services.begin();
76  list<string>::const_iterator se = services.end();
77  for (; si != se; si++) {
78  info->add_tag("serviceRef", (*si));
79  }
80  }
81 #endif
82 
83 }
84 
85 
90 void CatalogItem::dump(ostream &strm) const
91 {
92  strm << BESIndent::LMarg << "CatalogItem::dump - (" << (void *) this << ")" << endl;
93  BESIndent::Indent();
94 
95  strm << BESIndent::LMarg << "name: " << d_name << endl;
96  strm << BESIndent::LMarg << "size: " << d_size << endl;
97  strm << BESIndent::LMarg << "last modified time: " << d_lmt << endl;
98  strm << BESIndent::LMarg << "is_data: " << d_is_data << endl;
99  strm << BESIndent::LMarg << "type: " << d_type << endl;
100 
101  BESIndent::UnIndent();
102 }
bes::CatalogItem::encode_item
void encode_item(BESInfo *info)
Encode this CatalogItem in an info object.
Definition: CatalogItem.cc:53
BESInfo
informational response object
Definition: BESInfo.h:63
bes::CatalogItem::dump
virtual void dump(std::ostream &strm) const
Definition: CatalogItem.cc:90