bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
CatalogNode.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_CatalogNode_h
25#define I_CatalogNode_h 1
26
27#include <string>
28#include <vector>
29#include <ostream>
30
31#include "BESObj.h"
32
33#define ITEMS 0
34#define NODES_AND_LEAVES 1
35
36class BESInfo;
37
38namespace bes {
39
40class CatalogItem;
41
45class CatalogNode: public BESObj {
46private:
47 std::string d_name;
48 std::string d_catalog_name;
49 std::string d_lmt;
50
51 CatalogItem* d_no_really_im_a_leaf;
52
53#if ITEMS
54 std::vector<CatalogItem*> d_items;
55#endif
56
57#if NODES_AND_LEAVES
58 // Separate the child nodes and leaves so they can be treated as
59 // a group more easily (all the nodes listed first, e.g.).
60 std::vector<CatalogItem*> d_nodes;
61 std::vector<CatalogItem*> d_leaves;
62#endif
63
64 CatalogNode(const CatalogNode &rhs);
65 CatalogNode &operator=(const CatalogNode &rhs);
66
67public:
69 CatalogNode() : d_name(""), d_catalog_name(""), d_lmt(""), d_no_really_im_a_leaf(0){ }
70
71 CatalogNode(const std::string &name) : d_name(name), d_catalog_name(""), d_lmt(""), d_no_really_im_a_leaf(0) { }
72
73 virtual ~CatalogNode();
74
75
76 void set_leaf(CatalogItem *leaf) { d_no_really_im_a_leaf = leaf; }
77 CatalogItem *get_leaf() const { return d_no_really_im_a_leaf; }
78
80 std::string get_name() const { return d_name; }
82 void set_name(std::string n) { d_name = n; }
83
85 std::string get_catalog_name() const { return d_catalog_name; }
87 void set_catalog_name(std::string cn) { d_catalog_name = cn; }
88
90 std::string get_lmt() const { return d_lmt; }
92 void set_lmt(std::string lmt) { d_lmt = lmt; }
93
94 typedef std::vector<CatalogItem*>::const_iterator item_citer;
95 typedef std::vector<CatalogItem*>::iterator item_iter;
96
97#if ITEMS
98 item_citer items_begin() { return d_items.begin(); }
99 item_citer items_end() { return d_items.end(); }
100
102 size_t get_item_count() const { return d_items.size(); }
104 void add_item(CatalogItem *item) { d_items.push_back(item); }
105#endif
106
107#if NODES_AND_LEAVES
108 item_iter nodes_begin() { return d_nodes.begin(); }
109 item_iter nodes_end() { return d_nodes.end(); }
110
111 size_t get_item_count() const { return d_nodes.size() + d_leaves.size(); }
112
114 size_t get_node_count() const { return d_nodes.size(); }
116 void add_node(CatalogItem *node) { d_nodes.push_back(node); }
117
118 item_iter leaves_begin() { return d_leaves.begin(); }
119 item_iter leaves_end() { return d_leaves.end(); }
120
122 size_t get_leaf_count() const { return d_leaves.size(); }
124 void add_leaf(CatalogItem *leaf) { d_leaves.push_back(leaf); }
125#endif
126
127 void encode_node(BESInfo *info);
128
129 virtual void dump(std::ostream &strm) const;
130};
131
132} // namespace bes
133
134#endif // I_BESCatalogNode_h
informational response object
Definition BESInfo.h:63
top level BES object to house generic methods
Definition BESObj.h:54
std::string get_lmt() const
Get the last modified time for this node.
Definition CatalogNode.h:90
void encode_node(BESInfo *info)
Encode this CatalogNode in an info object.
void add_node(CatalogItem *node)
Add information about an node that is in this node of the catalog.
void add_leaf(CatalogItem *leaf)
Add information about an leaf that is in this node of the catalog.
size_t get_leaf_count() const
How many leaves are in this node of the catalog?
void set_catalog_name(std::string cn)
Set the name of the catalog.
Definition CatalogNode.h:87
std::string get_catalog_name() const
The name of the catalog.
Definition CatalogNode.h:85
size_t get_node_count() const
How many nodes are in this node of the catalog?
void set_name(std::string n)
Set the name of the catalog's node.
Definition CatalogNode.h:82
CatalogNode()
Make an empty instance.
Definition CatalogNode.h:69
virtual void dump(std::ostream &strm) const
std::string get_name() const
The name of this node in the catalog.
Definition CatalogNode.h:80
void set_lmt(std::string lmt)
Set the LMT for this node.
Definition CatalogNode.h:92