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