casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TBData.h
Go to the documentation of this file.
00001 //# TBData.h: Data types used for loaded data.
00002 //# Copyright (C) 2005
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: $
00027 #ifndef TBDATA_H_
00028 #define TBDATA_H_
00029 
00030 #include <casaqt/QtBrowser/TBConstants.h>
00031 
00032 #include <casa/BasicSL/String.h>
00033 #include <casa/Containers/Record.h>
00034 #include <casa/Arrays/Array.h>
00035 
00036 #include <casa/namespace.h>
00037 using namespace std;
00038 
00039 namespace casa {
00040 
00041 //# Forward Declarations
00042 class TBArray;
00043 
00044 // <summary>
00045 // Data types used for loaded data.
00046 // </summary>
00047 //
00048 // <synopsis>
00049 // TBData is the abstract superclass for any data type that the browser knows
00050 // about.  The idea is to get around templates and other such unpleasantness
00051 // that causes unnecessary code copying.
00052 // </synopsis>
00053 
00054 class TBData {
00055 public:
00056     // Default Constructor.
00057     TBData();
00058     
00059     virtual ~TBData();
00060     
00061     
00062     // See TBData::asString().
00063     String displayValue();
00064     
00065     
00066     // asString() must be implemented by any subclass.  Returns this data
00067     // value in String form.  This method is especially important because
00068     // the browser uses this String to display in the GUI widgets.
00069     virtual String asString() = 0;
00070     
00071     // asDouble() must be implemented by any subclass, although the returned
00072     // value does not have to be valid for classes for which the value cannot
00073     // be represented as a double.
00074     virtual double asDouble() = 0;
00075     
00076     // asFloat() must be implemented by any subclass, although the returned
00077     // value does not have to be valid for classes for which the value cannot
00078     // be represented as a float.
00079     virtual float asFloat() = 0;
00080     
00081     // asInt() must be implemented by any subclass, although the returned
00082     // value does not have to be valid for classes for which the value cannot
00083     // be represented as an int.
00084     virtual int asInt() = 0;
00085     
00086     // asUInt() must be implemented by any subclass, although the returned
00087     // value does not have to be valid for classes for which the value cannot
00088     // be represented as an unsigned int.
00089     virtual unsigned int asUInt() = 0;
00090     
00091     // asBool() must be implemented by any subclass, although the returned
00092     // value does not have to be valid for classes for which the value cannot
00093     // be represented as a boolean.
00094     virtual bool asBool() = 0;
00095     
00096     // asChar() must be implemented by any subclass, although the returned
00097     // value does not have to be valid for classes for which the value cannot
00098     // be represented as a char.
00099     virtual char asChar() = 0;
00100     
00101     // asUChar() must be implemented by any subclass, although the returned
00102     // value does not have to be valid for classes for which the value cannot
00103     // be represented as an unsigned character.
00104     virtual unsigned char asUChar() = 0;
00105     
00106     // asShort() must be implemented by any subclass, although the returned
00107     // value does not have to be valid for classes for which the value cannot
00108     // be represented as a short.
00109     virtual short int asShort() = 0;
00110     
00111     // asComplex() must be implemented by any subclass, although the returned
00112     // value does not have to be valid for classes for which the value cannot
00113     // be represented as a complex.
00114     virtual pair<float, float> asComplex() = 0;
00115     
00116     // asDComplex() must be implemented by any subclass, although the returned
00117     // value does not have to be valid for classes for which the value cannot
00118     // be represented as a double complex.
00119     virtual pair<double, double> asDComplex() = 0;
00120     
00121     // asRecord() must be implemented by any subclass, although the returned
00122     // value does not have to be valid for classes for which the value cannot
00123     // be represented as a record.
00124     virtual Record* asRecord() = 0;
00125     
00126     
00127     // setValue() must be implemented by any subclass.  Sets this data's value
00128     // to the value of the given TBData.  Note: the behavior of this method
00129     // is undefined if the given TBData is not the same type as "this" TBData.
00130     virtual void setValue(TBData& value) = 0;
00131     
00132     // getType() must be implemented by any subclass.  Returns this TBData
00133     // object's type.  Must be one of TBConstants::TYPE_* definitions.
00134     virtual String getType() = 0;
00135     
00136     // equals() must be implemented by any subclass.  Returns true if the
00137     // given TBData is equal to this TBData object, false otherwise.  Note:
00138     // the behavior of this method is undefined if the given TBData is not of
00139     // the same type as "this" TBData.
00140     virtual bool equals(TBData* data) = 0;
00141     
00142     
00143     // Creates and returns a TBData object representing the given value and
00144     // type.  May return NULL if the value/type combination is invalid.
00145     // NOTE: this method currently does not work for Records in String form.
00146     static TBData* create(String value, String type);
00147     
00148     // Creates a TBArrayData object containing the data in the given TBArray
00149     // object with the given type.  NOTE: with the restructuring of the
00150     // browser to use TBDatas rather than Strings to store data, this method
00151     // should NOT be used.  It is currently being used as a helper method
00152     // for create(String, String), but its use is NOT encouraged.
00153     static TBData* create(TBArray* array, String type);
00154     
00155     // Creates and returns a copy of the given TBData.
00156     static TBData* create(TBData& data);
00157 };
00158 
00159 
00160 // <summary>
00161 // Implementation of TBData for String data.
00162 // </summary>
00163 
00164 class TBDataString : public TBData {
00165 public:
00166     // Constructor that takes the String data.
00167     TBDataString(String value);
00168     
00169     // Constructor that calls setValue().
00170     TBDataString(TBData& data);
00171     
00172     virtual ~TBDataString();
00173     
00174     
00175     // Returns the String value.
00176     String asString();
00177     
00178     // Invalid operations.
00179     // <group>
00180     double asDouble() { return 0; } 
00181     float asFloat() { return 0; }   
00182     int asInt() { return 0; }   
00183     unsigned int asUInt() { return 0; } 
00184     bool asBool() { return 0; } 
00185     char asChar() { return 0; } 
00186     unsigned char asUChar() { return 0; }   
00187     short int asShort() { return 0; }   
00188     pair<float, float> asComplex() { return pair<float, float>(0, 0); } 
00189     pair<double, double> asDComplex() { return pair<double, double>(0, 0); }    
00190     Record* asRecord() { return 0; }
00191     // </group>
00192     
00193     
00194     // Sets the value to the result of calling asString() on the given TBData.
00195     void setValue(TBData& value);
00196     
00197     // Returns the String type.
00198     String getType() { return TBConstants::TYPE_STRING; }
00199     
00200     // Returns true if the given data is a String type and the values are
00201     // equals, false otherwise.
00202     bool equals(TBData* data);
00203     
00204 private:
00205     // Value.
00206     String value;
00207 };
00208 
00209 
00210 // <summary>
00211 // Implementation of TBData for double data.
00212 // </summary>
00213 
00214 class TBDataDouble : public TBData {
00215 public:
00216     // Constructor that parses a double from the given String.
00217     TBDataDouble(String value);
00218     
00219     // Constructor that takes the double data.
00220     TBDataDouble(double value);
00221     
00222     // Constructor that calls setValue().
00223     TBDataDouble(TBData& data);
00224     
00225     virtual ~TBDataDouble();
00226     
00227     
00228     // Returns the value in String form.
00229     String asString();
00230     
00231     // Returns the double value.
00232     double asDouble();
00233     
00234     
00235     // Invalid operations.
00236     // <group>
00237     float asFloat() { return 0; }   
00238     int asInt() { return 0; }   
00239     unsigned int asUInt() { return 0; } 
00240     bool asBool() { return 0; } 
00241     char asChar() { return 0; } 
00242     unsigned char asUChar() { return 0; }   
00243     short int asShort() { return 0; }   
00244     pair<float, float> asComplex() { return pair<float, float>(0, 0); } 
00245     pair<double, double> asDComplex() { return pair<double, double>(0, 0); }    
00246     Record* asRecord() { return 0; }
00247     // </group>
00248     
00249     // If the given TBData is a String, parses a double from the String.
00250     // Otherwise sets the value to the result of the asDouble() call.
00251     void setValue(TBData& value);
00252     
00253     // Returns the double type.
00254     String getType() { return TBConstants::TYPE_DOUBLE; }
00255     
00256     // Returns true if the given data is a double type and their values are
00257     // equal, false otherwise.
00258     bool equals(TBData* data);
00259     
00260 private:
00261     // Value.
00262     double value;
00263 };
00264 
00265 
00266 // <summary>
00267 // Implementation of TBData for float data.
00268 // </summary>
00269 
00270 class TBDataFloat : public TBData {
00271 public:
00272     // Constructor that parses a float from the given String.
00273     TBDataFloat(String value);
00274     
00275     // Constructor that takes the float data.
00276     TBDataFloat(float value);
00277     
00278     // Constructor that calls setValue().
00279     TBDataFloat(TBData& data);
00280     
00281     virtual ~TBDataFloat();
00282     
00283     
00284     // Returns the value in String form.
00285     String asString();
00286     
00287     // Returns the value in double form.
00288     double asDouble();
00289     
00290     // Returns the float value.
00291     float asFloat();
00292     
00293     
00294     // Invalid operations.
00295     // <group>
00296     int asInt() { return 0; }   
00297     unsigned int asUInt() { return 0; } 
00298     bool asBool() { return 0; } 
00299     char asChar() { return 0; } 
00300     unsigned char asUChar() { return 0; }   
00301     short int asShort() { return 0; }   
00302     pair<float, float> asComplex() { return pair<float, float>(0, 0); } 
00303     pair<double, double> asDComplex() { return pair<double, double>(0, 0); }    
00304     Record* asRecord() { return 0; }
00305     // </group>
00306     
00307     
00308     // If the given TBData is a String, parses a float from the String.
00309     // Otherwise, if the given TBData is a float, sets the float value.
00310     void setValue(TBData& value);
00311     
00312     // Returns the float type.
00313     String getType() { return TBConstants::TYPE_FLOAT; }
00314     
00315     // Returns true if the given data is a float type and their values are
00316     // equal, false otherwise.
00317     bool equals(TBData* data);
00318     
00319 private:
00320     // Value.
00321     float value;
00322 };
00323 
00324 
00325 // <summary>
00326 // Implementation of TBData for integer data.
00327 // </summary>
00328 
00329 class TBDataInt : public TBData {
00330 public:
00331     // Constructor that parses an int from the given String.
00332     TBDataInt(String value);
00333     
00334     // Constructor that takes the int data.
00335     TBDataInt(int value);
00336     
00337     // Constructor that calls setValue().
00338     TBDataInt(TBData& data);
00339     
00340     virtual ~TBDataInt();
00341     
00342     
00343     // Returns the value in String form.
00344     String asString();
00345     
00346     // Returns the value in double form.
00347     double asDouble();
00348     
00349     // Returns the value.
00350     int asInt();
00351     
00352     
00353     // Invalid operations.
00354     // <group>
00355     float asFloat() { return 0; }
00356     unsigned int asUInt() { return 0; } 
00357     bool asBool() { return 0; } 
00358     char asChar() { return 0; } 
00359     unsigned char asUChar() { return 0; }   
00360     short int asShort() { return 0; }   
00361     pair<float, float> asComplex() { return pair<float, float>(0, 0); } 
00362     pair<double, double> asDComplex() { return pair<double, double>(0, 0); }    
00363     Record* asRecord() { return 0; }
00364     // </group>
00365     
00366     
00367     // If the given TBData is a String, parses an int from the String value.
00368     // Otherwise, if the given TBData is an int, sets the int value.
00369     void setValue(TBData& value);
00370     
00371     // Returns the int type.
00372     String getType() { return TBConstants::TYPE_INT; }
00373     
00374     // Returns true if the given data is an int type and their values are
00375     // equal, false otherwise
00376     bool equals(TBData* data);
00377     
00378 private:
00379     // Value.
00380     int value;
00381 };
00382 
00383 
00384 // <summary>
00385 // Implementation of TBData for unsigned int data.
00386 // </summary>
00387 
00388 class TBDataUInt : public TBData {
00389 public:
00390     // Constructor that parses an unsigned int from the given String.
00391     TBDataUInt(String value);
00392     
00393     // Constructor that takes the unsigned int data.
00394     TBDataUInt(unsigned int value);
00395     
00396     // Constructor that calls setValue().
00397     TBDataUInt(TBData& data);
00398     
00399     virtual ~TBDataUInt();
00400     
00401     
00402     // Returns the value in String form.
00403     String asString();
00404     
00405     // Returns the value in double form.
00406     double asDouble();
00407     
00408     // Returns the value.
00409     unsigned int asUInt();
00410     
00411     
00412     // Invalid operations.
00413     // <group>
00414     float asFloat() { return 0; }
00415     int asInt() { return 0; }
00416     bool asBool() { return 0; } 
00417     char asChar() { return 0; } 
00418     unsigned char asUChar() { return 0; }   
00419     short int asShort() { return 0; }   
00420     pair<float, float> asComplex() { return pair<float, float>(0, 0); } 
00421     pair<double, double> asDComplex() { return pair<double, double>(0, 0); }    
00422     Record* asRecord() { return 0; }
00423     // </group>
00424     
00425     
00426     // If the given TBData is a String, parses an unsigned int from the String
00427     // value.  Otherwise, if the given TBData is an unsigned int, sets the
00428     // unsigned int value.
00429     void setValue(TBData& value);
00430     
00431     // Returns the unsigned int type.
00432     String getType() { return TBConstants::TYPE_UINT; }
00433     
00434     // Returns true if the given data is an unsigned int type and their values
00435     // are equal, false otherwise
00436     bool equals(TBData* data);
00437     
00438 private:
00439     // Value.
00440     unsigned int value;
00441 };
00442 
00443 
00444 // <summary>
00445 // Implementation of TBData for boolean data.
00446 // </summary>
00447 
00448 class TBDataBool : public TBData {
00449 public:
00450     // Constructor that parses a boolean from the given String.
00451     TBDataBool(String value);
00452     
00453     // Constructor that takes the boolean data.
00454     TBDataBool(bool value);
00455     
00456     // Constructor that calls setValue().
00457     TBDataBool(TBData& data);
00458     
00459     virtual ~TBDataBool();
00460     
00461     
00462     // Returns the value in String form.
00463     String asString();
00464     
00465     // Returns the value in double form.
00466     double asDouble();
00467     
00468     // Returns the value in float form.
00469     float asFloat();
00470     
00471     // Returns the value in int form.
00472     int asInt();
00473     
00474     // Returns the value in unsigned int form.
00475     unsigned int asUInt();
00476     
00477     // Returns the value.
00478     bool asBool();
00479     
00480     
00481     // Invalid operations.
00482     // <group>
00483     char asChar() { return 0; } 
00484     unsigned char asUChar() { return 0; }   
00485     short int asShort() { return 0; }   
00486     pair<float, float> asComplex() { return pair<float, float>(0, 0); } 
00487     pair<double, double> asDComplex() { return pair<double, double>(0, 0); }    
00488     Record* asRecord() { return 0; }
00489     // </group>
00490     
00491     
00492     // If the given TBData is a String, parses a boolean from the String value.
00493     // Otherwise, if the given TBData is a boolean, sets the boolean value.
00494     void setValue(TBData& value);
00495     
00496     // Returns the boolean type.
00497     String getType() { return TBConstants::TYPE_BOOL; }
00498     
00499     // Returns true if the given data is a boolean type and their values are
00500     // equal, false otherwise
00501     bool equals(TBData* data);
00502     
00503 private:
00504     // Value.
00505     bool value;
00506 };
00507 
00508 
00509 // <summary>
00510 // Implementation of TBData for character data.
00511 // </summary>
00512 
00513 class TBDataChar : public TBData {
00514 public:
00515     // Constructor that takes the first character of the given String.
00516     TBDataChar(String value);
00517     
00518     // Constructor that takes the character data.
00519     TBDataChar(char value);
00520     
00521     // Constructor that calls setValue().
00522     TBDataChar(TBData& data);
00523     
00524     virtual ~TBDataChar();
00525     
00526     
00527     // Returns the value in String form.
00528     String asString();
00529     
00530     // Returns the value in int form.
00531     int asInt();
00532     
00533     // Returns the value in unsigned int form.
00534     unsigned int asUInt();
00535     
00536     // Returns the value.
00537     char asChar();
00538     
00539     
00540     // Invalid operations.
00541     // <group>
00542     double asDouble() { return 0; } 
00543     float asFloat() { return 0; }
00544     bool asBool() { return 0; }
00545     unsigned char asUChar() { return 0; }   
00546     short int asShort() { return 0; }   
00547     pair<float, float> asComplex() { return pair<float, float>(0, 0); } 
00548     pair<double, double> asDComplex() { return pair<double, double>(0, 0); }    
00549     Record* asRecord() { return 0; }
00550     // </group>
00551     
00552     
00553     // If the given TBData is a String, takes the first character of the
00554     // String value.  Otherwise, if the given TBData is a character, sets
00555     // the character value.
00556     void setValue(TBData& value);
00557     
00558     // Returns the character type.
00559     String getType() { return TBConstants::TYPE_CHAR; }
00560     
00561     // Returns true if the given data is a character type and their values are
00562     // equal, false otherwise
00563     bool equals(TBData* data);
00564     
00565 private:
00566     // Value.
00567     char value;
00568 };
00569 
00570 
00571 // <summary>
00572 // Implementation of TBData for unsigned character data.
00573 // </summary>
00574 
00575 class TBDataUChar : public TBData {
00576 public:
00577     // Constructor that takes the first character from the given String.
00578     TBDataUChar(String value);
00579     
00580     // Constructor that takes the unsigned character value.
00581     TBDataUChar(unsigned char value);
00582     
00583     // Constructor that calls setValue().
00584     TBDataUChar(TBData& data);
00585     
00586     virtual ~TBDataUChar();
00587     
00588     
00589     // Returns the value in String form.
00590     String asString();
00591     
00592     // Returns the value in int form.
00593     int asInt();
00594     
00595     // Returns the value in unsigned int form.
00596     unsigned int asUInt();
00597     
00598     // Returns the value.
00599     unsigned char asUChar();
00600     
00601     
00602     // Invalid operations.
00603     // <group>
00604     double asDouble() { return 0; } 
00605     float asFloat() { return 0; }
00606     bool asBool() { return 0; }
00607     char asChar() { return 0; } 
00608     short int asShort() { return 0; }   
00609     pair<float, float> asComplex() { return pair<float, float>(0, 0); } 
00610     pair<double, double> asDComplex() { return pair<double, double>(0, 0); }    
00611     Record* asRecord() { return 0; }
00612     // </group>
00613     
00614     
00615     // If the given TBData is a String, takes the first character of the
00616     // String value.  Otherwise, if the given TBData is an unsigned character,
00617     // sets the unsigned character value.
00618     void setValue(TBData& value);
00619     
00620     // Returns the unsigned character type.
00621     String getType() { return TBConstants::TYPE_UCHAR; }
00622     
00623     // Returns true if the given data is an unsigned character type and their
00624     // values are equal, false otherwise
00625     bool equals(TBData* data);
00626     
00627 private:
00628     // Value.
00629     unsigned char value;
00630 };
00631 
00632 
00633 // <summary>
00634 // Implementation of TBData for short data.
00635 // </summary>
00636 
00637 class TBDataShort : public TBData {
00638 public:
00639     // Constructor that parses a short from the given String.
00640     TBDataShort(String value);
00641     
00642     // Constructor that takes the short data.
00643     TBDataShort(short int value);
00644     
00645     // Constructor that calls setValue().
00646     TBDataShort(TBData& data);
00647     
00648     virtual ~TBDataShort();
00649     
00650     
00651     // Returns the value in String form.
00652     String asString();
00653     
00654     // Returns the value in double form.
00655     double asDouble();
00656     
00657     // Returns the value in float form.
00658     float asFloat();
00659     
00660     // Returns the value in int form.
00661     int asInt();
00662     
00663     // Returns the value in unsigned int form.
00664     unsigned int asUInt();
00665     
00666     // Returns the value.
00667     short int asShort();
00668     
00669     
00670     // Invalid operations.
00671     // <group>
00672     bool asBool() { return 0; }
00673     char asChar() { return 0; } 
00674     unsigned char asUChar() { return 0; }   
00675     pair<float, float> asComplex() { return pair<float, float>(0, 0); } 
00676     pair<double, double> asDComplex() { return pair<double, double>(0, 0); }    
00677     Record* asRecord() { return 0; }
00678     // </group>
00679     
00680     
00681     // If the given TBData is a String, parses a short from the String value.
00682     // Otherwise, if the given TBData is a short, sets the short value.
00683     void setValue(TBData& value);
00684     
00685     // Returns the short type.
00686     String getType() { return TBConstants::TYPE_SHORT; }
00687     
00688     // Returns true if the given data is a short type and their values are
00689     // equal, false otherwise
00690     bool equals(TBData* data);
00691     
00692 private:
00693     // Value.
00694     short int value;
00695 };
00696 
00697 
00698 // <summary>
00699 // Implementation of TBData for complex data.
00700 // </summary>
00701 
00702 class TBDataComplex : public TBData {
00703 public:
00704     // Constructor that parses a complex from the given String.
00705     TBDataComplex(String value);
00706     
00707     // Constructor that takes the complex data.
00708     TBDataComplex(pair<float, float> value);
00709     
00710     // Constructor that takes the complex data.
00711     TBDataComplex(complex<float> value);
00712     
00713     // Constructor that calls setValue().
00714     TBDataComplex(TBData& data);
00715     
00716     virtual ~TBDataComplex();
00717     
00718     
00719     // Returns the value in String form.
00720     String asString();
00721     
00722     // Returns the value in double complex form.
00723     pair<double, double> asDComplex();
00724     
00725     // Returns the value.
00726     pair<float, float> asComplex();
00727     
00728     
00729     // Invalid operations.
00730     // <group>
00731     double asDouble() { return 0; }
00732     float asFloat() { return 0; }
00733     int asInt() { return 0; }
00734     unsigned int asUInt() { return 0; }
00735     short int asShort() { return 0; }
00736     bool asBool() { return 0; }
00737     char asChar() { return 0; } 
00738     unsigned char asUChar() { return 0; }   
00739     Record* asRecord() { return 0; }
00740     // </group>
00741     
00742     
00743     // If the given TBData is a String, parses a complex from the String value.
00744     // Otherwise, if the given TBData is a complex, sets the complex value.
00745     void setValue(TBData& value);
00746     
00747     // Returns the complex type.
00748     String getType() { return TBConstants::TYPE_COMPLEX; }
00749     
00750     // Returns true if the given data is a complex type and their values are
00751     // equal, false otherwise
00752     bool equals(TBData* data);
00753     
00754 private:
00755     // Value.
00756     pair<float, float> value;
00757 };
00758 
00759 
00760 // <summary>
00761 // Implementation of TBData for double complex data.
00762 // </summary>
00763 
00764 class TBDataDComplex : public TBData {
00765 public:
00766     // Constructor that parses a double complex from the given String.
00767     TBDataDComplex(String value);
00768     
00769     // Constructor that takes the double complex data.
00770     TBDataDComplex(pair<double, double> value);
00771     
00772     // Constructor that takes the double complex data.
00773     TBDataDComplex(complex<double> value);
00774     
00775     // Constructor that calls setValue().
00776     TBDataDComplex(TBData& data);
00777     
00778     virtual ~TBDataDComplex();
00779     
00780     
00781     // Returns the value in String form.
00782     String asString();
00783     
00784     // Returns the value.
00785     pair<double, double> asDComplex();
00786     
00787     
00788     // Invalid operations.
00789     // <group>
00790     double asDouble() { return 0; }
00791     float asFloat() { return 0; }
00792     int asInt() { return 0; }
00793     unsigned int asUInt() { return 0; }
00794     short int asShort() { return 0; }
00795     bool asBool() { return 0; }
00796     char asChar() { return 0; } 
00797     unsigned char asUChar() { return 0; }   
00798     pair<float, float> asComplex() { return pair<float, float>(0, 0); }
00799     Record* asRecord() { return 0; }
00800     // </group>
00801     
00802     
00803     // If the given TBData is a String, parses a double complex from the
00804     // String value.  Otherwise, if the given TBData is a double complex,
00805     // sets the double complex value.
00806     void setValue(TBData& value);
00807     
00808     // Returns the double complex type.
00809     String getType() { return TBConstants::TYPE_DCOMPLEX; }
00810     
00811     // Returns true if the given data is a double complex type and their
00812     // values are equal, false otherwise
00813     bool equals(TBData* data);
00814     
00815 private:
00816     // Value.
00817     pair<double, double> value;
00818 };
00819 
00820 
00821 // <summary>
00822 // Implementation of TBData for Table data.
00823 // </summary>
00824 //
00825 // <synopsis>
00826 // Although Table types are stored differently on disk, for the browser all
00827 // we really care about is the location.  Therefore TBDataTable is really just
00828 // a TBDataString.
00829 // </synopsis>
00830 
00831 class TBDataTable : public TBDataString {
00832 public:
00833     // Constructor that takes the String value.  See
00834     // TBDataString::TBDataString().
00835     TBDataTable(String value) : TBDataString(value) { }
00836     
00837     // Constructor that calls setValue().  See TBDataString::setValue().
00838     TBDataTable(TBData& data) : TBDataString(data) { }
00839     
00840     ~TBDataTable() { }
00841     
00842     // Returns the table type.
00843     String getType() { return TBConstants::TYPE_TABLE; }
00844 };
00845 
00846 
00847 // <summary>
00848 // Implementation of TBData for Record data.
00849 // </summary>
00850 
00851 class TBDataRecord : public TBData {
00852 public:
00853     // Constructor that takes the Record data.
00854     TBDataRecord(const RecordInterface& value);
00855     
00856     // Constructor that takes the Record data.
00857     TBDataRecord(RecordInterface* value);
00858     
00859     // Constructor that calls setValue().
00860     TBDataRecord(TBData& data);
00861     
00862     virtual ~TBDataRecord();
00863     
00864     
00865     // Returns the value in String form.
00866     String asString();
00867     
00868     // Returns the value.
00869     Record* asRecord();
00870     
00871     
00872     // Invalid operations.
00873     // <group>
00874     double asDouble() { return 0; }
00875     float asFloat() { return 0; }
00876     int asInt() { return 0; }
00877     unsigned int asUInt() { return 0; }
00878     short int asShort() { return 0; }
00879     bool asBool() { return 0; }
00880     char asChar() { return 0; } 
00881     unsigned char asUChar() { return 0; }   
00882     pair<float, float> asComplex() { return pair<float, float>(0, 0); }
00883     pair<double, double> asDComplex() { return pair<double, double>(0, 0); }
00884     // </group>
00885     
00886     
00887     // Iff the given TBData is a Record, sets the Record value.
00888     void setValue(TBData& value);
00889     
00890     // Returns the Record type.
00891     String getType() { return TBConstants::TYPE_RECORD; }
00892     
00893     // Returns true if the given data is a Record type and their values are
00894     // equal, false otherwise
00895     bool equals(TBData* data);
00896     
00897 private:
00898     // Value.
00899     Record value;
00900 };
00901 
00902 
00903 // <summary>
00904 // Implementation of TBData for date data.
00905 // </summary>
00906 //
00907 // <synopsis>
00908 // A date is somewhat special in that the data is stored as a double that
00909 // represents Modified Julian Seconds, but when we view the data we want it
00910 // in a human-readable form.  For this reason, a TBDataDate stores two
00911 // values: the double representation and the String representation.
00912 // </synopsis>
00913 
00914 class TBDataDate : public TBData {
00915 public:
00916     // Constructor that parses a date from the given String and then stores
00917     // the human-readable value with the given number of decimals.
00918     TBDataDate(String value, int decimals= TBConstants::DEFAULT_DATE_DECIMALS);
00919     
00920     // Constructor that stores the date from the given double and then stores
00921     // the human-readable value with the given number of decimals.
00922     TBDataDate(double value, int decimals= TBConstants::DEFAULT_DATE_DECIMALS);
00923     
00924     // Constructor that calls setValue().
00925     TBDataDate(TBData& data);
00926     
00927     virtual ~TBDataDate();
00928     
00929     
00930     // Returns the human-readable value.
00931     String asString();
00932     
00933     // Returns the value.
00934     double asDouble();
00935     
00936     
00937     // Invalid operations.
00938     // <group>
00939     float asFloat() { return 0; }   
00940     int asInt() { return 0; }   
00941     unsigned int asUInt() { return 0; } 
00942     bool asBool() { return 0; } 
00943     char asChar() { return 0; } 
00944     unsigned char asUChar() { return 0; }   
00945     short int asShort() { return 0; }   
00946     pair<float, float> asComplex() { return pair<float, float>(0, 0); } 
00947     pair<double, double> asDComplex() { return pair<double, double>(0, 0); }    
00948     Record* asRecord() { return 0; }
00949     // </group>
00950     
00951     
00952     // If the given TBData is a String, parses a date from the String value.
00953     // Otherwise, if the given TBData is a double or date, sets the date value.
00954     void setValue(TBData& value);
00955     
00956     // Returns the date type.
00957     String getType() { return TBConstants::TYPE_DATE; }
00958     
00959     // Returns true if the given data is a date type and their values are
00960     // equal, false otherwise
00961     bool equals(TBData* data);
00962     
00963 private:
00964     // Value.
00965     double value;
00966     
00967     // Human-readable representation of value.
00968     String valueStr;
00969 };
00970 
00971 
00972 // <summary>
00973 // Data type that holds an array.
00974 // </summary>
00975 //
00976 // <synopsis>
00977 // TBArrayData is the abstract class for array data types that the browser
00978 // knows about.  Subclasses of TBArrayData do not have to implement much of
00979 // the abstract methods in TBData, but they do have to implement some
00980 // array-specific methods.  Because of the way the browser is set up, an
00981 // array may or may not have actual data loaded into it; generally speaking,
00982 // one-dimensional arrays are loaded (copied) immediately upon construction
00983 // whereas other arrays must be manually loaded.  This is to save space.
00984 // </synopsis>
00985 
00986 class TBArrayData : public TBData {
00987 public:
00988     // Default Constructor.
00989     TBArrayData();
00990     
00991     ~TBArrayData();
00992     
00993     
00994     // Returns the array's shape.
00995     vector<int> getShape();
00996     
00997     // Returns true if the array has data loaded into it, false otherwise.
00998     bool isLoaded();
00999     
01000     // Returns true if the array is one-dimensional, false otherwise.
01001     bool isOneDimensional();
01002     
01003     // Returns true if the given coordinate is a valid index for this array
01004     // given its shape, false otherwise.
01005     bool coordIsValid(vector<int> d);
01006     
01007     // Returns true if the array is empty (i.e., all dimensions have size 0),
01008     // false otherwise.
01009     bool isEmpty();
01010     
01011     // Returns the first item in the array, or NULL if there is no data loaded.
01012     TBData* firstItem();
01013 
01014     
01015     // dataAt() must be implemented by any subclass.  Returns a TBData copy
01016     // of the data at the given coordinates, or NULL if the coordinates are
01017     // invalid or there is no loaded data.  NOTE: generally speaking, since
01018     // subclasses do not internally store their data as arrays of TBData*,
01019     // the returned TBData object must be deleted by the caller.
01020     virtual TBData* dataAt(vector<int> d) = 0;  
01021     
01022     // asString() must be implemented by any subclass.  Generally speaking,
01023     // should return the array data for one-dimensional arrays or the shape
01024     // and type otherwise.
01025     virtual String asString() = 0;
01026     
01027     // release() must be implemented by any subclass.  If data is loaded,
01028     // release it and free the memory.
01029     virtual bool release() = 0;
01030     
01031     // setDataAt() must be implemented by any subclass.  Sets the data at
01032     // the given coordinates to the given value.  NOTE: this method's behavior
01033     // is undefined if the type of the TBData does not match the type of the
01034     // array.
01035     virtual void setDataAt(vector<int> d, TBData& value) = 0;
01036     
01037     
01038     // Invalid operations.
01039     // <group>
01040     double asDouble() { return 0; }
01041     float asFloat() { return 0; }   
01042     int asInt() { return 0; }   
01043     unsigned int asUInt() { return 0; } 
01044     bool asBool() { return 0; } 
01045     char asChar() { return 0; } 
01046     unsigned char asUChar() { return 0; }   
01047     short int asShort() { return 0; }   
01048     pair<float, float> asComplex() { return pair<float, float>(0, 0); } 
01049     pair<double, double> asDComplex() { return pair<double, double>(0, 0); }    
01050     Record* asRecord() { return 0; }
01051     void setValue(TBData& value) { (void)value; }
01052     
01053     bool equals(TBData* data) { return false; (void)data; }
01054     // </group>
01055     
01056     
01057     // contains() must be implemented by any subclass.  Returns true if this
01058     // array has data loaded and contains the given value, false otherwise.
01059     virtual bool contains(TBData* data) = 0;
01060     
01061     // containsBetween() must be implemented by any subclass.  Returns true
01062     // if this array has data loaded and contains a value between the two
01063     // given values, false otherwise.  NOTE: the behavior is undefined for
01064     // arrays with non-numerical values.
01065     virtual bool containsBetween(TBData* data, TBData* data2) = 0;
01066     
01067     // containsLessThan() must be implemented by any subclass.  Returns true
01068     // if this array has data loaded and contains a value less than the
01069     // given value, false otherwise.  NOTE: the behavior is undefined for
01070     // arrays with non-numerical values.
01071     virtual bool containsLessThan(TBData* data) = 0;
01072     
01073     // containsGreaterThan() must be implemented by any subclass.  Returns true
01074     // if this array has data loaded and contains a value greater than the
01075     // given value, false otherwise.  NOTE: the behavior is undefined for
01076     // arrays with non-numerical values.
01077     virtual bool containsGreaterThan(TBData* data) = 0;
01078     
01079     // to1DString() must be implemented by any subclass.  Returns a "flattened"
01080     // version of the array.
01081     virtual String to1DString() = 0;
01082     
01083 protected:
01084     // Array shape.
01085     vector<int> shape;
01086     
01087     // Whether data is loaded.
01088     bool loaded;
01089     
01090     // Whether the array is one-dimensional.
01091     bool oneDim;
01092 };
01093 
01094 
01095 // <summary>
01096 // Implementation of TBArrayData for String array data.
01097 // </summary>
01098 
01099 class TBArrayDataString : public TBArrayData {
01100 public:
01101     // Default constructor.  Builds an empty, unloaded array.
01102     TBArrayDataString();
01103     
01104     // Constructor that takes the value and whether or not to load (copy) the
01105     // given data or not.  Note: data is always loaded for one-dimensional
01106     // arrays.
01107     TBArrayDataString(const Array<String>& value, bool full = false);
01108     
01109     // Constructor that copies the given data if it is the correct type.
01110     TBArrayDataString(TBData& data);
01111     
01112     ~TBArrayDataString();
01113     
01114     
01115     // See TBArrayData::dataAt().  Returns data of type String.
01116     TBData* dataAt(vector<int> d);
01117     
01118     // Returns the value.
01119     Array<String>& data() { return value; }
01120     
01121     // Returns the String representation of this array.  For one-dimensional,
01122     // loaded arrays returns the values; otherwise returns the shape and type.
01123     String asString();
01124     
01125     // Loads the given data into the array.
01126     void load(const Array<String>& value);
01127     
01128     // Releases the loaded data, if any.  Returns whether the release was
01129     // successful or not.
01130     bool release();
01131     
01132     // If the array is loaded, sets the value at the given coordinates (if
01133     // valid) to the given data.  This method is not defined if the given
01134     // value is not of the correct type.
01135     void setDataAt(vector<int> d, TBData& value);
01136     
01137     
01138     // Returns the String array type.
01139     String getType() { return TBConstants::TYPE_ARRAY_STRING; }
01140     
01141     // See TBArrayData::contains().  Returns false if the given data is not
01142     // of type String.
01143     bool contains(TBData* data);
01144     
01145     // See TBArrayData::containsBetween().  Returns false because Strings
01146     // are not numberable.
01147     bool containsBetween(TBData* data, TBData* data2) { return false; (void)data,(void)data2; }
01148     
01149     // See TBArrayData::containsLessThan().  Returns false because Strings
01150     // are not numberable.
01151     bool containsLessThan(TBData* data) { return false; (void)data; }
01152     
01153     // See TBArrayData::containsGreaterThan().  Returns false because Strings
01154     // are not numberable.
01155     bool containsGreaterThan(TBData* data)  { (void)data;   return false; }
01156     
01157     // See TBArrayData::to1DString().
01158     String to1DString();
01159     
01160 private:
01161     // Value.
01162     Array<String> value;
01163 };
01164 
01165 
01166 // <summary>
01167 // Implementation of TBArrayData for double array data.
01168 // </summary>
01169 
01170 class TBArrayDataDouble : public TBArrayData {
01171 public:
01172     // Default constructor.  Builds an empty, unloaded array.
01173     TBArrayDataDouble();
01174     
01175     // Constructor that takes the value and whether or not to load (copy) the
01176     // given data or not.  Note: data is always loaded for one-dimensional
01177     // arrays.
01178     TBArrayDataDouble(const Array<Double>& value, bool full = false);
01179     
01180     // Constructor that copies the given data if it is the correct type.
01181     TBArrayDataDouble(TBData& data);
01182     
01183     ~TBArrayDataDouble();
01184     
01185     
01186     // See TBArrayData::dataAt().  Returns data of type double.
01187     TBData* dataAt(vector<int> d);
01188     
01189     // Returns the value.
01190     Array<Double>& data() { return value; }
01191     
01192     // Returns the String representation of this array.  For one-dimensional,
01193     // loaded arrays returns the values; otherwise returns the shape and type.
01194     String asString();
01195     
01196     // Loads the given data into the array.
01197     void load(const Array<Double>& value);
01198     
01199     // Releases the loaded data, if any.  Returns whether the release was
01200     // successful or not.
01201     bool release();
01202     
01203     // If the array is loaded, sets the value at the given coordinates (if
01204     // valid) to the given data.  This method is not defined if the given
01205     // value is not of the correct type.
01206     void setDataAt(vector<int> d, TBData& value);
01207     
01208     
01209     // Returns the double array type.
01210     String getType() { return TBConstants::TYPE_ARRAY_DOUBLE; }
01211     
01212     // See TBArrayData::contains().  Returns false if the given data is not
01213     // of type double.
01214     bool contains(TBData* data);
01215     
01216     // See TBArrayData::containsBetween().  Returns false if either data is
01217     // not of type double.
01218     bool containsBetween(TBData* data, TBData* data2);
01219     
01220     // See TBArrayData::containsLessThan().  Returns false if either data is
01221     // not of type double.
01222     bool containsLessThan(TBData* data);
01223     
01224     // See TBArrayData::containsGreaterThan().  Returns false if either data is
01225     // not of type double.
01226     bool containsGreaterThan(TBData* data);
01227     
01228     // See TBArrayData::to1DString().
01229     String to1DString();
01230     
01231 private:
01232     // Value.
01233     Array<Double> value;
01234 };
01235 
01236 
01237 // <summary>
01238 // Implementation of TBArrayData for float array data.
01239 // </summary>
01240 
01241 class TBArrayDataFloat : public TBArrayData {
01242 public:
01243     // Default constructor.  Builds an empty, unloaded array.
01244     TBArrayDataFloat();
01245     
01246     // Constructor that takes the value and whether or not to load (copy) the
01247     // given data or not.  Note: data is always loaded for one-dimensional
01248     // arrays.
01249     TBArrayDataFloat(const Array<Float>& value, bool full = false);
01250     
01251     // Constructor that copies the given data if it is the correct type.
01252     TBArrayDataFloat(TBData& data);
01253     
01254     ~TBArrayDataFloat();
01255     
01256     
01257     // See TBArrayData::dataAt().  Returns data of type float.
01258     TBData* dataAt(vector<int> d);
01259     
01260     // Returns the value.
01261     Array<Float>& data() { return value; }
01262     
01263     // Returns the String representation of this array.  For one-dimensional,
01264     // loaded arrays returns the values; otherwise returns the shape and type.
01265     String asString();
01266     
01267     // Loads the given data into the array.
01268     void load(const Array<Float>& value);
01269     
01270     // Releases the loaded data, if any.  Returns whether the release was
01271     // successful or not.
01272     bool release();
01273     
01274     // If the array is loaded, sets the value at the given coordinates (if
01275     // valid) to the given data.  This method is not defined if the given
01276     // value is not of the correct type.
01277     void setDataAt(vector<int> d, TBData& value);
01278     
01279     
01280     // Returns the float array type.
01281     String getType() { return TBConstants::TYPE_ARRAY_FLOAT; }
01282     
01283     // See TBArrayData::contains().  Returns false if the given data is not
01284     // of type float.
01285     bool contains(TBData* data);
01286     
01287     // See TBArrayData::containsBetween().  Returns false if either data is
01288     // not of type float.
01289     bool containsBetween(TBData* data, TBData* data2);
01290     
01291     // See TBArrayData::containsLessThan().  Returns false if either data is
01292     // not of type float.
01293     bool containsLessThan(TBData* data);
01294     
01295     // See TBArrayData::containsGreaterThan().  Returns false if either data is
01296     // not of type float.
01297     bool containsGreaterThan(TBData* data);
01298     
01299     // See TBArrayData::to1DString().
01300     String to1DString();
01301     
01302 private:
01303     // Value.
01304     Array<Float> value;
01305 };
01306 
01307 
01308 // <summary>
01309 // Implementation of TBArrayData for int array data.
01310 // </summary>
01311 
01312 class TBArrayDataInt : public TBArrayData {
01313 public:
01314     // Default constructor.  Builds an empty, unloaded array.
01315     TBArrayDataInt();
01316     
01317     // Constructor that takes the value and whether or not to load (copy) the
01318     // given data or not.  Note: data is always loaded for one-dimensional
01319     // arrays.
01320     TBArrayDataInt(const Array<Int>& value, bool full = false);
01321     
01322     // Constructor that copies the given data if it is the correct type.
01323     TBArrayDataInt(TBData& data);
01324     
01325     ~TBArrayDataInt();
01326     
01327     
01328     // See TBArrayData::dataAt().  Returns data of type int.
01329     TBData* dataAt(vector<int> d);
01330     
01331     // Returns the value.
01332     Array<Int>& data() { return value; }
01333     
01334     // Returns the String representation of this array.  For one-dimensional,
01335     // loaded arrays returns the values; otherwise returns the shape and type.
01336     String asString();
01337     
01338     // Loads the given data into the array.
01339     void load(const Array<Int>& value);
01340     
01341     // Releases the loaded data, if any.  Returns whether the release was
01342     // successful or not.
01343     bool release();
01344     
01345     // If the array is loaded, sets the value at the given coordinates (if
01346     // valid) to the given data.  This method is not defined if the given
01347     // value is not of the correct type.
01348     void setDataAt(vector<int> d, TBData& value);
01349     
01350     
01351     // Returns the int array type.
01352     String getType() { return TBConstants::TYPE_ARRAY_INT; }
01353     
01354     // See TBArrayData::contains().  Returns false if the given data is not
01355     // of type int.
01356     bool contains(TBData* data);
01357     
01358     // See TBArrayData::containsBetween().  Returns false if either data is
01359     // not of type int.
01360     bool containsBetween(TBData* data, TBData* data2);
01361     
01362     // See TBArrayData::containsLessThan().  Returns false if either data is
01363     // not of type int.
01364     bool containsLessThan(TBData* data);
01365     
01366     // See TBArrayData::containsGreaterThan().  Returns false if either data is
01367     // not of type int.
01368     bool containsGreaterThan(TBData* data);
01369     
01370     // See TBArrayData::to1DString().
01371     String to1DString();
01372     
01373 private:
01374     // Value.
01375     Array<Int> value;
01376 };
01377 
01378 
01379 // <summary>
01380 // Implementation of TBArrayData for unsigned int array data.
01381 // </summary>
01382 
01383 class TBArrayDataUInt : public TBArrayData {
01384 public:
01385     // Default constructor.  Builds an empty, unloaded array.
01386     TBArrayDataUInt();
01387     
01388     // Constructor that takes the value and whether or not to load (copy) the
01389     // given data or not.  Note: data is always loaded for one-dimensional
01390     // arrays.
01391     TBArrayDataUInt(const Array<uInt>& value, bool full = false);
01392     
01393     // Constructor that copies the given data if it is the correct type.
01394     TBArrayDataUInt(TBData& data);
01395     
01396     ~TBArrayDataUInt();
01397     
01398     
01399     // See TBArrayData::dataAt().  Returns data of type unsigned int.
01400     TBData* dataAt(vector<int> d);
01401     
01402     // Returns the value.
01403     Array<uInt>& data() { return value; }
01404     
01405     // Returns the String representation of this array.  For one-dimensional,
01406     // loaded arrays returns the values; otherwise returns the shape and type.
01407     String asString();
01408     
01409     // Loads the given data into the array.
01410     void load(const Array<uInt>& value);
01411     
01412     // Releases the loaded data, if any.  Returns whether the release was
01413     // successful or not.
01414     bool release();
01415     
01416     // If the array is loaded, sets the value at the given coordinates (if
01417     // valid) to the given data.  This method is not defined if the given
01418     // value is not of the correct type.
01419     void setDataAt(vector<int> d, TBData& value);
01420     
01421     
01422     // Returns the unsigned int array type.
01423     String getType() { return TBConstants::TYPE_ARRAY_UINT; }
01424     
01425     // See TBArrayData::contains().  Returns false if the given data is not
01426     // of type unsigned int.
01427     bool contains(TBData* data);
01428     
01429     // See TBArrayData::containsBetween().  Returns false if either data is
01430     // not of type unsigned int.
01431     bool containsBetween(TBData* data, TBData* data2);
01432     
01433     // See TBArrayData::containsLessThan().  Returns false if either data is
01434     // not of type unsigned int.
01435     bool containsLessThan(TBData* data);
01436     
01437     // See TBArrayData::containsGreaterThan().  Returns false if either data is
01438     // not of type unsigned int.
01439     bool containsGreaterThan(TBData* data);
01440     
01441     // See TBArrayData::to1DString().
01442     String to1DString();
01443     
01444 private:
01445     // Value.
01446     Array<uInt> value;
01447 };
01448 
01449 
01450 // <summary>
01451 // Implementation of TBArrayData for boolean array data.
01452 // </summary>
01453 
01454 class TBArrayDataBool : public TBArrayData {
01455 public:
01456     // Default constructor.  Builds an empty, unloaded array.
01457     TBArrayDataBool();
01458     
01459     // Constructor that takes the value and whether or not to load (copy) the
01460     // given data or not.  Note: data is always loaded for one-dimensional
01461     // arrays.
01462     TBArrayDataBool(const Array<Bool>& value, bool full = false);
01463     
01464     // Constructor that copies the given data if it is the correct type.
01465     TBArrayDataBool(TBData& data);
01466     
01467     ~TBArrayDataBool();
01468     
01469     
01470     // See TBArrayData::dataAt().  Returns data of type boolean.
01471     TBData* dataAt(vector<int> d);
01472     
01473     // Returns the value.
01474     Array<Bool>& data() { return value; }
01475     
01476     // Returns the String representation of this array.  For one-dimensional,
01477     // loaded arrays returns the values; otherwise returns the shape and type.
01478     String asString();
01479     
01480     // Loads the given data into the array.
01481     void load(const Array<Bool>& value);
01482     
01483     // Releases the loaded data, if any.  Returns whether the release was
01484     // successful or not.
01485     bool release();
01486     
01487     // If the array is loaded, sets the value at the given coordinates (if
01488     // valid) to the given data.  This method is not defined if the given
01489     // value is not of the correct type.
01490     void setDataAt(vector<int> d, TBData& value);
01491     
01492     
01493     // Returns the boolean array type.
01494     String getType() { return TBConstants::TYPE_ARRAY_BOOL; }
01495     
01496     // See TBArrayData::contains().  Returns false if the given data is not
01497     // of type boolean.
01498     bool contains(TBData* data);
01499     
01500     // See TBArrayData::containsBetween().  Returns false if either data is
01501     // not of type boolean.
01502     bool containsBetween(TBData* data, TBData* data2);
01503     
01504     // See TBArrayData::containsLessThan().  Returns false if either data is
01505     // not of type boolean.
01506     bool containsLessThan(TBData* data);
01507     
01508     // See TBArrayData::containsGreaterThan().  Returns false if either data is
01509     // not of type boolean.
01510     bool containsGreaterThan(TBData* data);
01511     
01512     // See TBArrayData::to1DString().
01513     String to1DString();
01514     
01515 private:
01516     // Value.
01517     Array<Bool> value;
01518 };
01519 
01520 
01521 // <summary>
01522 // Implementation of TBArrayData for character array data.
01523 // </summary>
01524 
01525 class TBArrayDataChar : public TBArrayData {
01526 public:
01527     // Default constructor.  Builds an empty, unloaded array.
01528     TBArrayDataChar();
01529     
01530     // Constructor that takes the value and whether or not to load (copy) the
01531     // given data or not.  Note: data is always loaded for one-dimensional
01532     // arrays.
01533     TBArrayDataChar(const Array<Char>& value, bool full = false);
01534     
01535     // Constructor that copies the given data if it is the correct type.
01536     TBArrayDataChar(TBData& data);
01537     
01538     ~TBArrayDataChar();
01539     
01540     
01541     // See TBArrayData::dataAt().  Returns data of type character.
01542     TBData* dataAt(vector<int> d);
01543     
01544     // Returns the value.
01545     Array<Char>& data() { return value; }
01546     
01547     // Returns the String representation of this array.  For one-dimensional,
01548     // loaded arrays returns the values; otherwise returns the shape and type.
01549     String asString();
01550     
01551     // Loads the given data into the array.
01552     void load(const Array<Char>& value);
01553     
01554     // Releases the loaded data, if any.  Returns whether the release was
01555     // successful or not.
01556     bool release();
01557     
01558     // If the array is loaded, sets the value at the given coordinates (if
01559     // valid) to the given data.  This method is not defined if the given
01560     // value is not of the correct type.
01561     void setDataAt(vector<int> d, TBData& value);
01562     
01563     
01564     // Returns the character array type.
01565     String getType() { return TBConstants::TYPE_ARRAY_CHAR; }
01566     
01567     // See TBArrayData::contains().  Returns false if the given data is not
01568     // of type character.
01569     bool contains(TBData* data);
01570     
01571     // See TBArrayData::containsBetween().  Returns false if either data is
01572     // not of type character.
01573     bool containsBetween(TBData* data, TBData* data2);
01574     
01575     // See TBArrayData::containsLessThan().  Returns false if either data is
01576     // not of type character.
01577     bool containsLessThan(TBData* data);
01578     
01579     // See TBArrayData::containsGreaterThan().  Returns false if either data is
01580     // not of type character.
01581     bool containsGreaterThan(TBData* data);
01582     
01583     // See TBArrayData::to1DString().
01584     String to1DString();
01585     
01586 private:
01587     // Value.
01588     Array<Char> value;
01589 };
01590 
01591 
01592 // <summary>
01593 // Implementation of TBArrayData for unsigned character array data.
01594 // </summary>
01595 
01596 class TBArrayDataUChar : public TBArrayData {
01597 public:
01598     // Default constructor.  Builds an empty, unloaded array.
01599     TBArrayDataUChar();
01600     
01601     // Constructor that takes the value and whether or not to load (copy) the
01602     // given data or not.  Note: data is always loaded for one-dimensional
01603     // arrays.
01604     TBArrayDataUChar(const Array<uChar>& value, bool full = false);
01605     
01606     // Constructor that copies the given data if it is the correct type.
01607     TBArrayDataUChar(TBData& data);
01608     
01609     ~TBArrayDataUChar();
01610     
01611     
01612     // See TBArrayData::dataAt().  Returns data of type unsigned character.
01613     TBData* dataAt(vector<int> d);
01614     
01615     // Returns the value.
01616     Array<uChar>& data() { return value; }
01617     
01618     // Returns the String representation of this array.  For one-dimensional,
01619     // loaded arrays returns the values; otherwise returns the shape and type.
01620     String asString();
01621     
01622     // Loads the given data into the array.
01623     void load(const Array<uChar>& value);
01624     
01625     // Releases the loaded data, if any.  Returns whether the release was
01626     // successful or not.
01627     bool release();
01628     
01629     // If the array is loaded, sets the value at the given coordinates (if
01630     // valid) to the given data.  This method is not defined if the given
01631     // value is not of the correct type.
01632     void setDataAt(vector<int> d, TBData& value);
01633     
01634     
01635     // Returns the unsigned character array type.
01636     String getType() { return TBConstants::TYPE_ARRAY_UCHAR; }
01637     
01638     // See TBArrayData::contains().  Returns false if the given data is not
01639     // of type unsigned char.
01640     bool contains(TBData* data);
01641     
01642     // See TBArrayData::containsBetween().  Returns false if either data is
01643     // not of type unsigned character.
01644     bool containsBetween(TBData* data, TBData* data2);
01645     
01646     // See TBArrayData::containsLessThan().  Returns false if either data is
01647     // not of type unsigned character.
01648     bool containsLessThan(TBData* data);
01649     
01650     // See TBArrayData::containsGreaterThan().  Returns false if either data is
01651     // not of type unsigned character.
01652     bool containsGreaterThan(TBData* data);
01653     
01654     // See TBArrayData::to1DString().
01655     String to1DString();
01656     
01657 private:
01658     // Value.
01659     Array<uChar> value;
01660 };
01661 
01662 
01663 // <summary>
01664 // Implementation of TBArrayData for short array data.
01665 // </summary>
01666 
01667 class TBArrayDataShort : public TBArrayData {
01668 public:
01669     // Default constructor.  Builds an empty, unloaded array.
01670     TBArrayDataShort();
01671     
01672     // Constructor that takes the value and whether or not to load (copy) the
01673     // given data or not.  Note: data is always loaded for one-dimensional
01674     // arrays.
01675     TBArrayDataShort(const Array<Short>& value, bool full = false);
01676     
01677     // Constructor that copies the given data if it is the correct type.
01678     TBArrayDataShort(TBData& data);
01679     
01680     ~TBArrayDataShort();
01681     
01682     
01683     // See TBArrayData::dataAt().  Returns data of type short.
01684     TBData* dataAt(vector<int> d);
01685     
01686     // Returns the value.
01687     Array<Short>& data() { return value; }
01688     
01689     // Returns the String representation of this array.  For one-dimensional,
01690     // loaded arrays returns the values; otherwise returns the shape and type.
01691     String asString();
01692     
01693     // Loads the given data into the array.
01694     void load(const Array<Short>& value);
01695     
01696     // Releases the loaded data, if any.  Returns whether the release was
01697     // successful or not.
01698     bool release();
01699     
01700     // If the array is loaded, sets the value at the given coordinates (if
01701     // valid) to the given data.  This method is not defined if the given
01702     // value is not of the correct type.
01703     void setDataAt(vector<int> d, TBData& value);
01704     
01705     
01706     // Returns the short array type.
01707     String getType() { return TBConstants::TYPE_ARRAY_SHORT; }
01708     
01709     // See TBArrayData::contains().  Returns false if the given data is not
01710     // of type short.
01711     bool contains(TBData* data);
01712     
01713     // See TBArrayData::containsBetween().  Returns false if either data is
01714     // not of type short.
01715     bool containsBetween(TBData* data, TBData* data2);
01716     
01717     // See TBArrayData::containsLessThan().  Returns false if either data is
01718     // not of type short.
01719     bool containsLessThan(TBData* data);
01720     
01721     // See TBArrayData::containsGreaterThan().  Returns false if either data is
01722     // not of type short.
01723     bool containsGreaterThan(TBData* data);
01724     
01725     // See TBArrayData::to1DString().
01726     String to1DString();
01727     
01728 private:
01729     // Value.
01730     Array<Short> value;
01731 };
01732 
01733 
01734 // <summary>
01735 // Implementation of TBArrayData for complex array data.
01736 // </summary>
01737 
01738 class TBArrayDataComplex : public TBArrayData {
01739 public:
01740     // Default constructor.  Builds an empty, unloaded array.
01741     TBArrayDataComplex();
01742     
01743     // Constructor that takes the value and whether or not to load (copy) the
01744     // given data or not.  Note: data is always loaded for one-dimensional
01745     // arrays.
01746     TBArrayDataComplex(const Array<Complex>& value, bool full = false);
01747     
01748     // Constructor that copies the given data if it is the correct type.
01749     TBArrayDataComplex(TBData& data);
01750     
01751     ~TBArrayDataComplex();
01752     
01753     
01754     // See TBArrayData::dataAt().  Returns data of type complex.
01755     TBData* dataAt(vector<int> d);
01756     
01757     // Returns the value.
01758     Array<Complex>& data() { return value; }
01759     
01760     // Returns the String representation of this array.  For one-dimensional,
01761     // loaded arrays returns the values; otherwise returns the shape and type.
01762     String asString();
01763     
01764     // Loads the given data into the array.
01765     void load(const Array<Complex>& value);
01766     
01767     // Releases the loaded data, if any.  Returns whether the release was
01768     // successful or not.
01769     bool release();
01770     
01771     // If the array is loaded, sets the value at the given coordinates (if
01772     // valid) to the given data.  This method is not defined if the given
01773     // value is not of the correct type.
01774     void setDataAt(vector<int> d, TBData& value);
01775     
01776     
01777     // Returns the complex array type.
01778     String getType() { return TBConstants::TYPE_ARRAY_COMPLEX; }
01779     
01780     // See TBArrayData::contains().  Returns false if the given data is not
01781     // of type complex.
01782     bool contains(TBData* data);
01783     
01784     // See TBArrayData::containsBetween().  Returns false if either data is
01785     // not of type complex.
01786     bool containsBetween(TBData* data, TBData* data2);
01787     
01788     // See TBArrayData::containsLessThan().  Returns false if either data is
01789     // not of type complex.
01790     bool containsLessThan(TBData* data);
01791     
01792     // See TBArrayData::containsGreaterThan().  Returns false if either data is
01793     // not of type complex.
01794     bool containsGreaterThan(TBData* data);
01795     
01796     // See TBArrayData::to1DString().
01797     String to1DString();
01798     
01799 private:
01800     // Value.
01801     Array<Complex> value;
01802 };
01803 
01804 
01805 // <summary>
01806 // Implementation of TBArrayData for double complex array data.
01807 // </summary>
01808 
01809 class TBArrayDataDComplex : public TBArrayData {
01810 public:
01811     // Default constructor.  Builds an empty, unloaded array.
01812     TBArrayDataDComplex();
01813     
01814     // Constructor that takes the value and whether or not to load (copy) the
01815     // given data or not.  Note: data is always loaded for one-dimensional
01816     // arrays.
01817     TBArrayDataDComplex(const Array<DComplex>& value, bool full = false);
01818     
01819     // Constructor that copies the given data if it is the correct type.
01820     TBArrayDataDComplex(TBData& data);
01821     
01822     ~TBArrayDataDComplex();
01823     
01824     
01825     // See TBArrayData::dataAt().  Returns data of type double complex.
01826     TBData* dataAt(vector<int> d);
01827     
01828     // Returns the value.
01829     Array<DComplex>& data() { return value; }
01830     
01831     // Returns the String representation of this array.  For one-dimensional,
01832     // loaded arrays returns the values; otherwise returns the shape and type.
01833     String asString();
01834     
01835     // Loads the given data into the array.
01836     void load(const Array<DComplex>& value);
01837     
01838     // Releases the loaded data, if any.  Returns whether the release was
01839     // successful or not.
01840     bool release();
01841     
01842     // If the array is loaded, sets the value at the given coordinates (if
01843     // valid) to the given data.  This method is not defined if the given
01844     // value is not of the correct type.
01845     void setDataAt(vector<int> d, TBData& value);
01846     
01847     
01848     // Returns the double complex array type.
01849     String getType() { return TBConstants::TYPE_ARRAY_DCOMPLEX; }
01850     
01851     // See TBArrayData::contains().  Returns false if the given data is not
01852     // of type double complex.
01853     bool contains(TBData* data);
01854     
01855     // See TBArrayData::containsBetween().  Returns false if either data is
01856     // not of type double complex.
01857     bool containsBetween(TBData* data, TBData* data2);
01858     
01859     // See TBArrayData::containsLessThan().  Returns false if either data is
01860     // not of type double complex.
01861     bool containsLessThan(TBData* data);
01862     
01863     // See TBArrayData::containsGreaterThan().  Returns false if either data is
01864     // not of type double complex.
01865     bool containsGreaterThan(TBData* data);
01866     
01867     // See TBArrayData::to1DString().
01868     String to1DString();
01869     
01870 private:
01871     // Value.
01872     Array<DComplex> value;
01873 };
01874 
01875 }
01876 
01877 #endif /*TBDATA_H_*/