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