Isis 3.0 Developer's Reference (API) |
Home |
00001 #ifndef CubeAttribute_h 00002 #define CubeAttribute_h 00003 00026 #include <string> 00027 00028 #include "Cube.h" 00029 #include "Endian.h" 00030 #include "iException.h" 00031 #include "iString.h" 00032 #include "PixelType.h" 00033 #include "Pvl.h" 00034 00035 namespace Isis { 00036 00043 enum RangeType { 00044 PropagateRange, 00045 RangeSet, 00046 }; 00047 00048 00057 inline std::string RangeTypeName(RangeType rangeType) { 00058 if(rangeType == PropagateRange) return "Propagate"; 00059 if(rangeType == RangeSet) return "Set"; 00060 00061 std::string msg = "Invalid output range type [" + Isis::iString(rangeType) + "]"; 00062 throw Isis::iException::Message(Isis::iException::Parse, msg, _FILEINFO_); 00063 } 00064 00065 00074 inline RangeType RangeTypeEnumeration(const std::string &rangeType) { 00075 Isis::iString temp(rangeType); 00076 temp = temp.UpCase(); 00077 if(temp == "PROPAGATE") return PropagateRange; 00078 if(temp == "SET") return RangeSet; 00079 00080 std::string msg = "Invalid output range type string [" + rangeType + "]"; 00081 throw Isis::iException::Message(Isis::iException::Parse, msg, _FILEINFO_); 00082 } 00083 00084 00093 enum LabelAttachment { 00094 AttachedLabel, 00095 DetachedLabel 00096 }; 00097 00098 00107 inline std::string LabelAttachmentName(LabelAttachment labelType) { 00108 if(labelType == AttachedLabel) return "Attached"; 00109 if(labelType == DetachedLabel) return "Detached"; 00110 00111 std::string msg = "Invalid label attachment type [" + Isis::iString(labelType) + "]"; 00112 throw Isis::iException::Message(Isis::iException::Parse, msg, _FILEINFO_); 00113 } 00114 00115 00124 inline LabelAttachment LabelAttachmentEnumeration(const std::string &labelType) { 00125 Isis::iString temp(labelType); 00126 temp = temp.UpCase(); 00127 if(temp == "ATTACHED") return AttachedLabel; 00128 if(temp == "DETACHED") return DetachedLabel; 00129 00130 std::string msg = "Invalid label attachment type string [" + labelType + "]"; 00131 throw Isis::iException::Message(Isis::iException::Parse, msg, _FILEINFO_); 00132 } 00133 00134 00135 00167 class CubeAttribute { 00168 public: 00169 00171 CubeAttribute(); 00172 00173 00185 CubeAttribute(const Isis::iString &att); 00186 00187 00189 virtual ~CubeAttribute(); 00190 00191 00197 virtual void Write(std::ostream &ostr) const; 00198 00199 00205 virtual void Write(std::string &str) const; 00206 00207 00213 virtual void Write(Isis::Pvl &pvl) const; 00214 00215 protected: 00216 Isis::iString p_attribute; 00217 }; 00218 00219 00243 class CubeAttributeInput : public CubeAttribute { 00244 00245 public: 00246 00248 CubeAttributeInput(); 00249 00250 00260 CubeAttributeInput(const Isis::iString &att); 00261 00262 00264 ~CubeAttributeInput(); 00265 00266 00276 void Set(const std::string &att); 00277 00278 00280 void Reset(); 00281 00282 00284 std::vector<std::string> Bands() const; 00285 00297 std::string BandsStr() const; 00298 00300 void Bands(const std::vector<std::string> &bands); 00301 00303 void Bands(const std::string &bands); 00304 00306 void Write(std::ostream &ostr) const; 00307 00309 void Write(std::string &str) const; 00310 00312 void Write(Isis::Pvl &pvl) const; 00313 00314 private: 00315 std::vector<std::string> p_bands; 00316 00326 void Parse(const std::string &att); 00327 }; 00328 00329 00360 class CubeAttributeOutput : public CubeAttribute { 00361 public: 00362 00364 CubeAttributeOutput(); 00365 00378 CubeAttributeOutput(const Isis::iString &att); 00379 00380 00382 ~CubeAttributeOutput(); 00383 00384 00386 inline bool PropagatePixelType() const { 00387 if(p_pixelTypeDef == "PROPAGATE") { 00388 return true; 00389 } 00390 return false; 00391 }; 00392 00394 inline bool PropagateMinimumMaximum() const { 00395 if(p_rangeType == Isis::PropagateRange) { 00396 return true; 00397 } 00398 return false; 00399 }; 00400 00410 void Set(const std::string &att); 00411 00417 void Reset(); 00418 00420 std::string FileFormatStr() const; 00421 00423 Cube::Format FileFormat() const; 00424 00426 void Format(const Cube::Format &fmt); 00427 00429 std::string ByteOrderStr() const; 00430 00432 Isis::ByteOrder ByteOrder() const; 00433 00435 void Order(const Isis::ByteOrder order); 00436 00438 double Minimum() const; 00439 00441 double Maximum() const; 00442 00444 void Minimum(const double min); 00445 00447 void Maximum(const double max); 00448 00450 Isis::PixelType PixelType() const; 00451 00453 void Label(Isis::LabelAttachment attachment) { 00454 p_labelAttachment = attachment; 00455 }; 00456 00458 bool AttachedLabel() const { 00459 return p_labelAttachment == Isis::AttachedLabel; 00460 }; 00461 00463 bool DetachedLabel() const { 00464 return p_labelAttachment == Isis::DetachedLabel; 00465 }; 00466 00468 void PixelType(const Isis::PixelType type); 00469 00471 void Write(std::ostream &ostr) const; 00472 00474 void Write(std::string &str) const; 00475 00477 void Write(Isis::Pvl &pvl) const; 00478 00479 00480 private: 00481 Isis::PixelType p_pixelType; 00482 00487 std::string p_pixelTypeDef; 00493 Isis::RangeType p_rangeType; 00494 00495 double p_minimum; 00496 double p_maximum; 00497 Cube::Format p_format; 00498 Isis::ByteOrder p_order; 00499 Isis::LabelAttachment p_labelAttachment; 00500 00507 void Parse(const std::string &att); 00508 00510 void Initialize(); 00511 00512 }; 00513 }; 00514 00515 #endif