00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef EXTHDU_H
00011 #define EXTHDU_H 1
00012
00013
00014 #include "HDU.h"
00015
00016 #include "CCfits.h"
00017
00018 #include "FitsError.h"
00019
00020 namespace CCfits {
00021 class Column;
00022
00023 }
00024
00025
00026 namespace CCfits {
00027
00390 class ExtHDU : public HDU
00391 {
00392
00393 public:
00394
00395
00396
00397 class WrongExtensionType : public FitsException
00398 {
00399 public:
00400 WrongExtensionType (const String& msg, bool silent = true);
00401
00402 protected:
00403 private:
00404 private:
00405 };
00406 ExtHDU(const ExtHDU &right);
00407 virtual ~ExtHDU();
00408 friend bool operator<(const ExtHDU &left,const ExtHDU &right);
00409
00410 friend bool operator>(const ExtHDU &left,const ExtHDU &right);
00411
00412 friend bool operator<=(const ExtHDU &left,const ExtHDU &right);
00413
00414 friend bool operator>=(const ExtHDU &left,const ExtHDU &right);
00415
00416 static void readHduName (const fitsfile* fptr, int hduIndex, String& hduName, int& hduVersion);
00417 virtual void readData (bool readFlag = false, const std::vector<String>& keys = std::vector<String>()) = 0;
00418 const String& name () const;
00419 virtual HDU * clone (FITSBase* p) const = 0;
00420
00421
00422
00423
00424
00425 virtual void makeThisCurrent () const;
00426 virtual Column& column (const String& colName) const;
00427 virtual Column& column (int colIndex) const;
00428 virtual long rows () const;
00429 virtual void addColumn (ValueType type, const String& columnName, long repeatWidth, const String& colUnit = String(""), long decimals = -1, size_t columnNumber = 0);
00430 virtual void deleteColumn (const String& columnName);
00431 int version () const;
00432 void version (int value);
00433 static const String& missHDU ();
00434 static void setMissHDU (const String& value);
00435
00436 public:
00437
00438
00439
00440
00441
00442
00443
00444
00445 template <typename S>
00446 void write(const std::vector<long>& first,
00447 long nElements,
00448 const std::valarray<S>& data,
00449 S* nullValue);
00450
00451
00452 template <typename S>
00453 void write(long first,
00454 long nElements,
00455 const std::valarray<S>& data,
00456 S* nullValue);
00457
00458 template <typename S>
00459 void write(const std::vector<long>& first,
00460 long nElements,
00461 const std::valarray<S>& data);
00462
00463
00464 template <typename S>
00465 void write(long first,
00466 long nElements,
00467 const std::valarray<S>& data);
00468
00469 template <typename S>
00470 void write(const std::vector<long>& firstVertex,
00471 const std::vector<long>& lastVertex,
00472 const std::valarray<S>& data);
00473
00474
00475
00476
00477
00478
00479 template <typename S>
00480 void read (std::valarray<S>& image) ;
00481
00482 template<typename S>
00483 void read (std::valarray<S>& image,
00484 long first,
00485 long nElements,
00486 S* nullValue) ;
00487
00488 template<typename S>
00489 void read (std::valarray<S>& image,
00490 const std::vector<long>& first,
00491 long nElements,
00492 S* nullValue) ;
00493
00494 template<typename S>
00495 void read (std::valarray<S>& image,
00496 const std::vector<long>& firstVertex,
00497 const std::vector<long>& lastVertex,
00498 const std::vector<long>& stride) ;
00499
00500 template<typename S>
00501 void read (std::valarray<S>& image,
00502 long first,
00503 long nElements) ;
00504
00505 template<typename S>
00506 void read (std::valarray<S>& image,
00507 const std::vector<long>& first,
00508 long nElements) ;
00509
00510 template<typename S>
00511 void read (std::valarray<S>& image,
00512 const std::vector<long>& firstVertex,
00513 const std::vector<long>& lastVertex,
00514 const std::vector<long>& stride,
00515 S* nullValue) ;
00516
00517 protected:
00518
00519 ExtHDU (FITSBase* p, HduType xtype, const String &hduName, int version);
00520
00521
00522 ExtHDU (FITSBase* p, HduType xtype, const String &hduName, int bitpix, int naxis, const std::vector<long>& axes, int version);
00523
00524
00525
00526 ExtHDU (FITSBase* p, HduType xtype, int number);
00527
00528 virtual std::ostream & put (std::ostream &s) const = 0;
00529 virtual void column (const String& colname, Column* value);
00530 virtual void checkExtensionType () const;
00531 int getVersion ();
00532 long pcount () const;
00533 void pcount (long value);
00534 long gcount () const;
00535 void gcount (long value);
00536 HduType xtension () const;
00537 void xtension (HduType value);
00538
00539
00540
00541 private:
00542 virtual void initRead () = 0;
00543 void checkXtension ();
00544
00545
00546
00547 private:
00548
00549 long m_pcount;
00550 long m_gcount;
00551 int m_version;
00552 HduType m_xtension;
00553 static String s_missHDU;
00554
00555
00556 String m_name;
00557
00558
00559
00560 };
00561
00562
00563
00564
00565
00566 inline bool operator<(const ExtHDU &left,const ExtHDU &right)
00567 {
00568 if (left.m_name < right.m_name) return true;
00569 if (left.m_name > right.m_name) return false;
00570 if (left.m_name == right.m_name)
00571 {
00572 if (left.m_version < right.m_version) return true;
00573 }
00574 return false;
00575 }
00576
00577 inline bool operator>(const ExtHDU &left,const ExtHDU &right)
00578 {
00579 return !operator<=(left,right);
00580 }
00581
00582 inline bool operator<=(const ExtHDU &left,const ExtHDU &right)
00583 {
00584 if (left.m_name <= right.m_name)
00585 {
00586 if (left.m_version <= right.m_version) return true;
00587 }
00588 return false;
00589 }
00590
00591 inline bool operator>=(const ExtHDU &left,const ExtHDU &right)
00592 {
00593 return !operator<(left,right);
00594 }
00595
00596
00597 inline const String& ExtHDU::name () const
00598 {
00599
00600 return m_name;
00601 }
00602
00603 inline long ExtHDU::pcount () const
00604 {
00605 return m_pcount;
00606 }
00607
00608 inline void ExtHDU::pcount (long value)
00609 {
00610 m_pcount = value;
00611 }
00612
00613 inline long ExtHDU::gcount () const
00614 {
00615 return m_gcount;
00616 }
00617
00618 inline void ExtHDU::gcount (long value)
00619 {
00620 m_gcount = value;
00621 }
00622
00623 inline int ExtHDU::version () const
00624 {
00625 return m_version;
00626 }
00627
00628 inline void ExtHDU::version (int value)
00629 {
00630 m_version = value;
00631 }
00632
00633 inline HduType ExtHDU::xtension () const
00634 {
00635 return m_xtension;
00636 }
00637
00638 inline void ExtHDU::xtension (HduType value)
00639 {
00640 m_xtension = value;
00641 }
00642
00643 inline const String& ExtHDU::missHDU ()
00644 {
00645 return s_missHDU;
00646 }
00647
00648 inline void ExtHDU::setMissHDU (const String& value)
00649 {
00650 s_missHDU = value;
00651 }
00652
00653 }
00654
00655
00656 #endif