<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>libdap++: Grid.cc Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.5.9 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="main.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <h1>Grid.cc</h1><a href="Grid_8cc.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <a name="l00002"></a>00002 <span class="comment">// -*- mode: c++; c-basic-offset:4 -*-</span> <a name="l00003"></a>00003 <a name="l00004"></a>00004 <span class="comment">// This file is part of libdap, A C++ implementation of the OPeNDAP Data</span> <a name="l00005"></a>00005 <span class="comment">// Access Protocol.</span> <a name="l00006"></a>00006 <a name="l00007"></a>00007 <span class="comment">// Copyright (c) 2002,2003 OPeNDAP, Inc.</span> <a name="l00008"></a>00008 <span class="comment">// Author: James Gallagher <jgallagher@opendap.org></span> <a name="l00009"></a>00009 <span class="comment">//</span> <a name="l00010"></a>00010 <span class="comment">// This library is free software; you can redistribute it and/or</span> <a name="l00011"></a>00011 <span class="comment">// modify it under the terms of the GNU Lesser General Public</span> <a name="l00012"></a>00012 <span class="comment">// License as published by the Free Software Foundation; either</span> <a name="l00013"></a>00013 <span class="comment">// version 2.1 of the License, or (at your option) any later version.</span> <a name="l00014"></a>00014 <span class="comment">//</span> <a name="l00015"></a>00015 <span class="comment">// This library is distributed in the hope that it will be useful,</span> <a name="l00016"></a>00016 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00017"></a>00017 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span> <a name="l00018"></a>00018 <span class="comment">// Lesser General Public License for more details.</span> <a name="l00019"></a>00019 <span class="comment">//</span> <a name="l00020"></a>00020 <span class="comment">// You should have received a copy of the GNU Lesser General Public</span> <a name="l00021"></a>00021 <span class="comment">// License along with this library; if not, write to the Free Software</span> <a name="l00022"></a>00022 <span class="comment">// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span> <a name="l00023"></a>00023 <span class="comment">//</span> <a name="l00024"></a>00024 <span class="comment">// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.</span> <a name="l00025"></a>00025 <a name="l00026"></a>00026 <span class="comment">// (c) COPYRIGHT URI/MIT 1994-1999</span> <a name="l00027"></a>00027 <span class="comment">// Please read the full copyright statement in the file COPYRIGHT_URI.</span> <a name="l00028"></a>00028 <span class="comment">//</span> <a name="l00029"></a>00029 <span class="comment">// Authors:</span> <a name="l00030"></a>00030 <span class="comment">// jhrg,jimg James Gallagher <jgallagher@gso.uri.edu></span> <a name="l00031"></a>00031 <a name="l00032"></a>00032 <span class="comment">// implementation for Grid.</span> <a name="l00033"></a>00033 <span class="comment">//</span> <a name="l00034"></a>00034 <span class="comment">// jhrg 9/15/94</span> <a name="l00035"></a>00035 <a name="l00036"></a>00036 <span class="preprocessor">#include "<a class="code" href="config_8h.html">config.h</a>"</span> <a name="l00037"></a>00037 <a name="l00038"></a>00038 <span class="preprocessor">#include <functional></span> <a name="l00039"></a>00039 <span class="preprocessor">#include <algorithm></span> <a name="l00040"></a>00040 <a name="l00041"></a>00041 <span class="preprocessor">#include "<a class="code" href="Grid_8h.html">Grid.h</a>"</span> <a name="l00042"></a>00042 <span class="preprocessor">#include "<a class="code" href="DDS_8h.html">DDS.h</a>"</span> <a name="l00043"></a>00043 <span class="preprocessor">#include "<a class="code" href="Array_8h.html">Array.h</a>"</span> <span class="comment">// for downcasts</span> <a name="l00044"></a>00044 <span class="preprocessor">#include "<a class="code" href="util_8h.html">util.h</a>"</span> <a name="l00045"></a>00045 <span class="preprocessor">#include "<a class="code" href="InternalErr_8h.html">InternalErr.h</a>"</span> <a name="l00046"></a>00046 <span class="preprocessor">#include "<a class="code" href="escaping_8h.html">escaping.h</a>"</span> <a name="l00047"></a>00047 <span class="comment">//#include "BTIterAdapter.h"</span> <a name="l00048"></a>00048 <a name="l00049"></a>00049 <a name="l00050"></a>00050 <span class="keyword">using namespace </span>std; <a name="l00051"></a>00051 <a name="l00052"></a>00052 <span class="keyword">namespace </span>libdap { <a name="l00053"></a>00053 <a name="l00054"></a>00054 <span class="keywordtype">void</span> <a name="l00055"></a>00055 Grid::_duplicate(<span class="keyword">const</span> Grid &s) <a name="l00056"></a>00056 { <a name="l00057"></a>00057 _array_var = s._array_var->ptr_duplicate(); <a name="l00058"></a>00058 _array_var->set_parent(<span class="keyword">this</span>); <a name="l00059"></a>00059 <a name="l00060"></a>00060 <a class="code" href="classlibdap_1_1Grid.html#75774a8fe1c7c7ec9a1e48a7d6d2cbc0" title="The Grid constructor.">Grid</a> &cs = <span class="keyword">const_cast<</span><a class="code" href="classlibdap_1_1Grid.html#75774a8fe1c7c7ec9a1e48a7d6d2cbc0" title="The Grid constructor.">Grid</a> &<span class="keyword">></span>(s); <a name="l00061"></a>00061 <a name="l00062"></a>00062 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#69ee284e8087d1482373989f3256f95d">Map_iter</a> i = cs._map_vars.begin(); i != cs._map_vars.end(); i++) { <a name="l00063"></a>00063 <a class="code" href="classlibdap_1_1BaseType.html#85729dec5e1c563a06bff3f3ec660822" title="The BaseType constructor.">BaseType</a> *btp = (*i)->ptr_duplicate(); <a name="l00064"></a>00064 btp->set_parent(<span class="keyword">this</span>); <a name="l00065"></a>00065 _map_vars.push_back(btp); <a name="l00066"></a>00066 } <a name="l00067"></a>00067 } <a name="l00068"></a>00068 <a name="l00078"></a><a class="code" href="classlibdap_1_1Grid.html#75774a8fe1c7c7ec9a1e48a7d6d2cbc0">00078</a> <a class="code" href="classlibdap_1_1Grid.html#75774a8fe1c7c7ec9a1e48a7d6d2cbc0" title="The Grid constructor.">Grid::Grid</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &n) : <a class="code" href="classlibdap_1_1Constructor.html">Constructor</a>(n, <a class="code" href="namespacelibdap.html#05ca706d4539ae7b750c3bc7066ab6e6c41525d2e860d3bcff641eb1fdba41d2">dods_grid_c</a>), _array_var(0) <a name="l00079"></a>00079 {} <a name="l00080"></a>00080 <a name="l00092"></a><a class="code" href="classlibdap_1_1Grid.html#dec10faa3280dde1bee9c1bf2eda9038">00092</a> <a class="code" href="classlibdap_1_1Grid.html#75774a8fe1c7c7ec9a1e48a7d6d2cbc0" title="The Grid constructor.">Grid::Grid</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &n, <span class="keyword">const</span> <span class="keywordtype">string</span> &d) <a name="l00093"></a>00093 : <a class="code" href="classlibdap_1_1Constructor.html">Constructor</a>(n, d, <a class="code" href="namespacelibdap.html#05ca706d4539ae7b750c3bc7066ab6e6c41525d2e860d3bcff641eb1fdba41d2">dods_grid_c</a>), _array_var(0) <a name="l00094"></a>00094 {} <a name="l00095"></a>00095 <a name="l00097"></a><a class="code" href="classlibdap_1_1Grid.html#d9c190d610f40faee6165467f554fb9a">00097</a> <a class="code" href="classlibdap_1_1Grid.html#75774a8fe1c7c7ec9a1e48a7d6d2cbc0" title="The Grid constructor.">Grid::Grid</a>(<span class="keyword">const</span> <a class="code" href="classlibdap_1_1Grid.html" title="Holds the Grid data type.">Grid</a> &rhs) : <a class="code" href="classlibdap_1_1Constructor.html">Constructor</a>(rhs) <a name="l00098"></a>00098 { <a name="l00099"></a>00099 _duplicate(rhs); <a name="l00100"></a>00100 } <a name="l00101"></a>00101 <a name="l00102"></a><a class="code" href="classlibdap_1_1Grid.html#6a81c2fe6689b4159d7ea9e6eb8f5e78">00102</a> <a class="code" href="classlibdap_1_1Grid.html#6a81c2fe6689b4159d7ea9e6eb8f5e78">Grid::~Grid</a>() <a name="l00103"></a>00103 { <a name="l00104"></a>00104 <span class="keyword">delete</span> _array_var; _array_var = 0; <a name="l00105"></a>00105 <a name="l00106"></a>00106 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#69ee284e8087d1482373989f3256f95d">Map_iter</a> i = _map_vars.begin(); i != _map_vars.end(); i++) { <a name="l00107"></a>00107 <a class="code" href="classlibdap_1_1BaseType.html" title="The basic data type for the DODS DAP types.">BaseType</a> *btp = *i ; <a name="l00108"></a>00108 <span class="keyword">delete</span> btp ; btp = 0; <a name="l00109"></a>00109 } <a name="l00110"></a>00110 } <a name="l00111"></a>00111 <a name="l00112"></a>00112 <a class="code" href="classlibdap_1_1BaseType.html" title="The basic data type for the DODS DAP types.">BaseType</a> * <a name="l00113"></a><a class="code" href="classlibdap_1_1Grid.html#0c4a5aefa252d3eab94b8a0ce5232dc6">00113</a> <a class="code" href="classlibdap_1_1Grid.html#0c4a5aefa252d3eab94b8a0ce5232dc6">Grid::ptr_duplicate</a>() <a name="l00114"></a>00114 { <a name="l00115"></a>00115 <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classlibdap_1_1Grid.html#75774a8fe1c7c7ec9a1e48a7d6d2cbc0" title="The Grid constructor.">Grid</a>(*<span class="keyword">this</span>); <a name="l00116"></a>00116 } <a name="l00117"></a>00117 <a name="l00118"></a>00118 <a class="code" href="classlibdap_1_1Grid.html" title="Holds the Grid data type.">Grid</a> & <a name="l00119"></a><a class="code" href="classlibdap_1_1Grid.html#ecf55730764a11b15858bb94b5a56988">00119</a> <a class="code" href="classlibdap_1_1Grid.html#ecf55730764a11b15858bb94b5a56988">Grid::operator=</a>(<span class="keyword">const</span> <a class="code" href="classlibdap_1_1Grid.html" title="Holds the Grid data type.">Grid</a> &rhs) <a name="l00120"></a>00120 { <a name="l00121"></a>00121 <span class="keywordflow">if</span> (<span class="keyword">this</span> == &rhs) <a name="l00122"></a>00122 <span class="keywordflow">return</span> *<span class="keyword">this</span>; <a name="l00123"></a>00123 <a name="l00124"></a>00124 <span class="keyword">delete</span> _array_var; _array_var = 0; <a name="l00125"></a>00125 <a name="l00126"></a>00126 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#69ee284e8087d1482373989f3256f95d">Map_iter</a> i = _map_vars.begin(); i != _map_vars.end(); i++) { <a name="l00127"></a>00127 <a class="code" href="classlibdap_1_1BaseType.html" title="The basic data type for the DODS DAP types.">BaseType</a> *btp = *i ; <a name="l00128"></a>00128 <span class="keyword">delete</span> btp ; <a name="l00129"></a>00129 } <a name="l00130"></a>00130 <a name="l00131"></a>00131 <span class="keyword">dynamic_cast<</span><a class="code" href="classlibdap_1_1Constructor.html">Constructor</a> &<span class="keyword">></span>(*this) = rhs; <a name="l00132"></a>00132 <a name="l00133"></a>00133 _duplicate(rhs); <a name="l00134"></a>00134 <a name="l00135"></a>00135 <span class="keywordflow">return</span> *<span class="keyword">this</span>; <a name="l00136"></a>00136 } <a name="l00137"></a>00137 <a name="l00138"></a>00138 <span class="keywordtype">int</span> <a name="l00139"></a><a class="code" href="classlibdap_1_1Grid.html#af8208db18a1ce7ddfeabed691815a3f">00139</a> <a class="code" href="classlibdap_1_1Grid.html#af8208db18a1ce7ddfeabed691815a3f" title="Count the members of constructor types.">Grid::element_count</a>(<span class="keywordtype">bool</span> leaves) <a name="l00140"></a>00140 { <a name="l00141"></a>00141 <span class="keywordflow">if</span> (!leaves) <a name="l00142"></a>00142 <span class="keywordflow">return</span> _map_vars.size() + 1; <a name="l00143"></a>00143 <span class="keywordflow">else</span> { <a name="l00144"></a>00144 <span class="keywordtype">int</span> i = 0; <a name="l00145"></a>00145 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#69ee284e8087d1482373989f3256f95d">Map_iter</a> j = _map_vars.begin(); j != _map_vars.end(); j++) { <a name="l00146"></a>00146 j += (*j)->element_count(leaves); <a name="l00147"></a>00147 } <a name="l00148"></a>00148 <a name="l00149"></a>00149 <span class="keywordflow">if</span> (!<a class="code" href="classlibdap_1_1Grid.html#905ac86a44a9d8ce576056ba244cf558" title="Returns the Grid Array. This method returns the array using an Array*, so no cast...">get_array</a>()) <a name="l00150"></a>00150 <span class="keywordflow">throw</span> <a class="code" href="classlibdap_1_1InternalErr.html" title="A class for software fault reporting.">InternalErr</a>(__FILE__, __LINE__, <span class="stringliteral">"No Grid arry!"</span>); <a name="l00151"></a>00151 <a name="l00152"></a>00152 i += <a class="code" href="classlibdap_1_1Grid.html#905ac86a44a9d8ce576056ba244cf558" title="Returns the Grid Array. This method returns the array using an Array*, so no cast...">get_array</a>()-><a class="code" href="classlibdap_1_1Vector.html#b78981c9e05e7d1dc24f913dbd2021d7" title="Count the members of constructor types.">element_count</a>(leaves); <a name="l00153"></a>00153 <span class="keywordflow">return</span> i; <a name="l00154"></a>00154 } <a name="l00155"></a>00155 } <a name="l00156"></a>00156 <a name="l00157"></a>00157 <span class="keywordtype">void</span> <a name="l00158"></a><a class="code" href="classlibdap_1_1Grid.html#20be3f6a4e09af668821f3f21fefcac6">00158</a> <a class="code" href="classlibdap_1_1Grid.html#20be3f6a4e09af668821f3f21fefcac6">Grid::set_send_p</a>(<span class="keywordtype">bool</span> state) <a name="l00159"></a>00159 { <a name="l00160"></a>00160 _array_var-><a class="code" href="classlibdap_1_1BaseType.html#ba7b27635c95b74536de18393133628e">set_send_p</a>(state); <a name="l00161"></a>00161 <a name="l00162"></a>00162 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#69ee284e8087d1482373989f3256f95d">Map_iter</a> i = _map_vars.begin(); i != _map_vars.end(); i++) { <a name="l00163"></a>00163 (*i)->set_send_p(state); <a name="l00164"></a>00164 } <a name="l00165"></a>00165 <a name="l00166"></a>00166 <a class="code" href="classlibdap_1_1Grid.html#20be3f6a4e09af668821f3f21fefcac6">BaseType::set_send_p</a>(state); <a name="l00167"></a>00167 } <a name="l00168"></a>00168 <a name="l00169"></a>00169 <span class="keywordtype">void</span> <a name="l00170"></a><a class="code" href="classlibdap_1_1Grid.html#daa3661e737987979357f5e10f208640">00170</a> <a class="code" href="classlibdap_1_1Grid.html#daa3661e737987979357f5e10f208640" title="Sets the value of the read_p property.">Grid::set_read_p</a>(<span class="keywordtype">bool</span> state) <a name="l00171"></a>00171 { <a name="l00172"></a>00172 _array_var-><a class="code" href="classlibdap_1_1BaseType.html#4533905a450d2a7af32e7d5acd557676" title="Sets the value of the read_p property.">set_read_p</a>(state); <a name="l00173"></a>00173 <a name="l00174"></a>00174 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#69ee284e8087d1482373989f3256f95d">Map_iter</a> i = _map_vars.begin(); i != _map_vars.end(); i++) { <a name="l00175"></a>00175 (*i)->set_read_p(state); <a name="l00176"></a>00176 } <a name="l00177"></a>00177 <a name="l00178"></a>00178 <a class="code" href="classlibdap_1_1Grid.html#daa3661e737987979357f5e10f208640" title="Sets the value of the read_p property.">BaseType::set_read_p</a>(state); <a name="l00179"></a>00179 } <a name="l00180"></a>00180 <a name="l00181"></a>00181 <span class="keywordtype">void</span> <a name="l00182"></a><a class="code" href="classlibdap_1_1Grid.html#35856e4d5f554daf96b465ba30661a50">00182</a> <a class="code" href="classlibdap_1_1Grid.html#35856e4d5f554daf96b465ba30661a50">Grid::set_in_selection</a>(<span class="keywordtype">bool</span> state) <a name="l00183"></a>00183 { <a name="l00184"></a>00184 _array_var-><a class="code" href="classlibdap_1_1BaseType.html#2bc036248cdaf1affac464170f32ad30">set_in_selection</a>(state); <a name="l00185"></a>00185 <a name="l00186"></a>00186 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#69ee284e8087d1482373989f3256f95d">Map_iter</a> i = _map_vars.begin(); i != _map_vars.end(); i++) { <a name="l00187"></a>00187 (*i)->set_in_selection(state); <a name="l00188"></a>00188 } <a name="l00189"></a>00189 <a name="l00190"></a>00190 <a class="code" href="classlibdap_1_1Grid.html#35856e4d5f554daf96b465ba30661a50">BaseType::set_in_selection</a>(state); <a name="l00191"></a>00191 } <a name="l00192"></a>00192 <a name="l00193"></a>00193 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a name="l00194"></a><a class="code" href="classlibdap_1_1Grid.html#f9984d996046137c078e7fbce7dc25a6">00194</a> <a class="code" href="classlibdap_1_1Grid.html#f9984d996046137c078e7fbce7dc25a6" title="Returns the size of the class instance data.">Grid::width</a>() <a name="l00195"></a>00195 { <a name="l00196"></a>00196 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> sz = _array_var-><a class="code" href="classlibdap_1_1BaseType.html#3058467f1e80a41f3cf1068ec9ec68ed" title="Returns the size of the class instance data.">width</a>(); <a name="l00197"></a>00197 <a name="l00198"></a>00198 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#69ee284e8087d1482373989f3256f95d">Map_iter</a> i = _map_vars.begin(); i != _map_vars.end(); i++) { <a name="l00199"></a>00199 sz += (*i)->width(); <a name="l00200"></a>00200 } <a name="l00201"></a>00201 <a name="l00202"></a>00202 <span class="keywordflow">return</span> sz; <a name="l00203"></a>00203 } <a name="l00204"></a>00204 <a name="l00205"></a>00205 <span class="keywordtype">void</span> <a name="l00206"></a><a class="code" href="classlibdap_1_1Grid.html#b3ee0a326a9dc7dc4528275601acbcd6">00206</a> <a class="code" href="classlibdap_1_1Grid.html#b3ee0a326a9dc7dc4528275601acbcd6">Grid::intern_data</a>(<a class="code" href="classlibdap_1_1ConstraintEvaluator.html" title="Evaluate a constraint expression.">ConstraintEvaluator</a> &eval, <a class="code" href="classlibdap_1_1DDS.html">DDS</a> &dds) <a name="l00207"></a>00207 { <a name="l00208"></a>00208 dds.<a class="code" href="classlibdap_1_1DDS.html#8cd9b6a34f5e1a49665de3189e141de8">timeout_on</a>(); <a name="l00209"></a>00209 <a name="l00210"></a>00210 <span class="keywordflow">if</span> (!<a class="code" href="classlibdap_1_1BaseType.html#38ff819a432217c55db2e9071928d20c" title="Has this variable been read?">read_p</a>()) <a name="l00211"></a>00211 <a class="code" href="classlibdap_1_1BaseType.html#1da003c53f2e663223f603ab3fbd7c8e" title="Read data into a local buffer.">read</a>(); <span class="comment">// read() throws Error and InternalErr</span> <a name="l00212"></a>00212 <a name="l00213"></a>00213 dds.<a class="code" href="classlibdap_1_1DDS.html#6740f99a5fc64640505924c5603ace0a">timeout_off</a>(); <a name="l00214"></a>00214 <a name="l00215"></a>00215 <span class="keywordflow">if</span> (_array_var-><a class="code" href="classlibdap_1_1BaseType.html#980c0013817836aa77ef74aeec7fb192" title="Should this variable be sent?">send_p</a>()) <a name="l00216"></a>00216 _array_var-><a class="code" href="classlibdap_1_1BaseType.html#722d33783aa0272d339b0301a4f77e59">intern_data</a>(eval, dds); <a name="l00217"></a>00217 <a name="l00218"></a>00218 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#69ee284e8087d1482373989f3256f95d">Map_iter</a> i = _map_vars.begin(); i != _map_vars.end(); i++) { <a name="l00219"></a>00219 <span class="keywordflow">if</span> ((*i)->send_p()) { <a name="l00220"></a>00220 (*i)->intern_data(eval, dds); <a name="l00221"></a>00221 } <a name="l00222"></a>00222 } <a name="l00223"></a>00223 } <a name="l00224"></a>00224 <a name="l00225"></a>00225 <span class="keywordtype">bool</span> <a name="l00226"></a><a class="code" href="classlibdap_1_1Grid.html#76fd548ab588e78f0dd08871631cde5e">00226</a> <a class="code" href="classlibdap_1_1Grid.html#76fd548ab588e78f0dd08871631cde5e" title="Move data to the net.">Grid::serialize</a>(<a class="code" href="classlibdap_1_1ConstraintEvaluator.html" title="Evaluate a constraint expression.">ConstraintEvaluator</a> &eval, <a class="code" href="classlibdap_1_1DDS.html">DDS</a> &dds, <a name="l00227"></a>00227 <a class="code" href="classlibdap_1_1Marshaller.html" title="abstract base class used to marshall/serialize dap data objects">Marshaller</a> &m, <span class="keywordtype">bool</span> ce_eval) <a name="l00228"></a>00228 { <a name="l00229"></a>00229 dds.<a class="code" href="classlibdap_1_1DDS.html#8cd9b6a34f5e1a49665de3189e141de8">timeout_on</a>(); <a name="l00230"></a>00230 <a name="l00231"></a>00231 <span class="comment">// Re ticket 560: Get an object from eval that describes how to sample</span> <a name="l00232"></a>00232 <span class="comment">// and rearrange the data, then perform those actions. Alternative:</span> <a name="l00233"></a>00233 <span class="comment">// implement this as a selection function.</span> <a name="l00234"></a>00234 <a name="l00235"></a>00235 <span class="keywordflow">if</span> (!<a class="code" href="classlibdap_1_1BaseType.html#38ff819a432217c55db2e9071928d20c" title="Has this variable been read?">read_p</a>()) <a name="l00236"></a>00236 <a class="code" href="classlibdap_1_1BaseType.html#1da003c53f2e663223f603ab3fbd7c8e" title="Read data into a local buffer.">read</a>(); <span class="comment">// read() throws Error and InternalErr</span> <a name="l00237"></a>00237 <a name="l00238"></a>00238 <span class="preprocessor">#if EVAL</span> <a name="l00239"></a>00239 <span class="preprocessor"></span> <span class="keywordflow">if</span> (ce_eval && !eval.<a class="code" href="classlibdap_1_1ConstraintEvaluator.html#a0066a57cf00c975f6ccbc2e90c64742" title="Evaluate a boolean-valued constraint expression. This is main method for the evaluator...">eval_selection</a>(dds, <a class="code" href="classlibdap_1_1BaseType.html#9f102f5cc17ac7d2d80f9921e10d3baf" title="Returns the name of the dataset used to create this instance.">dataset</a>())) <a name="l00240"></a>00240 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00241"></a>00241 <span class="preprocessor">#endif</span> <a name="l00242"></a>00242 <span class="preprocessor"></span> <a name="l00243"></a>00243 dds.<a class="code" href="classlibdap_1_1DDS.html#6740f99a5fc64640505924c5603ace0a">timeout_off</a>(); <a name="l00244"></a>00244 <a name="l00245"></a>00245 <span class="keywordflow">if</span> (_array_var-><a class="code" href="classlibdap_1_1BaseType.html#980c0013817836aa77ef74aeec7fb192" title="Should this variable be sent?">send_p</a>()) <a name="l00246"></a>00246 _array_var-><a class="code" href="classlibdap_1_1BaseType.html#1f45893684a69b50b37817b88230de9f" title="Move data to the net.">serialize</a>(eval, dds, m, <span class="keyword">false</span>); <a name="l00247"></a>00247 <a name="l00248"></a>00248 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#69ee284e8087d1482373989f3256f95d">Map_iter</a> i = _map_vars.begin(); i != _map_vars.end(); i++) { <a name="l00249"></a>00249 <span class="keywordflow">if</span> ((*i)->send_p()) { <a name="l00250"></a>00250 (*i)->serialize(eval, dds, m, <span class="keyword">false</span>); <a name="l00251"></a>00251 } <a name="l00252"></a>00252 } <a name="l00253"></a>00253 <a name="l00254"></a>00254 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00255"></a>00255 } <a name="l00256"></a>00256 <a name="l00257"></a>00257 <span class="keywordtype">bool</span> <a name="l00258"></a><a class="code" href="classlibdap_1_1Grid.html#5cfc24c934f487fe8c7f18c4c24666f5">00258</a> <a class="code" href="classlibdap_1_1Grid.html#5cfc24c934f487fe8c7f18c4c24666f5" title="Receive data from the net.">Grid::deserialize</a>(<a class="code" href="classlibdap_1_1UnMarshaller.html" title="abstract base class used to unmarshall/deserialize dap data objects">UnMarshaller</a> &um, <a class="code" href="classlibdap_1_1DDS.html">DDS</a> *dds, <span class="keywordtype">bool</span> reuse) <a name="l00259"></a>00259 { <a name="l00260"></a>00260 _array_var-><a class="code" href="classlibdap_1_1BaseType.html#a14891b5342c1ce06399343de8b716d0" title="Receive data from the net.">deserialize</a>(um, dds, reuse); <a name="l00261"></a>00261 <a name="l00262"></a>00262 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#69ee284e8087d1482373989f3256f95d">Map_iter</a> i = _map_vars.begin(); i != _map_vars.end(); i++) { <a name="l00263"></a>00263 (*i)->deserialize(um, dds, reuse); <a name="l00264"></a>00264 } <a name="l00265"></a>00265 <a name="l00266"></a>00266 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00267"></a>00267 } <a name="l00268"></a>00268 <a name="l00276"></a>00276 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a name="l00277"></a><a class="code" href="classlibdap_1_1Grid.html#d18e0142c959b4103d8e4e2f87c89552">00277</a> <a class="code" href="classlibdap_1_1Grid.html#d18e0142c959b4103d8e4e2f87c89552" title="Returns the size of the Grid type.">Grid::val2buf</a>(<span class="keywordtype">void</span> *, <span class="keywordtype">bool</span>) <a name="l00278"></a>00278 { <a name="l00279"></a>00279 <span class="keywordflow">return</span> <span class="keyword">sizeof</span>(<a class="code" href="classlibdap_1_1Grid.html" title="Holds the Grid data type.">Grid</a>); <a name="l00280"></a>00280 } <a name="l00281"></a>00281 <a name="l00285"></a>00285 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a name="l00286"></a><a class="code" href="classlibdap_1_1Grid.html#4b2053395c19b4e52cf75bb919aa8eae">00286</a> <a class="code" href="classlibdap_1_1Grid.html#4b2053395c19b4e52cf75bb919aa8eae">Grid::buf2val</a>(<span class="keywordtype">void</span> **) <a name="l00287"></a>00287 { <a name="l00288"></a>00288 <span class="keywordflow">return</span> <span class="keyword">sizeof</span>(<a class="code" href="classlibdap_1_1Grid.html" title="Holds the Grid data type.">Grid</a>); <a name="l00289"></a>00289 } <a name="l00290"></a>00290 <a name="l00291"></a>00291 <a class="code" href="classlibdap_1_1BaseType.html" title="The basic data type for the DODS DAP types.">BaseType</a> * <a name="l00292"></a><a class="code" href="classlibdap_1_1Grid.html#d9615a69ebc80b621658d466154bb1e6">00292</a> <a class="code" href="classlibdap_1_1Grid.html#d75c8aca61d68cc4a65430bc937ba3fc">Grid::var</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &n, <a class="code" href="classlibdap_1_1BaseType.html#e9c6e71855b90a0e552713011c9ab81f">btp_stack</a> &s) <a name="l00293"></a>00293 { <a name="l00294"></a>00294 <span class="keywordflow">return</span> <a class="code" href="classlibdap_1_1Grid.html#d75c8aca61d68cc4a65430bc937ba3fc">var</a>(n, <span class="keyword">true</span>, &s); <a name="l00295"></a>00295 } <a name="l00296"></a>00296 <a name="l00301"></a>00301 <a class="code" href="classlibdap_1_1BaseType.html" title="The basic data type for the DODS DAP types.">BaseType</a> * <a name="l00302"></a><a class="code" href="classlibdap_1_1Grid.html#d75c8aca61d68cc4a65430bc937ba3fc">00302</a> <a class="code" href="classlibdap_1_1Grid.html#d75c8aca61d68cc4a65430bc937ba3fc">Grid::var</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &n, <span class="keywordtype">bool</span>, <a class="code" href="classlibdap_1_1BaseType.html#e9c6e71855b90a0e552713011c9ab81f">btp_stack</a> *s) <a name="l00303"></a>00303 { <a name="l00304"></a>00304 <span class="keywordtype">string</span> <a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a> = <a class="code" href="namespacelibdap.html#376f9593431111a80ef78c98b8f4a0e2">www2id</a>(n); <a name="l00305"></a>00305 <a name="l00306"></a>00306 <span class="keywordflow">if</span> (_array_var-><a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>() == name) { <a name="l00307"></a>00307 <span class="keywordflow">if</span> (s) <a name="l00308"></a>00308 s->push(static_cast<BaseType *>(<span class="keyword">this</span>)); <a name="l00309"></a>00309 <span class="keywordflow">return</span> _array_var; <a name="l00310"></a>00310 } <a name="l00311"></a>00311 <a name="l00312"></a>00312 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#69ee284e8087d1482373989f3256f95d">Map_iter</a> i = _map_vars.begin(); i != _map_vars.end(); i++) { <a name="l00313"></a>00313 <span class="keywordflow">if</span> ((*i)->name() == name) { <a name="l00314"></a>00314 <span class="keywordflow">if</span> (s) <a name="l00315"></a>00315 s->push(static_cast<BaseType *>(<span class="keyword">this</span>)); <a name="l00316"></a>00316 <span class="keywordflow">return</span> *i; <a name="l00317"></a>00317 } <a name="l00318"></a>00318 } <a name="l00319"></a>00319 <a name="l00320"></a>00320 <span class="keywordflow">return</span> 0; <a name="l00321"></a>00321 } <a name="l00322"></a>00322 <a name="l00335"></a>00335 <span class="keywordtype">void</span> <a name="l00336"></a><a class="code" href="classlibdap_1_1Grid.html#e8356b6e1b8c6c67718bb9bfefd9f7e8">00336</a> <a class="code" href="classlibdap_1_1Grid.html#e8356b6e1b8c6c67718bb9bfefd9f7e8">Grid::add_var</a>(<a class="code" href="classlibdap_1_1BaseType.html" title="The basic data type for the DODS DAP types.">BaseType</a> *bt, <a class="code" href="namespacelibdap.html#ddcb1d714cdecb877c65ff6d2fde0695" title="Names the parts of multi-section constructor data types.">Part</a> part) <a name="l00337"></a>00337 { <a name="l00338"></a>00338 <span class="keywordflow">if</span> (!bt) <a name="l00339"></a>00339 <span class="keywordflow">throw</span> <a class="code" href="classlibdap_1_1InternalErr.html" title="A class for software fault reporting.">InternalErr</a>(__FILE__, __LINE__, <a name="l00340"></a>00340 <span class="stringliteral">"Passing NULL pointer as variable to be added."</span>); <a name="l00341"></a>00341 <a name="l00342"></a>00342 <span class="comment">// Jose Garcia</span> <a name="l00343"></a>00343 <span class="comment">// Now we get a copy of the maps or of the array</span> <a name="l00344"></a>00344 <span class="comment">// so the owner of bt which is external to libdap++</span> <a name="l00345"></a>00345 <span class="comment">// is free to deallocate its object.</span> <a name="l00346"></a>00346 <span class="keywordflow">switch</span> (part) { <a name="l00347"></a>00347 <span class="keywordflow">case</span> <a class="code" href="namespacelibdap.html#ddcb1d714cdecb877c65ff6d2fde0695ed5453774cf1a62b2f92c0c70b989247">array</a>: <a name="l00348"></a>00348 _array_var = bt-><a class="code" href="classlibdap_1_1BaseType.html#0b130311c9901fb8a7ab11ea19090ef0">ptr_duplicate</a>(); <a name="l00349"></a>00349 _array_var-><a class="code" href="classlibdap_1_1BaseType.html#5b6a39f6ce6594fa74f3fc899ac9a966">set_parent</a>(<span class="keyword">this</span>); <a name="l00350"></a>00350 <span class="keywordflow">return</span>; <a name="l00351"></a>00351 <span class="keywordflow">case</span> <a class="code" href="namespacelibdap.html#ddcb1d714cdecb877c65ff6d2fde0695aa7dc708bd26f663a00ecf52a673da1b">maps</a>: { <a name="l00352"></a>00352 <a class="code" href="classlibdap_1_1BaseType.html" title="The basic data type for the DODS DAP types.">BaseType</a> *btp = bt-><a class="code" href="classlibdap_1_1BaseType.html#0b130311c9901fb8a7ab11ea19090ef0">ptr_duplicate</a>(); <a name="l00353"></a>00353 btp-><a class="code" href="classlibdap_1_1BaseType.html#5b6a39f6ce6594fa74f3fc899ac9a966">set_parent</a>(<span class="keyword">this</span>); <a name="l00354"></a>00354 _map_vars.push_back(btp); <a name="l00355"></a>00355 <span class="keywordflow">return</span>; <a name="l00356"></a>00356 } <a name="l00357"></a>00357 <span class="keywordflow">default</span>: <a name="l00358"></a>00358 <span class="keywordflow">if</span> (!_array_var) { <a name="l00359"></a>00359 _array_var = bt-><a class="code" href="classlibdap_1_1BaseType.html#0b130311c9901fb8a7ab11ea19090ef0">ptr_duplicate</a>(); <a name="l00360"></a>00360 _array_var-><a class="code" href="classlibdap_1_1BaseType.html#5b6a39f6ce6594fa74f3fc899ac9a966">set_parent</a>(<span class="keyword">this</span>); <a name="l00361"></a>00361 } <a name="l00362"></a>00362 <span class="keywordflow">else</span> { <a name="l00363"></a>00363 <a class="code" href="classlibdap_1_1BaseType.html" title="The basic data type for the DODS DAP types.">BaseType</a> *btp = bt-><a class="code" href="classlibdap_1_1BaseType.html#0b130311c9901fb8a7ab11ea19090ef0">ptr_duplicate</a>(); <a name="l00364"></a>00364 btp-><a class="code" href="classlibdap_1_1BaseType.html#5b6a39f6ce6594fa74f3fc899ac9a966">set_parent</a>(<span class="keyword">this</span>); <a name="l00365"></a>00365 _map_vars.push_back(btp); <a name="l00366"></a>00366 } <a name="l00367"></a>00367 <span class="keywordflow">return</span>; <a name="l00368"></a>00368 } <a name="l00369"></a>00369 } <a name="l00370"></a>00370 <a name="l00374"></a>00374 <a class="code" href="classlibdap_1_1BaseType.html" title="The basic data type for the DODS DAP types.">BaseType</a> * <a name="l00375"></a><a class="code" href="classlibdap_1_1Grid.html#13f73ec1242460db6be3b7a818c8328f">00375</a> <a class="code" href="classlibdap_1_1Grid.html#13f73ec1242460db6be3b7a818c8328f" title="Returns the Grid Array.">Grid::array_var</a>() <a name="l00376"></a>00376 { <a name="l00377"></a>00377 <span class="keywordflow">return</span> _array_var; <a name="l00378"></a>00378 } <a name="l00379"></a>00379 <a name="l00383"></a>00383 <a class="code" href="classlibdap_1_1Array.html" title="A multidimensional array of identical data types.">Array</a> * <a name="l00384"></a><a class="code" href="classlibdap_1_1Grid.html#905ac86a44a9d8ce576056ba244cf558">00384</a> <a class="code" href="classlibdap_1_1Grid.html#905ac86a44a9d8ce576056ba244cf558" title="Returns the Grid Array. This method returns the array using an Array*, so no cast...">Grid::get_array</a>() <a name="l00385"></a>00385 { <a name="l00386"></a>00386 <a class="code" href="classlibdap_1_1Array.html" title="A multidimensional array of identical data types.">Array</a> *a = <span class="keyword">dynamic_cast<</span><a class="code" href="classlibdap_1_1Array.html" title="A multidimensional array of identical data types.">Array</a>*<span class="keyword">></span>(_array_var); <a name="l00387"></a>00387 <span class="keywordflow">if</span> (a) <a name="l00388"></a>00388 <span class="keywordflow">return</span> a; <a name="l00389"></a>00389 <span class="keywordflow">else</span> <a name="l00390"></a>00390 <span class="keywordflow">throw</span> <a class="code" href="classlibdap_1_1InternalErr.html" title="A class for software fault reporting.">InternalErr</a>(__FILE__, __LINE__, <span class="stringliteral">"bad Cast"</span>); <a name="l00391"></a>00391 } <a name="l00392"></a>00392 <a name="l00394"></a>00394 <a class="code" href="classlibdap_1_1Grid.html#69ee284e8087d1482373989f3256f95d">Grid::Map_iter</a> <a name="l00395"></a><a class="code" href="classlibdap_1_1Grid.html#2e9d2e436c0ff138a977dbba54c018eb">00395</a> <a class="code" href="classlibdap_1_1Grid.html#2e9d2e436c0ff138a977dbba54c018eb" title="Returns an iterator referencing the first Map vector.">Grid::map_begin</a>() <a name="l00396"></a>00396 { <a name="l00397"></a>00397 <span class="keywordflow">return</span> _map_vars.begin() ; <a name="l00398"></a>00398 } <a name="l00399"></a>00399 <a name="l00402"></a>00402 <a class="code" href="classlibdap_1_1Grid.html#69ee284e8087d1482373989f3256f95d">Grid::Map_iter</a> <a name="l00403"></a><a class="code" href="classlibdap_1_1Grid.html#aebbf2a5329ec01b6527b4bafde87837">00403</a> <a class="code" href="classlibdap_1_1Grid.html#aebbf2a5329ec01b6527b4bafde87837">Grid::map_end</a>() <a name="l00404"></a>00404 { <a name="l00405"></a>00405 <span class="keywordflow">return</span> _map_vars.end() ; <a name="l00406"></a>00406 } <a name="l00407"></a>00407 <a name="l00409"></a>00409 <a class="code" href="classlibdap_1_1Grid.html#1c1791bdfac09f6ec42a71089fdccc75">Grid::Map_riter</a> <a name="l00410"></a><a class="code" href="classlibdap_1_1Grid.html#fdddc12f67c7f4f6bb6c78d55a2f75b2">00410</a> <a class="code" href="classlibdap_1_1Grid.html#fdddc12f67c7f4f6bb6c78d55a2f75b2" title="Returns an iterator referencing the first Map vector.">Grid::map_rbegin</a>() <a name="l00411"></a>00411 { <a name="l00412"></a>00412 <span class="keywordflow">return</span> _map_vars.rbegin() ; <a name="l00413"></a>00413 } <a name="l00414"></a>00414 <a name="l00417"></a>00417 <a class="code" href="classlibdap_1_1Grid.html#1c1791bdfac09f6ec42a71089fdccc75">Grid::Map_riter</a> <a name="l00418"></a><a class="code" href="classlibdap_1_1Grid.html#b821c8beb7c653ce38842fcb27d644ca">00418</a> <a class="code" href="classlibdap_1_1Grid.html#b821c8beb7c653ce38842fcb27d644ca">Grid::map_rend</a>() <a name="l00419"></a>00419 { <a name="l00420"></a>00420 <span class="keywordflow">return</span> _map_vars.rend() ; <a name="l00421"></a>00421 } <a name="l00422"></a>00422 <a name="l00426"></a>00426 <a class="code" href="classlibdap_1_1Grid.html#69ee284e8087d1482373989f3256f95d">Grid::Map_iter</a> <a name="l00427"></a><a class="code" href="classlibdap_1_1Grid.html#30dd7f9fa8a28b4bf6ccd6e94a12b62c">00427</a> <a class="code" href="classlibdap_1_1Grid.html#30dd7f9fa8a28b4bf6ccd6e94a12b62c">Grid::get_map_iter</a>(<span class="keywordtype">int</span> i) <a name="l00428"></a>00428 { <a name="l00429"></a>00429 <span class="keywordflow">return</span> _map_vars.begin() + i; <a name="l00430"></a>00430 } <a name="l00431"></a>00431 <a name="l00447"></a>00447 <span class="keywordtype">int</span> <a name="l00448"></a><a class="code" href="classlibdap_1_1Grid.html#d26dc472b37af0abeb540a43fb04d8dc">00448</a> <a class="code" href="classlibdap_1_1Grid.html#d26dc472b37af0abeb540a43fb04d8dc" title="Returns the number of components in the Grid object.">Grid::components</a>(<span class="keywordtype">bool</span> constrained) <a name="l00449"></a>00449 { <a name="l00450"></a>00450 <span class="keywordtype">int</span> comp; <a name="l00451"></a>00451 <a name="l00452"></a>00452 <span class="keywordflow">if</span> (constrained) { <a name="l00453"></a>00453 comp = _array_var-><a class="code" href="classlibdap_1_1BaseType.html#980c0013817836aa77ef74aeec7fb192" title="Should this variable be sent?">send_p</a>() ? 1 : 0; <a name="l00454"></a>00454 <a name="l00455"></a>00455 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#69ee284e8087d1482373989f3256f95d">Map_iter</a> i = _map_vars.begin(); i != _map_vars.end(); i++) { <a name="l00456"></a>00456 <span class="keywordflow">if</span> ((*i)->send_p()) { <a name="l00457"></a>00457 comp++; <a name="l00458"></a>00458 } <a name="l00459"></a>00459 } <a name="l00460"></a>00460 } <a name="l00461"></a>00461 <span class="keywordflow">else</span> { <a name="l00462"></a>00462 comp = 1 + _map_vars.size(); <a name="l00463"></a>00463 } <a name="l00464"></a>00464 <a name="l00465"></a>00465 <span class="keywordflow">return</span> comp; <a name="l00466"></a>00466 } <a name="l00467"></a>00467 <a name="l00468"></a>00468 <span class="comment">// When projected (using whatever the current constraint provides in the way</span> <a name="l00469"></a>00469 <span class="comment">// of a projection), is the object still a Grid?</span> <a name="l00470"></a>00470 <a name="l00487"></a>00487 <span class="keywordtype">bool</span> <a name="l00488"></a><a class="code" href="classlibdap_1_1Grid.html#a737cef63a1b9c8b8b0952fcb22a621b">00488</a> <a class="code" href="classlibdap_1_1Grid.html#a737cef63a1b9c8b8b0952fcb22a621b">Grid::projection_yields_grid</a>() <a name="l00489"></a>00489 { <a name="l00490"></a>00490 <span class="comment">// For each dimension in the Array part, check the corresponding Map</span> <a name="l00491"></a>00491 <span class="comment">// vector to make sure it is present in the projected Grid. If for each</span> <a name="l00492"></a>00492 <span class="comment">// projected dimension in the Array component, there is a matching Map</span> <a name="l00493"></a>00493 <span class="comment">// vector, then the Grid is valid.</span> <a name="l00494"></a>00494 <span class="keywordtype">bool</span> valid = <span class="keyword">true</span>; <a name="l00495"></a>00495 <a class="code" href="classlibdap_1_1Array.html" title="A multidimensional array of identical data types.">Array</a> *a = (<a class="code" href="classlibdap_1_1Array.html" title="A multidimensional array of identical data types.">Array</a> *)_array_var; <a name="l00496"></a>00496 <a name="l00497"></a>00497 <span class="comment">// Don't bother checking if the Array component is not included.</span> <a name="l00498"></a>00498 <span class="keywordflow">if</span> (!a-><a class="code" href="classlibdap_1_1BaseType.html#980c0013817836aa77ef74aeec7fb192" title="Should this variable be sent?">send_p</a>()) <a name="l00499"></a>00499 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00500"></a>00500 <a name="l00501"></a>00501 <a class="code" href="classlibdap_1_1Array.html#7a557c05085a83d1501dbfa249d3cc52">Array::Dim_iter</a> i = a-><a class="code" href="classlibdap_1_1Array.html#e6e6943cd895fa8dc1c58621ffad42a0">dim_begin</a>() ; <a name="l00502"></a>00502 <a class="code" href="classlibdap_1_1Grid.html#69ee284e8087d1482373989f3256f95d">Map_iter</a> m = <a class="code" href="classlibdap_1_1Grid.html#2e9d2e436c0ff138a977dbba54c018eb" title="Returns an iterator referencing the first Map vector.">map_begin</a>() ; <a name="l00503"></a>00503 <span class="keywordflow">for</span> (; valid && i != a-><a class="code" href="classlibdap_1_1Array.html#1e6b13c4a5d3e825df7ebae3a9dc300d">dim_end</a>() && m != <a class="code" href="classlibdap_1_1Grid.html#aebbf2a5329ec01b6527b4bafde87837">map_end</a>(); i++, m++) { <a name="l00504"></a>00504 <span class="keywordflow">if</span> (a-><a class="code" href="classlibdap_1_1Array.html#8f29497af9c33c0d66939d5f9a16d92a" title="Returns the size of the dimension.">dimension_size</a>(i, <span class="keyword">true</span>)) { <a name="l00505"></a>00505 <span class="comment">// Check the matching Map vector; the Map projection must equal</span> <a name="l00506"></a>00506 <span class="comment">// the Array dimension projection</span> <a name="l00507"></a>00507 <a class="code" href="classlibdap_1_1Array.html" title="A multidimensional array of identical data types.">Array</a> *map = (<a class="code" href="classlibdap_1_1Array.html" title="A multidimensional array of identical data types.">Array</a> *)(*m); <a name="l00508"></a>00508 <a class="code" href="classlibdap_1_1Array.html#7a557c05085a83d1501dbfa249d3cc52">Array::Dim_iter</a> fd = map-><a class="code" href="classlibdap_1_1Array.html#e6e6943cd895fa8dc1c58621ffad42a0">dim_begin</a>(); <span class="comment">// Maps have only one dim!</span> <a name="l00509"></a>00509 valid = map-><a class="code" href="classlibdap_1_1Array.html#12084880777d27d782b0e1f2f4d5ae01" title="Return the start index of a dimension.">dimension_start</a>(fd, <span class="keyword">true</span>) <a name="l00510"></a>00510 == a-><a class="code" href="classlibdap_1_1Array.html#12084880777d27d782b0e1f2f4d5ae01" title="Return the start index of a dimension.">dimension_start</a>(i, <span class="keyword">true</span>) <a name="l00511"></a>00511 && map-><a class="code" href="classlibdap_1_1Array.html#446f239be3ef678a4476058c8041552a" title="Return the stop index of the constraint.">dimension_stop</a>(fd, <span class="keyword">true</span>) <a name="l00512"></a>00512 == a-><a class="code" href="classlibdap_1_1Array.html#446f239be3ef678a4476058c8041552a" title="Return the stop index of the constraint.">dimension_stop</a>(i, <span class="keyword">true</span>) <a name="l00513"></a>00513 && map-><a class="code" href="classlibdap_1_1Array.html#fc530e71ace953992a5b314a6f885d31" title="Returns the stride value of the constraint.">dimension_stride</a>(fd, <span class="keyword">true</span>) <a name="l00514"></a>00514 == a-><a class="code" href="classlibdap_1_1Array.html#fc530e71ace953992a5b314a6f885d31" title="Returns the stride value of the constraint.">dimension_stride</a>(i, <span class="keyword">true</span>); <a name="l00515"></a>00515 } <a name="l00516"></a>00516 <span class="keywordflow">else</span> { <a name="l00517"></a>00517 <span class="comment">// Corresponding Map vector must be excluded from the projection.</span> <a name="l00518"></a>00518 <a class="code" href="classlibdap_1_1Array.html" title="A multidimensional array of identical data types.">Array</a> *map = (<a class="code" href="classlibdap_1_1Array.html" title="A multidimensional array of identical data types.">Array</a> *)(*m); <a name="l00519"></a>00519 valid = !map-><a class="code" href="classlibdap_1_1BaseType.html#980c0013817836aa77ef74aeec7fb192" title="Should this variable be sent?">send_p</a>(); <a name="l00520"></a>00520 } <a name="l00521"></a>00521 } <a name="l00522"></a>00522 <a name="l00523"></a>00523 <span class="keywordflow">return</span> valid; <a name="l00524"></a>00524 } <a name="l00525"></a>00525 <a name="l00527"></a>00527 <span class="keywordtype">void</span> <a name="l00528"></a><a class="code" href="classlibdap_1_1Grid.html#3b7ce41c5ab7b86bdb30508d39127600">00528</a> <a class="code" href="classlibdap_1_1Grid.html#3b7ce41c5ab7b86bdb30508d39127600">Grid::clear_constraint</a>() <a name="l00529"></a>00529 { <a name="l00530"></a>00530 <span class="keyword">dynamic_cast<</span><a class="code" href="classlibdap_1_1Array.html" title="A multidimensional array of identical data types.">Array</a>&<span class="keyword">></span>(*_array_var).clear_constraint(); <a name="l00531"></a>00531 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#69ee284e8087d1482373989f3256f95d">Map_iter</a> m = <a class="code" href="classlibdap_1_1Grid.html#2e9d2e436c0ff138a977dbba54c018eb" title="Returns an iterator referencing the first Map vector.">map_begin</a>(); m != <a class="code" href="classlibdap_1_1Grid.html#aebbf2a5329ec01b6527b4bafde87837">map_end</a>(); ++m) <a name="l00532"></a>00532 dynamic_cast<Array&>(*(*m)).<a class="code" href="classlibdap_1_1Grid.html#3b7ce41c5ab7b86bdb30508d39127600">clear_constraint</a>(); <a name="l00533"></a>00533 } <a name="l00534"></a>00534 <span class="comment">//#if FILE_METHODS</span> <a name="l00535"></a>00535 <span class="keywordtype">void</span> <a name="l00536"></a><a class="code" href="classlibdap_1_1Grid.html#1c0bcf75f8474ef140d133f47a78ed67">00536</a> <a class="code" href="classlibdap_1_1Grid.html#5a239b053928636e13e3a478faf8e334" title="Print an ASCII representation of the variable structure.">Grid::print_decl</a>(FILE *out, <span class="keywordtype">string</span> space, <span class="keywordtype">bool</span> print_semi, <a name="l00537"></a>00537 <span class="keywordtype">bool</span> constraint_info, <span class="keywordtype">bool</span> constrained) <a name="l00538"></a>00538 { <a name="l00539"></a>00539 <span class="keywordflow">if</span> (constrained && !<a class="code" href="classlibdap_1_1BaseType.html#980c0013817836aa77ef74aeec7fb192" title="Should this variable be sent?">send_p</a>()) <a name="l00540"></a>00540 <span class="keywordflow">return</span>; <a name="l00541"></a>00541 <a name="l00542"></a>00542 <span class="comment">// If we are printing the declaration of a constrained Grid then check for</span> <a name="l00543"></a>00543 <span class="comment">// the case where the projection removes all but one component; the</span> <a name="l00544"></a>00544 <span class="comment">// resulting object is a simple array.</span> <a name="l00545"></a>00545 <span class="keywordtype">int</span> projection = <a class="code" href="classlibdap_1_1Grid.html#d26dc472b37af0abeb540a43fb04d8dc" title="Returns the number of components in the Grid object.">components</a>(<span class="keyword">true</span>); <a name="l00546"></a>00546 <span class="keywordflow">if</span> (constrained && projection == 1) { <a name="l00547"></a>00547 _array_var-><a class="code" href="classlibdap_1_1BaseType.html#2d799fad93255d7f2b803562ae7a5784" title="Print an ASCII representation of the variable structure.">print_decl</a>(out, space, print_semi <span class="comment">/*true*/</span>, constraint_info, <a name="l00548"></a>00548 constrained); <a name="l00549"></a>00549 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#d147322e168c6750893b6913d7f3edc5">Map_citer</a> i = _map_vars.begin(); i != _map_vars.end(); i++) { <a name="l00550"></a>00550 (*i)->print_decl(out, space, print_semi <span class="comment">/*true*/</span>, constraint_info, constrained); <a name="l00551"></a>00551 } <a name="l00552"></a>00552 <a name="l00553"></a>00553 <span class="keywordflow">goto</span> exit; <span class="comment">// Skip end material.</span> <a name="l00554"></a>00554 } <a name="l00555"></a>00555 <span class="comment">// If there are M (< N) componets (Array and Maps combined) in a N</span> <a name="l00556"></a>00556 <span class="comment">// component Grid, send the M components as elements of a Struture.</span> <a name="l00557"></a>00557 <span class="comment">// This will preserve the grouping without violating the rules for a</span> <a name="l00558"></a>00558 <span class="comment">// Grid.</span> <a name="l00559"></a>00559 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (constrained && !<a class="code" href="classlibdap_1_1Grid.html#a737cef63a1b9c8b8b0952fcb22a621b">projection_yields_grid</a>()) { <a name="l00560"></a>00560 fprintf(out, <span class="stringliteral">"%sStructure {\n"</span>, space.c_str()) ; <a name="l00561"></a>00561 <a name="l00562"></a>00562 _array_var-><a class="code" href="classlibdap_1_1BaseType.html#2d799fad93255d7f2b803562ae7a5784" title="Print an ASCII representation of the variable structure.">print_decl</a>(out, space + <span class="stringliteral">" "</span>, <span class="keyword">true</span>, constraint_info, <a name="l00563"></a>00563 constrained); <a name="l00564"></a>00564 <a name="l00565"></a>00565 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#d147322e168c6750893b6913d7f3edc5">Map_citer</a> i = _map_vars.begin(); i != _map_vars.end(); i++) { <a name="l00566"></a>00566 (*i)->print_decl(out, space + <span class="stringliteral">" "</span>, <span class="keyword">true</span>, <a name="l00567"></a>00567 constraint_info, constrained); <a name="l00568"></a>00568 } <a name="l00569"></a>00569 <a name="l00570"></a>00570 fprintf(out, <span class="stringliteral">"%s} %s"</span>, space.c_str(), <a class="code" href="namespacelibdap.html#fbd709ed83699c11234a213463d16b9c">id2www</a>(<a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>()).c_str()) ; <a name="l00571"></a>00571 } <a name="l00572"></a>00572 <span class="keywordflow">else</span> { <a name="l00573"></a>00573 <span class="comment">// The number of elements in the (projected) Grid must be such that</span> <a name="l00574"></a>00574 <span class="comment">// we have a valid Grid object; send it as such.</span> <a name="l00575"></a>00575 fprintf(out, <span class="stringliteral">"%s%s {\n"</span>, space.c_str(), <a class="code" href="classlibdap_1_1BaseType.html#c4461c9e287b167871acade5e5472116" title="Returns the type of the class instance as a string.">type_name</a>().c_str()) ; <a name="l00576"></a>00576 <a name="l00577"></a>00577 fprintf(out, <span class="stringliteral">"%s Array:\n"</span>, space.c_str()) ; <a name="l00578"></a>00578 _array_var-><a class="code" href="classlibdap_1_1BaseType.html#2d799fad93255d7f2b803562ae7a5784" title="Print an ASCII representation of the variable structure.">print_decl</a>(out, space + <span class="stringliteral">" "</span>, <span class="keyword">true</span>, constraint_info, <a name="l00579"></a>00579 constrained); <a name="l00580"></a>00580 <a name="l00581"></a>00581 fprintf(out, <span class="stringliteral">"%s Maps:\n"</span>, space.c_str()) ; <a name="l00582"></a>00582 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#d147322e168c6750893b6913d7f3edc5">Map_citer</a> i = _map_vars.begin(); i != _map_vars.end(); i++) { <a name="l00583"></a>00583 (*i)->print_decl(out, space + <span class="stringliteral">" "</span>, <span class="keyword">true</span>, <a name="l00584"></a>00584 constraint_info, constrained); <a name="l00585"></a>00585 } <a name="l00586"></a>00586 <a name="l00587"></a>00587 fprintf(out, <span class="stringliteral">"%s} %s"</span>, space.c_str(), <a class="code" href="namespacelibdap.html#fbd709ed83699c11234a213463d16b9c">id2www</a>(<a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>()).c_str()) ; <a name="l00588"></a>00588 } <a name="l00589"></a>00589 <a name="l00590"></a>00590 <span class="keywordflow">if</span> (constraint_info) { <a name="l00591"></a>00591 <span class="keywordflow">if</span> (<a class="code" href="classlibdap_1_1BaseType.html#980c0013817836aa77ef74aeec7fb192" title="Should this variable be sent?">send_p</a>()) <a name="l00592"></a>00592 fprintf( out, <span class="stringliteral">": Send True"</span>); <a name="l00593"></a>00593 <span class="keywordflow">else</span> <a name="l00594"></a>00594 fprintf( out, <span class="stringliteral">": Send False"</span>); <a name="l00595"></a>00595 } <a name="l00596"></a>00596 <a name="l00597"></a>00597 <span class="keywordflow">if</span> (print_semi) <a name="l00598"></a>00598 fprintf(out, <span class="stringliteral">";\n"</span>) ; <a name="l00599"></a>00599 <a name="l00600"></a>00600 <span class="comment">// If sending just one comp, skip sending the terminal semicolon, etc.</span> <a name="l00601"></a>00601 exit: <a name="l00602"></a>00602 <span class="keywordflow">return</span>; <a name="l00603"></a>00603 } <a name="l00604"></a>00604 <span class="comment">//#endif</span> <a name="l00605"></a>00605 <span class="keywordtype">void</span> <a name="l00606"></a><a class="code" href="classlibdap_1_1Grid.html#5a239b053928636e13e3a478faf8e334">00606</a> <a class="code" href="classlibdap_1_1Grid.html#5a239b053928636e13e3a478faf8e334" title="Print an ASCII representation of the variable structure.">Grid::print_decl</a>(ostream &out, <span class="keywordtype">string</span> space, <span class="keywordtype">bool</span> print_semi, <a name="l00607"></a>00607 <span class="keywordtype">bool</span> constraint_info, <span class="keywordtype">bool</span> constrained) <a name="l00608"></a>00608 { <a name="l00609"></a>00609 <span class="keywordflow">if</span> (constrained && !<a class="code" href="classlibdap_1_1BaseType.html#980c0013817836aa77ef74aeec7fb192" title="Should this variable be sent?">send_p</a>()) <a name="l00610"></a>00610 <span class="keywordflow">return</span>; <a name="l00611"></a>00611 <a name="l00612"></a>00612 <span class="comment">// If we are printing the declaration of a constrained Grid then check for</span> <a name="l00613"></a>00613 <span class="comment">// the case where the projection removes all but one component; the</span> <a name="l00614"></a>00614 <span class="comment">// resulting object is a simple array.</span> <a name="l00615"></a>00615 <span class="comment">//</span> <a name="l00616"></a>00616 <span class="comment">// I replaced the 'true' with the value of 'print_semi' passed in by the</span> <a name="l00617"></a>00617 <span class="comment">// caller. This fixes an issue with the intern_data tests and does not</span> <a name="l00618"></a>00618 <span class="comment">// seem to break anything else. jhrg 11/9/07</span> <a name="l00619"></a>00619 <span class="keywordtype">int</span> projection = <a class="code" href="classlibdap_1_1Grid.html#d26dc472b37af0abeb540a43fb04d8dc" title="Returns the number of components in the Grid object.">components</a>(<span class="keyword">true</span>); <a name="l00620"></a>00620 <span class="keywordflow">if</span> (constrained && projection == 1) { <a name="l00621"></a>00621 _array_var-><a class="code" href="classlibdap_1_1BaseType.html#2d799fad93255d7f2b803562ae7a5784" title="Print an ASCII representation of the variable structure.">print_decl</a>(out, space, print_semi <span class="comment">/*true*/</span>, constraint_info, <a name="l00622"></a>00622 constrained); <a name="l00623"></a>00623 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#d147322e168c6750893b6913d7f3edc5">Map_citer</a> i = _map_vars.begin(); i != _map_vars.end(); i++) { <a name="l00624"></a>00624 (*i)->print_decl(out, space, print_semi <span class="comment">/*true*/</span>, constraint_info, constrained); <a name="l00625"></a>00625 } <a name="l00626"></a>00626 <a name="l00627"></a>00627 <span class="keywordflow">goto</span> exit; <span class="comment">// Skip end material.</span> <a name="l00628"></a>00628 } <a name="l00629"></a>00629 <span class="comment">// If there are M (< N) components (Array and Maps combined) in a N</span> <a name="l00630"></a>00630 <span class="comment">// component Grid, send the M components as elements of a Structure.</span> <a name="l00631"></a>00631 <span class="comment">// This will preserve the grouping without violating the rules for a</span> <a name="l00632"></a>00632 <span class="comment">// Grid.</span> <a name="l00633"></a>00633 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (constrained && !<a class="code" href="classlibdap_1_1Grid.html#a737cef63a1b9c8b8b0952fcb22a621b">projection_yields_grid</a>()) { <a name="l00634"></a>00634 out << space << <span class="stringliteral">"Structure {\n"</span> ; <a name="l00635"></a>00635 <a name="l00636"></a>00636 _array_var-><a class="code" href="classlibdap_1_1BaseType.html#2d799fad93255d7f2b803562ae7a5784" title="Print an ASCII representation of the variable structure.">print_decl</a>(out, space + <span class="stringliteral">" "</span>, <span class="keyword">true</span>, constraint_info, <a name="l00637"></a>00637 constrained); <a name="l00638"></a>00638 <a name="l00639"></a>00639 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#d147322e168c6750893b6913d7f3edc5">Map_citer</a> i = _map_vars.begin(); i != _map_vars.end(); i++) { <a name="l00640"></a>00640 (*i)->print_decl(out, space + <span class="stringliteral">" "</span>, <span class="keyword">true</span>, <a name="l00641"></a>00641 constraint_info, constrained); <a name="l00642"></a>00642 } <a name="l00643"></a>00643 <a name="l00644"></a>00644 out << space << <span class="stringliteral">"} "</span> << <a class="code" href="namespacelibdap.html#fbd709ed83699c11234a213463d16b9c">id2www</a>(<a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>()) ; <a name="l00645"></a>00645 } <a name="l00646"></a>00646 <span class="keywordflow">else</span> { <a name="l00647"></a>00647 <span class="comment">// The number of elements in the (projected) Grid must be such that</span> <a name="l00648"></a>00648 <span class="comment">// we have a valid Grid object; send it as such.</span> <a name="l00649"></a>00649 out << space << <a class="code" href="classlibdap_1_1BaseType.html#c4461c9e287b167871acade5e5472116" title="Returns the type of the class instance as a string.">type_name</a>() << <span class="stringliteral">" {\n"</span> ; <a name="l00650"></a>00650 <a name="l00651"></a>00651 out << space << <span class="stringliteral">" Array:\n"</span> ; <a name="l00652"></a>00652 _array_var-><a class="code" href="classlibdap_1_1BaseType.html#2d799fad93255d7f2b803562ae7a5784" title="Print an ASCII representation of the variable structure.">print_decl</a>(out, space + <span class="stringliteral">" "</span>, <span class="keyword">true</span>, constraint_info, <a name="l00653"></a>00653 constrained); <a name="l00654"></a>00654 <a name="l00655"></a>00655 out << space << <span class="stringliteral">" Maps:\n"</span> ; <a name="l00656"></a>00656 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#d147322e168c6750893b6913d7f3edc5">Map_citer</a> i = _map_vars.begin(); i != _map_vars.end(); i++) { <a name="l00657"></a>00657 (*i)->print_decl(out, space + <span class="stringliteral">" "</span>, <span class="keyword">true</span>, <a name="l00658"></a>00658 constraint_info, constrained); <a name="l00659"></a>00659 } <a name="l00660"></a>00660 <a name="l00661"></a>00661 out << space << <span class="stringliteral">"} "</span> << <a class="code" href="namespacelibdap.html#fbd709ed83699c11234a213463d16b9c">id2www</a>(<a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>()) ; <a name="l00662"></a>00662 } <a name="l00663"></a>00663 <a name="l00664"></a>00664 <span class="keywordflow">if</span> (constraint_info) { <a name="l00665"></a>00665 <span class="keywordflow">if</span> (<a class="code" href="classlibdap_1_1BaseType.html#980c0013817836aa77ef74aeec7fb192" title="Should this variable be sent?">send_p</a>()) <a name="l00666"></a>00666 out << <span class="stringliteral">": Send True"</span>; <a name="l00667"></a>00667 <span class="keywordflow">else</span> <a name="l00668"></a>00668 out << <span class="stringliteral">": Send False"</span>; <a name="l00669"></a>00669 } <a name="l00670"></a>00670 <a name="l00671"></a>00671 <span class="keywordflow">if</span> (print_semi) <a name="l00672"></a>00672 out << <span class="stringliteral">";\n"</span> ; <a name="l00673"></a>00673 <a name="l00674"></a>00674 <span class="comment">// If sending just one comp, skip sending the terminal semicolon, etc.</span> <a name="l00675"></a>00675 exit: <a name="l00676"></a>00676 <span class="keywordflow">return</span>; <a name="l00677"></a>00677 } <a name="l00678"></a>00678 <a name="l00679"></a>00679 <span class="comment">//#if FILE_METHODS</span> <a name="l00680"></a>00680 <span class="keyword">class </span>PrintMapField : <span class="keyword">public</span> unary_function<BaseType *, void> <a name="l00681"></a>00681 { <a name="l00682"></a>00682 FILE *d_out; <a name="l00683"></a>00683 <span class="keywordtype">string</span> d_space; <a name="l00684"></a>00684 <span class="keywordtype">bool</span> d_constrained; <a name="l00685"></a>00685 <span class="keywordtype">string</span> d_tag; <a name="l00686"></a>00686 <span class="keyword">public</span>: <a name="l00687"></a>00687 PrintMapField(FILE *o, <span class="keywordtype">string</span> s, <span class="keywordtype">bool</span> c, <span class="keyword">const</span> <span class="keywordtype">string</span> &t = <span class="stringliteral">"Map"</span>) <a name="l00688"></a>00688 : d_out(o), d_space(s), d_constrained(c), d_tag(t) <a name="l00689"></a>00689 {} <a name="l00690"></a>00690 <a name="l00691"></a>00691 <span class="keywordtype">void</span> operator()(BaseType *btp) <a name="l00692"></a>00692 { <a name="l00693"></a>00693 Array *a = <span class="keyword">dynamic_cast<</span>Array*<span class="keyword">></span>(btp); <a name="l00694"></a>00694 <span class="keywordflow">if</span> (!a) <a name="l00695"></a>00695 <span class="keywordflow">throw</span> InternalErr(__FILE__, __LINE__, <span class="stringliteral">"Expected an Array."</span>); <a name="l00696"></a>00696 a->print_xml_core(d_out, d_space, d_constrained, d_tag); <a name="l00697"></a>00697 } <a name="l00698"></a>00698 }; <a name="l00699"></a>00699 <a name="l00700"></a>00700 <span class="keywordtype">void</span> <a name="l00701"></a><a class="code" href="classlibdap_1_1Grid.html#7e55419705f8a64c5d86f3b0a236709e">00701</a> <a class="code" href="classlibdap_1_1Grid.html#29d53347639f843c164f19e3a3f19b7d">Grid::print_xml</a>(FILE *out, <span class="keywordtype">string</span> space, <span class="keywordtype">bool</span> constrained) <a name="l00702"></a>00702 { <a name="l00703"></a>00703 <span class="keywordflow">if</span> (constrained && !<a class="code" href="classlibdap_1_1BaseType.html#980c0013817836aa77ef74aeec7fb192" title="Should this variable be sent?">send_p</a>()) <a name="l00704"></a>00704 <span class="keywordflow">return</span>; <a name="l00705"></a>00705 <a name="l00706"></a>00706 <span class="comment">// If we are printing the declaration of a constrained Grid then check for</span> <a name="l00707"></a>00707 <span class="comment">// the case where the projection removes all but one component; the</span> <a name="l00708"></a>00708 <span class="comment">// resulting object is a simple array.</span> <a name="l00709"></a>00709 <span class="comment">//</span> <a name="l00710"></a>00710 <span class="comment">// I replaced the 'true' with the value of 'print_semi' passed in by the</span> <a name="l00711"></a>00711 <span class="comment">// caller. This fixes an issue with the intern_data tests and does not</span> <a name="l00712"></a>00712 <span class="comment">// seem to break anything else. jhrg 11/9/07</span> <a name="l00713"></a>00713 <span class="keywordtype">int</span> projection = <a class="code" href="classlibdap_1_1Grid.html#d26dc472b37af0abeb540a43fb04d8dc" title="Returns the number of components in the Grid object.">components</a>(<span class="keyword">true</span>); <a name="l00714"></a>00714 <span class="keywordflow">if</span> (constrained && projection == 1) { <a name="l00715"></a>00715 <a class="code" href="classlibdap_1_1BaseType.html#1fcd9537c67e3bf88964b2656ff5bac1">get_attr_table</a>().<a class="code" href="classlibdap_1_1AttrTable.html#5e27ea09f83831eded1b3d86de7f4534">print_xml</a>(out, space + <span class="stringliteral">" "</span>, constrained); <a name="l00716"></a>00716 <a name="l00717"></a>00717 <a class="code" href="classlibdap_1_1Grid.html#905ac86a44a9d8ce576056ba244cf558" title="Returns the Grid Array. This method returns the array using an Array*, so no cast...">get_array</a>()-><a class="code" href="classlibdap_1_1Array.html#3ce1bd161426e6950dc97511f33b2845">print_xml</a>(out, space + <span class="stringliteral">" "</span>, constrained); <a name="l00718"></a>00718 <a name="l00719"></a>00719 for_each(<a class="code" href="classlibdap_1_1Grid.html#2e9d2e436c0ff138a977dbba54c018eb" title="Returns an iterator referencing the first Map vector.">map_begin</a>(), <a class="code" href="classlibdap_1_1Grid.html#aebbf2a5329ec01b6527b4bafde87837">map_end</a>(), <a name="l00720"></a>00720 PrintMapField(out, space + <span class="stringliteral">" "</span>, constrained, <span class="stringliteral">"Array"</span>)); <a name="l00721"></a>00721 } <a name="l00722"></a>00722 <span class="comment">// If there are M (< N) components (Array and Maps combined) in a N</span> <a name="l00723"></a>00723 <span class="comment">// component Grid, send the M components as elements of a Structure.</span> <a name="l00724"></a>00724 <span class="comment">// This will preserve the grouping without violating the rules for a</span> <a name="l00725"></a>00725 <span class="comment">// Grid.</span> <a name="l00726"></a>00726 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (constrained && !<a class="code" href="classlibdap_1_1Grid.html#a737cef63a1b9c8b8b0952fcb22a621b">projection_yields_grid</a>()) { <a name="l00727"></a>00727 fprintf(out, <span class="stringliteral">"%s<Structure"</span>, space.c_str()); <a name="l00728"></a>00728 <span class="keywordflow">if</span> (!<a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>().empty()) <a name="l00729"></a>00729 fprintf(out, <span class="stringliteral">" name=\"%s\""</span>, <a class="code" href="namespacelibdap.html#62463a13bf510db3a14c0053fea14f4d">id2xml</a>(<a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>()).c_str()); <a name="l00730"></a>00730 <a name="l00731"></a>00731 fprintf(out, <span class="stringliteral">">\n"</span>); <a name="l00732"></a>00732 <a name="l00733"></a>00733 <a class="code" href="classlibdap_1_1BaseType.html#1fcd9537c67e3bf88964b2656ff5bac1">get_attr_table</a>().<a class="code" href="classlibdap_1_1AttrTable.html#5e27ea09f83831eded1b3d86de7f4534">print_xml</a>(out, space + <span class="stringliteral">" "</span>, constrained); <a name="l00734"></a>00734 <a name="l00735"></a>00735 <a class="code" href="classlibdap_1_1Grid.html#905ac86a44a9d8ce576056ba244cf558" title="Returns the Grid Array. This method returns the array using an Array*, so no cast...">get_array</a>()-><a class="code" href="classlibdap_1_1Array.html#3ce1bd161426e6950dc97511f33b2845">print_xml</a>(out, space + <span class="stringliteral">" "</span>, constrained); <a name="l00736"></a>00736 <a name="l00737"></a>00737 for_each(<a class="code" href="classlibdap_1_1Grid.html#2e9d2e436c0ff138a977dbba54c018eb" title="Returns an iterator referencing the first Map vector.">map_begin</a>(), <a class="code" href="classlibdap_1_1Grid.html#aebbf2a5329ec01b6527b4bafde87837">map_end</a>(), <a name="l00738"></a>00738 PrintMapField(out, space + <span class="stringliteral">" "</span>, constrained, <span class="stringliteral">"Array"</span>)); <a name="l00739"></a>00739 <a name="l00740"></a>00740 fprintf(out, <span class="stringliteral">"%s</Structure>\n"</span>, space.c_str()); <a name="l00741"></a>00741 } <a name="l00742"></a>00742 <span class="keywordflow">else</span> { <a name="l00743"></a>00743 <span class="comment">// The number of elements in the (projected) Grid must be such that</span> <a name="l00744"></a>00744 <span class="comment">// we have a valid Grid object; send it as such.</span> <a name="l00745"></a>00745 fprintf(out, <span class="stringliteral">"%s<Grid"</span>, space.c_str()); <a name="l00746"></a>00746 <span class="keywordflow">if</span> (!<a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>().empty()) <a name="l00747"></a>00747 fprintf(out, <span class="stringliteral">" name=\"%s\""</span>, <a class="code" href="namespacelibdap.html#62463a13bf510db3a14c0053fea14f4d">id2xml</a>(<a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>()).c_str()); <a name="l00748"></a>00748 <a name="l00749"></a>00749 fprintf(out, <span class="stringliteral">">\n"</span>); <a name="l00750"></a>00750 <a name="l00751"></a>00751 <a class="code" href="classlibdap_1_1BaseType.html#1fcd9537c67e3bf88964b2656ff5bac1">get_attr_table</a>().<a class="code" href="classlibdap_1_1AttrTable.html#5e27ea09f83831eded1b3d86de7f4534">print_xml</a>(out, space + <span class="stringliteral">" "</span>, constrained); <a name="l00752"></a>00752 <a name="l00753"></a>00753 <a class="code" href="classlibdap_1_1Grid.html#905ac86a44a9d8ce576056ba244cf558" title="Returns the Grid Array. This method returns the array using an Array*, so no cast...">get_array</a>()-><a class="code" href="classlibdap_1_1Array.html#3ce1bd161426e6950dc97511f33b2845">print_xml</a>(out, space + <span class="stringliteral">" "</span>, constrained); <a name="l00754"></a>00754 <a name="l00755"></a>00755 for_each(<a class="code" href="classlibdap_1_1Grid.html#2e9d2e436c0ff138a977dbba54c018eb" title="Returns an iterator referencing the first Map vector.">map_begin</a>(), <a class="code" href="classlibdap_1_1Grid.html#aebbf2a5329ec01b6527b4bafde87837">map_end</a>(), <a name="l00756"></a>00756 PrintMapField(out, space + <span class="stringliteral">" "</span>, constrained)); <a name="l00757"></a>00757 <a name="l00758"></a>00758 fprintf(out, <span class="stringliteral">"%s</Grid>\n"</span>, space.c_str()); <a name="l00759"></a>00759 } <a name="l00760"></a>00760 } <a name="l00761"></a>00761 <span class="comment">//#endif</span> <a name="l00762"></a>00762 <a name="l00763"></a>00763 <span class="keyword">class </span>PrintMapFieldStrm : <span class="keyword">public</span> unary_function<BaseType *, void> <a name="l00764"></a>00764 { <a name="l00765"></a>00765 ostream &d_out; <a name="l00766"></a>00766 <span class="keywordtype">string</span> d_space; <a name="l00767"></a>00767 <span class="keywordtype">bool</span> d_constrained; <a name="l00768"></a>00768 <span class="keywordtype">string</span> d_tag; <a name="l00769"></a>00769 <span class="keyword">public</span>: <a name="l00770"></a>00770 PrintMapFieldStrm(ostream &o, <span class="keywordtype">string</span> s, <span class="keywordtype">bool</span> c, <span class="keyword">const</span> <span class="keywordtype">string</span> &t = <span class="stringliteral">"Map"</span>) <a name="l00771"></a>00771 : d_out(o), d_space(s), d_constrained(c), d_tag(t) <a name="l00772"></a>00772 {} <a name="l00773"></a>00773 <a name="l00774"></a>00774 <span class="keywordtype">void</span> operator()(BaseType *btp) <a name="l00775"></a>00775 { <a name="l00776"></a>00776 Array *a = <span class="keyword">dynamic_cast<</span>Array*<span class="keyword">></span>(btp); <a name="l00777"></a>00777 <span class="keywordflow">if</span> (!a) <a name="l00778"></a>00778 <span class="keywordflow">throw</span> InternalErr(__FILE__, __LINE__, <span class="stringliteral">"Expected an Array."</span>); <a name="l00779"></a>00779 a->print_xml_core(d_out, d_space, d_constrained, d_tag); <a name="l00780"></a>00780 } <a name="l00781"></a>00781 }; <a name="l00782"></a>00782 <a name="l00783"></a>00783 <span class="keywordtype">void</span> <a name="l00784"></a><a class="code" href="classlibdap_1_1Grid.html#29d53347639f843c164f19e3a3f19b7d">00784</a> <a class="code" href="classlibdap_1_1Grid.html#29d53347639f843c164f19e3a3f19b7d">Grid::print_xml</a>(ostream &out, <span class="keywordtype">string</span> space, <span class="keywordtype">bool</span> constrained) <a name="l00785"></a>00785 { <a name="l00786"></a>00786 <span class="keywordflow">if</span> (constrained && !<a class="code" href="classlibdap_1_1BaseType.html#980c0013817836aa77ef74aeec7fb192" title="Should this variable be sent?">send_p</a>()) <a name="l00787"></a>00787 <span class="keywordflow">return</span>; <a name="l00788"></a>00788 <a name="l00789"></a>00789 <span class="comment">// If we are printing the declaration of a constrained Grid then check for</span> <a name="l00790"></a>00790 <span class="comment">// the case where the projection removes all but one component; the</span> <a name="l00791"></a>00791 <span class="comment">// resulting object is a simple array.</span> <a name="l00792"></a>00792 <span class="comment">//</span> <a name="l00793"></a>00793 <span class="comment">// I replaced the 'true' with the value of 'print_semi' passed in by the</span> <a name="l00794"></a>00794 <span class="comment">// caller. This fixes an issue with the intern_data tests and does not</span> <a name="l00795"></a>00795 <span class="comment">// seem to break anything else. jhrg 11/9/07</span> <a name="l00796"></a>00796 <span class="keywordtype">int</span> projection = <a class="code" href="classlibdap_1_1Grid.html#d26dc472b37af0abeb540a43fb04d8dc" title="Returns the number of components in the Grid object.">components</a>(<span class="keyword">true</span>); <a name="l00797"></a>00797 <span class="keywordflow">if</span> (constrained && projection == 1) { <a name="l00798"></a>00798 <a class="code" href="classlibdap_1_1BaseType.html#1fcd9537c67e3bf88964b2656ff5bac1">get_attr_table</a>().<a class="code" href="classlibdap_1_1AttrTable.html#5e27ea09f83831eded1b3d86de7f4534">print_xml</a>(out, space + <span class="stringliteral">" "</span>, constrained); <a name="l00799"></a>00799 <a name="l00800"></a>00800 <a class="code" href="classlibdap_1_1Grid.html#905ac86a44a9d8ce576056ba244cf558" title="Returns the Grid Array. This method returns the array using an Array*, so no cast...">get_array</a>()-><a class="code" href="classlibdap_1_1Array.html#3ce1bd161426e6950dc97511f33b2845">print_xml</a>(out, space + <span class="stringliteral">" "</span>, constrained); <a name="l00801"></a>00801 <a name="l00802"></a>00802 for_each(<a class="code" href="classlibdap_1_1Grid.html#2e9d2e436c0ff138a977dbba54c018eb" title="Returns an iterator referencing the first Map vector.">map_begin</a>(), <a class="code" href="classlibdap_1_1Grid.html#aebbf2a5329ec01b6527b4bafde87837">map_end</a>(), <a name="l00803"></a>00803 PrintMapFieldStrm(out, space + <span class="stringliteral">" "</span>, constrained, <span class="stringliteral">"Array"</span>)); <a name="l00804"></a>00804 } <a name="l00805"></a>00805 <span class="comment">// If there are M (< N) components (Array and Maps combined) in a N</span> <a name="l00806"></a>00806 <span class="comment">// component Grid, send the M components as elements of a Structure.</span> <a name="l00807"></a>00807 <span class="comment">// This will preserve the grouping without violating the rules for a</span> <a name="l00808"></a>00808 <span class="comment">// Grid.</span> <a name="l00809"></a>00809 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (constrained && !<a class="code" href="classlibdap_1_1Grid.html#a737cef63a1b9c8b8b0952fcb22a621b">projection_yields_grid</a>()) { <a name="l00810"></a>00810 out << space << <span class="stringliteral">"<Structure"</span> ; <a name="l00811"></a>00811 <span class="keywordflow">if</span> (!<a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>().empty()) <a name="l00812"></a>00812 out << <span class="stringliteral">" name=\""</span> << <a class="code" href="namespacelibdap.html#62463a13bf510db3a14c0053fea14f4d">id2xml</a>(<a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>()) << <span class="stringliteral">"\""</span> ; <a name="l00813"></a>00813 <a name="l00814"></a>00814 out << <span class="stringliteral">">\n"</span> ; <a name="l00815"></a>00815 <a name="l00816"></a>00816 <a class="code" href="classlibdap_1_1BaseType.html#1fcd9537c67e3bf88964b2656ff5bac1">get_attr_table</a>().<a class="code" href="classlibdap_1_1AttrTable.html#5e27ea09f83831eded1b3d86de7f4534">print_xml</a>(out, space + <span class="stringliteral">" "</span>, constrained); <a name="l00817"></a>00817 <a name="l00818"></a>00818 <a class="code" href="classlibdap_1_1Grid.html#905ac86a44a9d8ce576056ba244cf558" title="Returns the Grid Array. This method returns the array using an Array*, so no cast...">get_array</a>()-><a class="code" href="classlibdap_1_1Array.html#3ce1bd161426e6950dc97511f33b2845">print_xml</a>(out, space + <span class="stringliteral">" "</span>, constrained); <a name="l00819"></a>00819 <a name="l00820"></a>00820 for_each(<a class="code" href="classlibdap_1_1Grid.html#2e9d2e436c0ff138a977dbba54c018eb" title="Returns an iterator referencing the first Map vector.">map_begin</a>(), <a class="code" href="classlibdap_1_1Grid.html#aebbf2a5329ec01b6527b4bafde87837">map_end</a>(), <a name="l00821"></a>00821 PrintMapFieldStrm(out, space + <span class="stringliteral">" "</span>, constrained, <span class="stringliteral">"Array"</span>)); <a name="l00822"></a>00822 <a name="l00823"></a>00823 out << space << <span class="stringliteral">"</Structure>\n"</span> ; <a name="l00824"></a>00824 } <a name="l00825"></a>00825 <span class="keywordflow">else</span> { <a name="l00826"></a>00826 <span class="comment">// The number of elements in the (projected) Grid must be such that</span> <a name="l00827"></a>00827 <span class="comment">// we have a valid Grid object; send it as such.</span> <a name="l00828"></a>00828 out << space << <span class="stringliteral">"<Grid"</span> ; <a name="l00829"></a>00829 <span class="keywordflow">if</span> (!<a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>().empty()) <a name="l00830"></a>00830 out << <span class="stringliteral">" name=\""</span> << <a class="code" href="namespacelibdap.html#62463a13bf510db3a14c0053fea14f4d">id2xml</a>(<a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>()) << <span class="stringliteral">"\""</span> ; <a name="l00831"></a>00831 <a name="l00832"></a>00832 out << <span class="stringliteral">">\n"</span> ; <a name="l00833"></a>00833 <a name="l00834"></a>00834 <a class="code" href="classlibdap_1_1BaseType.html#1fcd9537c67e3bf88964b2656ff5bac1">get_attr_table</a>().<a class="code" href="classlibdap_1_1AttrTable.html#5e27ea09f83831eded1b3d86de7f4534">print_xml</a>(out, space + <span class="stringliteral">" "</span>, constrained); <a name="l00835"></a>00835 <a name="l00836"></a>00836 <a class="code" href="classlibdap_1_1Grid.html#905ac86a44a9d8ce576056ba244cf558" title="Returns the Grid Array. This method returns the array using an Array*, so no cast...">get_array</a>()-><a class="code" href="classlibdap_1_1Array.html#3ce1bd161426e6950dc97511f33b2845">print_xml</a>(out, space + <span class="stringliteral">" "</span>, constrained); <a name="l00837"></a>00837 <a name="l00838"></a>00838 for_each(<a class="code" href="classlibdap_1_1Grid.html#2e9d2e436c0ff138a977dbba54c018eb" title="Returns an iterator referencing the first Map vector.">map_begin</a>(), <a class="code" href="classlibdap_1_1Grid.html#aebbf2a5329ec01b6527b4bafde87837">map_end</a>(), <a name="l00839"></a>00839 PrintMapFieldStrm(out, space + <span class="stringliteral">" "</span>, constrained)); <a name="l00840"></a>00840 <a name="l00841"></a>00841 out << space << <span class="stringliteral">"</Grid>\n"</span> ; <a name="l00842"></a>00842 } <a name="l00843"></a>00843 } <a name="l00844"></a>00844 <a name="l00845"></a>00845 <span class="comment">//#if FILE_METHODS</span> <a name="l00846"></a>00846 <span class="keywordtype">void</span> <a name="l00847"></a><a class="code" href="classlibdap_1_1Grid.html#bc90f12653afefe765bea1917dcecc08">00847</a> <a class="code" href="classlibdap_1_1Grid.html#5322f6b5ce04e5d00347bf50b341f4e6" title="Prints the value of the variable.">Grid::print_val</a>(FILE *out, <span class="keywordtype">string</span> space, <span class="keywordtype">bool</span> print_decl_p) <a name="l00848"></a>00848 { <a name="l00849"></a>00849 <span class="keywordflow">if</span> (print_decl_p) { <a name="l00850"></a>00850 <a class="code" href="classlibdap_1_1Grid.html#5a239b053928636e13e3a478faf8e334" title="Print an ASCII representation of the variable structure.">print_decl</a>(out, space, <span class="keyword">false</span>); <a name="l00851"></a>00851 fprintf(out, <span class="stringliteral">" = "</span>) ; <a name="l00852"></a>00852 } <a name="l00853"></a>00853 <a name="l00854"></a>00854 <span class="comment">// If we are printing a value on the client-side, projection_yields_grid</span> <a name="l00855"></a>00855 <span class="comment">// should not be called since we don't *have* a projection without a</span> <a name="l00856"></a>00856 <span class="comment">// contraint. I think that if we are here and send_p() is not true, then</span> <a name="l00857"></a>00857 <span class="comment">// the value of this function should be ignored. 4/6/2000 jhrg</span> <a name="l00858"></a>00858 <span class="keywordtype">bool</span> pyg = <a class="code" href="classlibdap_1_1Grid.html#a737cef63a1b9c8b8b0952fcb22a621b">projection_yields_grid</a>(); <span class="comment">// hack 12/1/99 jhrg</span> <a name="l00859"></a>00859 <span class="keywordflow">if</span> (pyg || !<a class="code" href="classlibdap_1_1BaseType.html#980c0013817836aa77ef74aeec7fb192" title="Should this variable be sent?">send_p</a>()) <a name="l00860"></a>00860 fprintf(out, <span class="stringliteral">"{ Array: "</span>) ; <a name="l00861"></a>00861 <span class="keywordflow">else</span> <a name="l00862"></a>00862 fprintf(out, <span class="stringliteral">"{"</span>) ; <a name="l00863"></a>00863 _array_var-><a class="code" href="classlibdap_1_1BaseType.html#16f82585af6b66f434f2132f05c4960c" title="Prints the value of the variable.">print_val</a>(out, <span class="stringliteral">""</span>, <span class="keyword">false</span>); <a name="l00864"></a>00864 <span class="keywordflow">if</span> (pyg || !<a class="code" href="classlibdap_1_1BaseType.html#980c0013817836aa77ef74aeec7fb192" title="Should this variable be sent?">send_p</a>()) <a name="l00865"></a>00865 fprintf(out, <span class="stringliteral">" Maps: "</span>) ; <a name="l00866"></a>00866 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#d147322e168c6750893b6913d7f3edc5">Map_citer</a> i = _map_vars.begin(); i != _map_vars.end(); <a name="l00867"></a>00867 i++, (void)(i != _map_vars.end() && fprintf(out, <span class="stringliteral">", "</span>))) { <a name="l00868"></a>00868 (*i)->print_val(out, <span class="stringliteral">""</span>, <span class="keyword">false</span>); <a name="l00869"></a>00869 } <a name="l00870"></a>00870 fprintf(out, <span class="stringliteral">" }"</span>) ; <a name="l00871"></a>00871 <a name="l00872"></a>00872 <span class="keywordflow">if</span> (print_decl_p) <a name="l00873"></a>00873 fprintf(out, <span class="stringliteral">";\n"</span>) ; <a name="l00874"></a>00874 } <a name="l00875"></a>00875 <span class="comment">//#endif</span> <a name="l00876"></a>00876 <span class="keywordtype">void</span> <a name="l00877"></a><a class="code" href="classlibdap_1_1Grid.html#5322f6b5ce04e5d00347bf50b341f4e6">00877</a> <a class="code" href="classlibdap_1_1Grid.html#5322f6b5ce04e5d00347bf50b341f4e6" title="Prints the value of the variable.">Grid::print_val</a>(ostream &out, <span class="keywordtype">string</span> space, <span class="keywordtype">bool</span> print_decl_p) <a name="l00878"></a>00878 { <a name="l00879"></a>00879 <span class="keywordflow">if</span> (print_decl_p) { <a name="l00880"></a>00880 <a class="code" href="classlibdap_1_1Grid.html#5a239b053928636e13e3a478faf8e334" title="Print an ASCII representation of the variable structure.">print_decl</a>(out, space, <span class="keyword">false</span>); <a name="l00881"></a>00881 out << <span class="stringliteral">" = "</span> ; <a name="l00882"></a>00882 } <a name="l00883"></a>00883 <a name="l00884"></a>00884 <span class="comment">// If we are printing a value on the client-side, projection_yields_grid</span> <a name="l00885"></a>00885 <span class="comment">// should not be called since we don't *have* a projection without a</span> <a name="l00886"></a>00886 <span class="comment">// Constraint. I think that if we are here and send_p() is not true, then</span> <a name="l00887"></a>00887 <span class="comment">// the value of this function should be ignored. 4/6/2000 jhrg</span> <a name="l00888"></a>00888 <span class="keywordtype">bool</span> pyg = <a class="code" href="classlibdap_1_1Grid.html#a737cef63a1b9c8b8b0952fcb22a621b">projection_yields_grid</a>(); <span class="comment">// hack 12/1/99 jhrg</span> <a name="l00889"></a>00889 <span class="keywordflow">if</span> (pyg || !<a class="code" href="classlibdap_1_1BaseType.html#980c0013817836aa77ef74aeec7fb192" title="Should this variable be sent?">send_p</a>()) <a name="l00890"></a>00890 out << <span class="stringliteral">"{ Array: "</span> ; <a name="l00891"></a>00891 <span class="keywordflow">else</span> <a name="l00892"></a>00892 out << <span class="stringliteral">"{"</span> ; <a name="l00893"></a>00893 _array_var-><a class="code" href="classlibdap_1_1BaseType.html#16f82585af6b66f434f2132f05c4960c" title="Prints the value of the variable.">print_val</a>(out, <span class="stringliteral">""</span>, <span class="keyword">false</span>); <a name="l00894"></a>00894 <span class="keywordflow">if</span> (pyg || !<a class="code" href="classlibdap_1_1BaseType.html#980c0013817836aa77ef74aeec7fb192" title="Should this variable be sent?">send_p</a>()) <a name="l00895"></a>00895 out << <span class="stringliteral">" Maps: "</span> ; <a name="l00896"></a>00896 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#d147322e168c6750893b6913d7f3edc5">Map_citer</a> i = _map_vars.begin(); i != _map_vars.end(); <a name="l00897"></a>00897 i++, (void)(i != _map_vars.end() && out << <span class="stringliteral">", "</span>)) { <a name="l00898"></a>00898 (*i)->print_val(out, <span class="stringliteral">""</span>, <span class="keyword">false</span>); <a name="l00899"></a>00899 } <a name="l00900"></a>00900 out << <span class="stringliteral">" }"</span> ; <a name="l00901"></a>00901 <a name="l00902"></a>00902 <span class="keywordflow">if</span> (print_decl_p) <a name="l00903"></a>00903 out << <span class="stringliteral">";\n"</span> ; <a name="l00904"></a>00904 } <a name="l00905"></a>00905 <a name="l00906"></a>00906 <span class="comment">// Grids have ugly semantics.</span> <a name="l00907"></a>00907 <a name="l00912"></a>00912 <span class="keywordtype">bool</span> <a name="l00913"></a><a class="code" href="classlibdap_1_1Grid.html#e66a262518b81ff354061528654fae75">00913</a> <a class="code" href="classlibdap_1_1Grid.html#e66a262518b81ff354061528654fae75" title="Return true if this Grid is well formed.">Grid::check_semantics</a>(<span class="keywordtype">string</span> &msg, <span class="keywordtype">bool</span> all) <a name="l00914"></a>00914 { <a name="l00915"></a>00915 <span class="keywordflow">if</span> (!<a class="code" href="classlibdap_1_1BaseType.html#ec503abec2fd3090e7738c0a575491f8" title="Compare an object&#39;s current state with the semantics of its type.">BaseType::check_semantics</a>(msg)) <a name="l00916"></a>00916 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00917"></a>00917 <span class="preprocessor">#if 0</span> <a name="l00918"></a>00918 <span class="preprocessor"></span> <span class="comment">// Actually, the spec doesn't say this. jhrg 2/13/06</span> <a name="l00919"></a>00919 <span class="keywordflow">if</span> (!<a class="code" href="namespacelibdap.html#fabf64c5d4c1900f1c05ac655895f7ee">unique_names</a>(_map_vars, <a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>(), <a class="code" href="classlibdap_1_1BaseType.html#c4461c9e287b167871acade5e5472116" title="Returns the type of the class instance as a string.">type_name</a>(), msg)) <a name="l00920"></a>00920 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00921"></a>00921 <span class="preprocessor">#endif</span> <a name="l00922"></a>00922 <span class="preprocessor"></span> <a name="l00923"></a>00923 msg = <span class="stringliteral">""</span>; <a name="l00924"></a>00924 <a name="l00925"></a>00925 <span class="keywordflow">if</span> (!_array_var) { <a name="l00926"></a>00926 msg += <span class="stringliteral">"Null grid base array in `"</span> + <a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>() + <span class="stringliteral">"'\n"</span>; <a name="l00927"></a>00927 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00928"></a>00928 } <a name="l00929"></a>00929 <a name="l00930"></a>00930 <span class="comment">// Is it an array?</span> <a name="l00931"></a>00931 <span class="keywordflow">if</span> (_array_var-><a class="code" href="classlibdap_1_1BaseType.html#bc6b2d7099f00bb5f324ec129bff2a17" title="Returns the type of the class instance.">type</a>() != <a class="code" href="namespacelibdap.html#05ca706d4539ae7b750c3bc7066ab6e6da8f5df7bb2bc72327fcd16af811562f">dods_array_c</a>) { <a name="l00932"></a>00932 msg += <span class="stringliteral">"Grid `"</span> + <a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>() + <span class="stringliteral">"'s' member `"</span> + _array_var-><a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>() + <span class="stringliteral">"' must be an array\n"</span>; <a name="l00933"></a>00933 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00934"></a>00934 } <a name="l00935"></a>00935 <a name="l00936"></a>00936 <a class="code" href="classlibdap_1_1Array.html" title="A multidimensional array of identical data types.">Array</a> *av = (<a class="code" href="classlibdap_1_1Array.html" title="A multidimensional array of identical data types.">Array</a> *)_array_var; <span class="comment">// past test above, must be an array</span> <a name="l00937"></a>00937 <a name="l00938"></a>00938 <span class="comment">// Array must be of a simple_type.</span> <a name="l00939"></a>00939 <span class="keywordflow">if</span> (!av-><a class="code" href="classlibdap_1_1Vector.html#a5ccb30d1f27ae587f35216b859feec7">var</a>()-><a class="code" href="classlibdap_1_1BaseType.html#614ce462dc6236791630f373bf75ad49" title="Returns true if the instance is a numeric, string or URL type variable.">is_simple_type</a>()) { <a name="l00940"></a>00940 msg += <span class="stringliteral">"The field variable `"</span> + this-><a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>() + <span class="stringliteral">"' must be an array of simple type elements (e.g., int32, String)\n"</span>; <a name="l00941"></a>00941 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00942"></a>00942 } <a name="l00943"></a>00943 <a name="l00944"></a>00944 <span class="comment">// enough maps?</span> <a name="l00945"></a>00945 <span class="keywordflow">if</span> ((<span class="keywordtype">unsigned</span>)_map_vars.size() != av-><a class="code" href="classlibdap_1_1Array.html#fa75d1ff3c75b8359d03b3f382bfd179" title="Return the total number of dimensions in the array.">dimensions</a>()) { <a name="l00946"></a>00946 msg += <span class="stringliteral">"The number of map variables for grid `"</span> + this-><a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>() + <span class="stringliteral">"' does not match the number of dimensions of `"</span>; <a name="l00947"></a>00947 msg += av-><a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>() + <span class="stringliteral">"'\n"</span>; <a name="l00948"></a>00948 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00949"></a>00949 } <a name="l00950"></a>00950 <a name="l00951"></a>00951 <span class="keyword">const</span> <span class="keywordtype">string</span> array_var_name = av-><a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>(); <a name="l00952"></a>00952 <a class="code" href="classlibdap_1_1Array.html#7a557c05085a83d1501dbfa249d3cc52">Array::Dim_iter</a> asi = av-><a class="code" href="classlibdap_1_1Array.html#e6e6943cd895fa8dc1c58621ffad42a0">dim_begin</a>() ; <a name="l00953"></a>00953 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#69ee284e8087d1482373989f3256f95d">Map_iter</a> mvi = _map_vars.begin(); <a name="l00954"></a>00954 mvi != _map_vars.end(); mvi++, asi++) { <a name="l00955"></a>00955 <a name="l00956"></a>00956 <a class="code" href="classlibdap_1_1BaseType.html" title="The basic data type for the DODS DAP types.">BaseType</a> *mv = *mvi; <a name="l00957"></a>00957 <a name="l00958"></a>00958 <span class="comment">// check names</span> <a name="l00959"></a>00959 <span class="keywordflow">if</span> (array_var_name == mv-><a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>()) { <a name="l00960"></a>00960 msg += <span class="stringliteral">"Grid map variable `"</span> + mv-><a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>() + <span class="stringliteral">"' conflicts with the grid array name in grid `"</span> + <a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>() + <span class="stringliteral">"'\n"</span>; <a name="l00961"></a>00961 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00962"></a>00962 } <a name="l00963"></a>00963 <span class="comment">// check types</span> <a name="l00964"></a>00964 <span class="keywordflow">if</span> (mv-><a class="code" href="classlibdap_1_1BaseType.html#bc6b2d7099f00bb5f324ec129bff2a17" title="Returns the type of the class instance.">type</a>() != <a class="code" href="namespacelibdap.html#05ca706d4539ae7b750c3bc7066ab6e6da8f5df7bb2bc72327fcd16af811562f">dods_array_c</a>) { <a name="l00965"></a>00965 msg += <span class="stringliteral">"Grid map variable `"</span> + mv-><a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>() + <span class="stringliteral">"' is not an array\n"</span>; <a name="l00966"></a>00966 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00967"></a>00967 } <a name="l00968"></a>00968 <a name="l00969"></a>00969 <a class="code" href="classlibdap_1_1Array.html" title="A multidimensional array of identical data types.">Array</a> *mv_a = (<a class="code" href="classlibdap_1_1Array.html" title="A multidimensional array of identical data types.">Array</a> *)mv; <span class="comment">// downcast to (Array *)</span> <a name="l00970"></a>00970 <a name="l00971"></a>00971 <span class="comment">// Array must be of a simple_type.</span> <a name="l00972"></a>00972 <span class="keywordflow">if</span> (!mv_a-><a class="code" href="classlibdap_1_1Vector.html#a5ccb30d1f27ae587f35216b859feec7">var</a>()-><a class="code" href="classlibdap_1_1BaseType.html#614ce462dc6236791630f373bf75ad49" title="Returns true if the instance is a numeric, string or URL type variable.">is_simple_type</a>()) { <a name="l00973"></a>00973 msg += <span class="stringliteral">"The field variable `"</span> + this-><a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>() + <span class="stringliteral">"' must be an array of simple type elements (e.g., int32, String)\n"</span>; <a name="l00974"></a>00974 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00975"></a>00975 } <a name="l00976"></a>00976 <a name="l00977"></a>00977 <span class="comment">// check shape</span> <a name="l00978"></a>00978 <span class="keywordflow">if</span> (mv_a-><a class="code" href="classlibdap_1_1Array.html#fa75d1ff3c75b8359d03b3f382bfd179" title="Return the total number of dimensions in the array.">dimensions</a>() != 1) {<span class="comment">// maps must have one dimension</span> <a name="l00979"></a>00979 msg += <span class="stringliteral">"Grid map variable `"</span> + mv_a-><a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>() + <span class="stringliteral">"' must be only one dimension\n"</span>; <a name="l00980"></a>00980 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00981"></a>00981 } <a name="l00982"></a>00982 <span class="comment">// size of map must match corresponding array dimension</span> <a name="l00983"></a>00983 <a class="code" href="classlibdap_1_1Array.html#7a557c05085a83d1501dbfa249d3cc52">Array::Dim_iter</a> mv_asi = mv_a-><a class="code" href="classlibdap_1_1Array.html#e6e6943cd895fa8dc1c58621ffad42a0">dim_begin</a>() ; <a name="l00984"></a>00984 <span class="keywordtype">int</span> mv_a_size = mv_a-><a class="code" href="classlibdap_1_1Array.html#8f29497af9c33c0d66939d5f9a16d92a" title="Returns the size of the dimension.">dimension_size</a>(mv_asi) ; <a name="l00985"></a>00985 <span class="keywordtype">int</span> av_size = av-><a class="code" href="classlibdap_1_1Array.html#8f29497af9c33c0d66939d5f9a16d92a" title="Returns the size of the dimension.">dimension_size</a>(asi) ; <a name="l00986"></a>00986 <span class="keywordflow">if</span> (mv_a_size != av_size) { <a name="l00987"></a>00987 msg += <span class="stringliteral">"Grid map variable `"</span> + mv_a-><a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>() + <span class="stringliteral">"'s' size does not match the size of array variable '"</span>; <a name="l00988"></a>00988 msg += _array_var-><a class="code" href="classlibdap_1_1BaseType.html#0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>() + <span class="stringliteral">"'s' cooresponding dimension\n"</span>; <a name="l00989"></a>00989 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00990"></a>00990 } <a name="l00991"></a>00991 } <a name="l00992"></a>00992 <a name="l00993"></a>00993 <span class="keywordflow">if</span> (all) { <a name="l00994"></a>00994 <span class="keywordflow">if</span> (!_array_var-><a class="code" href="classlibdap_1_1BaseType.html#ec503abec2fd3090e7738c0a575491f8" title="Compare an object&#39;s current state with the semantics of its type.">check_semantics</a>(msg, <span class="keyword">true</span>)) <a name="l00995"></a>00995 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00996"></a>00996 <span class="keywordflow">for</span> (<a class="code" href="classlibdap_1_1Grid.html#69ee284e8087d1482373989f3256f95d">Map_iter</a> mvi = _map_vars.begin(); mvi != _map_vars.end(); mvi++) { <a name="l00997"></a>00997 <span class="keywordflow">if</span> (!(*mvi)->check_semantics(msg, <span class="keyword">true</span>)) { <a name="l00998"></a>00998 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00999"></a>00999 } <a name="l01000"></a>01000 } <a name="l01001"></a>01001 } <a name="l01002"></a>01002 <a name="l01003"></a>01003 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l01004"></a>01004 } <a name="l01005"></a>01005 <a name="l01014"></a>01014 <span class="keywordtype">void</span> <a name="l01015"></a><a class="code" href="classlibdap_1_1Grid.html#1ebdcb9b7a3844582c543acaf20cc07c">01015</a> <a class="code" href="classlibdap_1_1Grid.html#1ebdcb9b7a3844582c543acaf20cc07c" title="dumps information about this object">Grid::dump</a>(ostream &strm)<span class="keyword"> const</span> <a name="l01016"></a>01016 <span class="keyword"></span>{ <a name="l01017"></a>01017 strm << <a class="code" href="classlibdap_1_1DapIndent.html#45ca36e552f70fbdbca0599da4320aab">DapIndent::LMarg</a> << <span class="stringliteral">"Grid::dump - ("</span> <a name="l01018"></a>01018 << (<span class="keywordtype">void</span> *)<span class="keyword">this</span> << <span class="stringliteral">")"</span> << endl ; <a name="l01019"></a>01019 <a class="code" href="classlibdap_1_1DapIndent.html#4ed2cce66dbff9ad4320e89142103c6c">DapIndent::Indent</a>() ; <a name="l01020"></a>01020 <a class="code" href="classlibdap_1_1Grid.html#1ebdcb9b7a3844582c543acaf20cc07c" title="dumps information about this object">Constructor::dump</a>(strm) ; <a name="l01021"></a>01021 <span class="keywordflow">if</span> (_array_var) { <a name="l01022"></a>01022 strm << <a class="code" href="classlibdap_1_1DapIndent.html#45ca36e552f70fbdbca0599da4320aab">DapIndent::LMarg</a> << <span class="stringliteral">"array var: "</span> << endl ; <a name="l01023"></a>01023 DapIndent::Indent() ; <a name="l01024"></a>01024 _array_var-><a class="code" href="classlibdap_1_1BaseType.html#1ecd80ca994b950bd19b5f525fa4c7a2" title="dumps information about this object">dump</a>(strm) ; <a name="l01025"></a>01025 <a class="code" href="classlibdap_1_1DapIndent.html#65c519d0916b031bcf60ca8d26fc82f8">DapIndent::UnIndent</a>() ; <a name="l01026"></a>01026 } <a name="l01027"></a>01027 <span class="keywordflow">else</span> { <a name="l01028"></a>01028 strm << <a class="code" href="classlibdap_1_1DapIndent.html#45ca36e552f70fbdbca0599da4320aab">DapIndent::LMarg</a> << <span class="stringliteral">"array var: null"</span> << endl ; <a name="l01029"></a>01029 } <a name="l01030"></a>01030 strm << <a class="code" href="classlibdap_1_1DapIndent.html#45ca36e552f70fbdbca0599da4320aab">DapIndent::LMarg</a> << <span class="stringliteral">"map var: "</span> << endl ; <a name="l01031"></a>01031 DapIndent::Indent() ; <a name="l01032"></a>01032 <a class="code" href="classlibdap_1_1Grid.html#d147322e168c6750893b6913d7f3edc5">Map_citer</a> i = _map_vars.begin() ; <a name="l01033"></a>01033 <a class="code" href="classlibdap_1_1Grid.html#d147322e168c6750893b6913d7f3edc5">Map_citer</a> ie = _map_vars.end() ; <a name="l01034"></a>01034 <span class="keywordflow">for</span> (; i != ie; i++) { <a name="l01035"></a>01035 (*i)->dump(strm) ; <a name="l01036"></a>01036 } <a name="l01037"></a>01037 <a class="code" href="classlibdap_1_1DapIndent.html#65c519d0916b031bcf60ca8d26fc82f8">DapIndent::UnIndent</a>() ; <a name="l01038"></a>01038 <a class="code" href="classlibdap_1_1DapIndent.html#65c519d0916b031bcf60ca8d26fc82f8">DapIndent::UnIndent</a>() ; <a name="l01039"></a>01039 } <a name="l01040"></a>01040 <a name="l01041"></a>01041 } <span class="comment">// namespace libdap</span> <a name="l01042"></a>01042 </pre></div></div> <hr size="1"><address style="text-align: right;"><small>Generated on Wed Oct 7 19:57:07 2009 for libdap++ by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address> </body> </html>