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