bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
FONcSequence.cc
1// FONcSequence.cc
2
3// This file is part of BES Netcdf File Out Module
4
5// Copyright (c) 2004,2005 University Corporation for Atmospheric Research
6// Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu>
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 University Corporation for Atmospheric Research at
23// 3080 Center Green Drive, Boulder, CO 80301
24
25// (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
26// Please read the full copyright statement in the file COPYRIGHT_UCAR.
27//
28// Authors:
29// pwest Patrick West <pwest@ucar.edu>
30// jgarcia Jose Garcia <jgarcia@ucar.edu>
31
32#include <BESInternalError.h>
33
34#include "FONcSequence.h"
35#include "FONcUtils.h"
36
45FONcSequence::FONcSequence(libdap::BaseType *b) :
46 FONcBaseType(), _s(0)
47{
48 _s = dynamic_cast<libdap::Sequence *>(b);
49 if (!_s) {
50 throw BESInternalError("File out netcdf, FONcSequence was passed a variable that is not a DAP Sequence", __FILE__, __LINE__);
51 }
52}
53
62
72void FONcSequence::convert(vector<string> embed,bool _dap4, bool is_dap4_group)
73{
74 FONcBaseType::convert(embed,_dap4,is_dap4_group);
75 d_varname = FONcUtils::gen_name(embed, d_varname, d_orig_varname);
76}
77
89{
90 // for now we are simply going to add a global variable noting the
91 // presence of the sequence, the name of the sequence, and that the
92 // sequences has been elided.
93 string val = (string) "The sequence " + d_varname + " is a member of this dataset and has been elided.";
94 int stax = nc_put_att_text(ncid, NC_GLOBAL, d_varname.c_str(), val.size(), val.c_str());
95 if (stax != NC_NOERR) {
96 string err = (string) "File out netcdf, " + "failed to write string attribute for sequence " + d_varname;
97 FONcUtils::handle_error(stax, err, __FILE__, __LINE__);
98 }
99}
100
110void FONcSequence::write(int /*ncid*/)
111{
112 //FIXME implement this function. jhrg/sbl 5.14.21
113}
114
115string FONcSequence::name()
116{
117 return _s->name();
118}
119
127{
128 strm << BESIndent::LMarg << "FONcSequence::dump - (" << (void *) this << ")" << endl;
129 BESIndent::Indent();
130 strm << BESIndent::LMarg << "name = " << _s->name() << endl;
131 BESIndent::UnIndent();
132}
133
exception thrown if internal error encountered
virtual void define(int ncid)
define the DAP Sequence in the netcdf file
virtual void dump(ostream &strm) const
dumps information about this object for debugging purposes
FONcSequence(libdap::BaseType *b)
Constructor for FONcSequence that takes a DAP Sequence.
virtual ~FONcSequence()
Destructor that cleans up the sequence.
virtual void convert(vector< string > embed, bool _dap4=false, bool is_dap4_group=false)
convert the Sequence to something that can be stored in a netcdf file
virtual void write(int ncid)
Write the sequence data out to the netcdf file.
static void handle_error(int stax, const string &err, const string &file, int line)
handle any netcdf errors
Definition FONcUtils.cc:429
static string gen_name(const vector< string > &embed, const string &name, string &original)
generate a new name for the embedded variable
Definition FONcUtils.cc:182
STL class.
STL class.