bes Updated for version 3.20.13
CatalogItem.h
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#ifndef I_CatalogItem_h
25#define I_CatalogItem_h 1
26
27#include <string>
28#include <ostream>
29
30#include "BESObj.h"
31
32class BESInfo;
33
34namespace bes {
35
36#if 0
37Class Node {
38 Name
39 LMT
40 Item_count (number of nodes or leaves it holds)
41 Items (zero or more Item instances)
42
43 Class Item {
44 Name
45 Size
46 Type (node or leaf)
47 Is_data
48 LMT
49 }
50}
51#endif
52
72class CatalogItem: public BESObj {
73public:
74 enum item_type {unknown, node, leaf};
75
76private:
77 std::string d_name;
78 size_t d_size;
79 std::string d_lmt;
80 bool d_is_data;
81 item_type d_type;
82
83 CatalogItem(const CatalogItem &rhs);
84 CatalogItem &operator=(const CatalogItem &rhs);
85
86public:
88 CatalogItem() : d_name(""), d_size(0), d_lmt(""), d_is_data(false), d_type(unknown) { }
89
104 CatalogItem(const std::string &name, size_t size, const std::string &lmt, item_type type)
105 : d_name(name), d_size(size), d_lmt(lmt), d_is_data(false), d_type(type) { }
106
123 CatalogItem(const std::string &name, size_t size, const std::string &lmt, bool is_data, item_type type)
124 : d_name(name), d_size(size), d_lmt(lmt), d_is_data(is_data), d_type(type) { }
125
126 virtual ~CatalogItem() { }
127
129 bool operator() (CatalogItem *i,CatalogItem *j) { return (i->d_name < j->d_name); }
130 };
131
133 std::string get_name() const { return d_name; }
135 void set_name(std::string n) { d_name = n; }
136
138 size_t get_size() const { return d_size; }
140 void set_size(size_t s) { d_size = s; }
141
143 std::string get_lmt() const { return d_lmt; }
145 void set_lmt(std::string lmt) { d_lmt = lmt; }
146
148 bool is_data() const { return d_is_data; }
150 void set_is_data(bool id) { d_is_data = id; }
151
153 item_type get_type() const { return d_type; }
155 void set_type(item_type t) { d_type = t; }
156
157 void encode_item(BESInfo *info);
158
159 virtual void dump(std::ostream &strm) const;
160};
161
162} // namespace bes
163
164#endif // I_BESCatalogItem_h
informational response object
Definition: BESInfo.h:63
top level BES object to house generic methods
Definition: BESObj.h:54
void set_name(std::string n)
Set the name of the item.
Definition: CatalogItem.h:135
std::string get_name() const
The name of this item in the node.
Definition: CatalogItem.h:133
bool is_data() const
Is this item recognized as data?
Definition: CatalogItem.h:148
void set_size(size_t s)
Set the size of the item.
Definition: CatalogItem.h:140
void set_is_data(bool id)
Is this item data that the BES should interpret?
Definition: CatalogItem.h:150
size_t get_size() const
The size (bytes) of the item.
Definition: CatalogItem.h:138
void set_lmt(std::string lmt)
Set the LMT for this item.
Definition: CatalogItem.h:145
CatalogItem(const std::string &name, size_t size, const std::string &lmt, item_type type)
Hold information about an item in a BES Catalog.
Definition: CatalogItem.h:104
virtual void dump(std::ostream &strm) const
Definition: CatalogItem.cc:90
void encode_item(BESInfo *info)
Encode this CatalogItem in an info object.
Definition: CatalogItem.cc:53
std::string get_lmt() const
Get the last modified time for this item.
Definition: CatalogItem.h:143
item_type get_type() const
Get the type of this item (unknown, node or leaf)
Definition: CatalogItem.h:153
CatalogItem(const std::string &name, size_t size, const std::string &lmt, bool is_data, item_type type)
Hold information about an item in a BES Catalog.
Definition: CatalogItem.h:123
void set_type(item_type t)
Set the type for this item.
Definition: CatalogItem.h:155
CatalogItem()
Make an empty instance.
Definition: CatalogItem.h:88
Type
Type of JSON value.
Definition: rapidjson.h:664