OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
FONcSequence.cc
Go to the documentation of this file.
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 
46  : FONcBaseType(), _s( 0 )
47 {
48  _s = dynamic_cast<Sequence *>(b) ;
49  if( !_s )
50  {
51  string s = (string)"File out netcdf, FONcSequence was passed a "
52  + "variable that is not a DAP Sequence" ;
53  throw BESInternalError( s, __FILE__, __LINE__ ) ;
54  }
55 }
56 
63 {
64 }
65 
75 void
76 FONcSequence::convert( vector<string> embed )
77 {
78  FONcBaseType::convert( embed ) ;
80 }
81 
92 void
94 {
95  // for now we are simply going to add a global variable noting the
96  // presence of the sequence, the name of the sequence, and that the
97  // sequences has been elided.
98  string val = (string)"The sequence " + _varname
99  + " is a member of this dataset and has been elided." ;
100  int stax = nc_put_att_text( ncid, NC_GLOBAL, _varname.c_str(),
101  val.length(), val.c_str() ) ;
102  if( stax != NC_NOERR )
103  {
104  string err = (string)"File out netcdf, "
105  + "failed to write string attribute for sequence "
106  + _varname ;
107  FONcUtils::handle_error( stax, err, __FILE__, __LINE__ ) ;
108  }
109 }
110 
120 void
121 FONcSequence::write( int /*ncid*/ )
122 {
123 }
124 
125 string
127 {
128  return _s->name() ;
129 }
130 
137 void
138 FONcSequence::dump( ostream &strm ) const
139 {
140  strm << BESIndent::LMarg << "FONcSequence::dump - ("
141  << (void *)this << ")" << endl ;
143  strm << BESIndent::LMarg << "name = " << _s->name() << endl ;
145 }
146 
exception thrown if inernal error encountered
virtual void define(int ncid)
define the DAP Sequence in the netcdf file
Definition: FONcSequence.cc:93
virtual string name()
virtual void convert(vector< string > embed)
convert the Sequence to something that can be stored in a netcdf file
Definition: FONcSequence.cc:76
static void Indent()
Definition: BESIndent.cc:38
string _orig_varname
Definition: FONcBaseType.h:53
virtual void write(int ncid)
Write the sequence data out to the netcdf file.
string _varname
Definition: FONcBaseType.h:52
static ostream & LMarg(ostream &strm)
Definition: BESIndent.cc:73
virtual ~FONcSequence()
Destructor that cleans up the sequence.
Definition: FONcSequence.cc:62
virtual void dump(ostream &strm) const
dumps information about this object for debugging purposes
static void handle_error(int stax, string &err, const string &file, int line)
handle any netcdf errors
Definition: FONcUtils.cc:238
A DAP BaseType with file out netcdf information included.
Definition: FONcBaseType.h:48
FONcSequence(BaseType *b)
Constructor for FONcSequence that takes a DAP Sequence.
Definition: FONcSequence.cc:45
static string gen_name(const vector< string > &embed, const string &name, string &original)
generate a new name for the embedded variable
Definition: FONcUtils.cc:150
static void UnIndent()
Definition: BESIndent.cc:44
virtual void convert(vector< string > embed)
Definition: FONcBaseType.cc:41