bes Updated for version 3.20.10
Dimension.cc
1
2// This file is part of the "NcML Module" project, a BES module designed
3// to allow NcML files to be used to be used as a wrapper to add
4// AIS to existing datasets of any format.
5//
6// Copyright (c) 2009 OPeNDAP, Inc.
7// Author: Michael Johnson <m.johnson@opendap.org>
8//
9// For more information, please also see the main website: http://opendap.org/
10//
11// This library is free software; you can redistribute it and/or
12// modify it under the terms of the GNU Lesser General Public
13// License as published by the Free Software Foundation; either
14// version 2.1 of the License, or (at your option) any later version.
15//
16// This library is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19// Lesser General Public License for more details.
20//
21// You should have received a copy of the GNU Lesser General Public
22// License along with this library; if not, write to the Free Software
23// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24//
25// Please see the files COPYING and COPYRIGHT for more information on the GLPL.
26//
27// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
29#include "Dimension.h"
30#include "NCMLDebug.h"// the only NCML dep we allow...
31
32#include <iostream>
33#include <sstream>
34
35using std::string;
36using std::ostringstream;
37using std::vector;
38using std::ws;
39
40namespace agg_util {
41Dimension::Dimension() :
42 name(""), size(0), isShared(false), isSizeConstant(false)
43{
44}
45
46Dimension::Dimension(const string& nameArg, unsigned int sizeArg, bool isSharedArg, bool isSizeConstantArg) :
47 name(nameArg), size(sizeArg), isShared(isSharedArg), isSizeConstant(isSizeConstantArg)
48{
49}
50
51Dimension::~Dimension()
52{
53}
54
55std::string Dimension::toString() const
56{
57 ostringstream oss;
58 oss << *this;
59 return oss.str();
60}
61
62std::ostream& operator<<(std::ostream& os, const Dimension& dim)
63{
64 os << dim.name << '\n';
65 os << dim.size << '\n';
66 return os;
67}
68
69std::istream& operator>>(std::istream& is, Dimension& dim)
70{
71 dim.isShared = false;
72 dim.isSizeConstant = true;
73
74 getline(is, dim.name);
75 is >> ws >> dim.size >> ws;
76 return is;
77}
78
79#if 0
80bool DimensionTable::findDimension(const std::string& name, Dimension* pOut) const
81{
82 bool foundIt = false;
83 vector<Dimension>::const_iterator endIt = _dimensions.end();
84 vector<Dimension>::const_iterator it;
85 for (it = _dimensions.begin(); it != endIt; ++it) {
86 if (it->name == name) {
87 if (pOut) {
88 *pOut = *it;
89 }
90 foundIt = true;
91 break;
92 }
93 }
94 return foundIt;
95}
96
97void DimensionTable::addDimensionUnique(const Dimension& dim)
98{
99 if (!findDimension(dim.name)) {
100 _dimensions.push_back(dim);
101 }
102 else {
103 BESDEBUG("ncml", "A dimension with name=" << dim.name << " already exists. Not adding." << endl);
104 }
105}
106
107const std::vector<Dimension>&
108DimensionTable::getDimensions() const
109{
110 return _dimensions;
111}
112#endif
113
114}
Helper class for temporarily hijacking an existing dhi to load a DDX response for one particular file...