ExtHDU.h

00001 //   Read the documentation to learn more about C++ code generator
00002 //   versioning.
00003 //      This is version 2.1 release dated Nov 2008
00004 //      Astrophysics Science Division,
00005 //      NASA/ Goddard Space Flight Center
00006 //      HEASARC
00007 //      http://heasarc.gsfc.nasa.gov
00008 //      e-mail: ccfits@legacy.gsfc.nasa.gov
00009 //
00010 //      Original author: Ben Dorman
00011 
00012 #ifndef EXTHDU_H
00013 #define EXTHDU_H 1
00014 
00015 // HDU
00016 #include "HDU.h"
00017 // CCfitsHeader
00018 #include "CCfits.h"
00019 // FitsError
00020 #include "FitsError.h"
00021 
00022 namespace CCfits {
00023   class Column;
00024 
00025 } // namespace CCfits
00026 
00027 
00028 namespace CCfits {
00029 
00400   class ExtHDU : public HDU  //## Inherits: <unnamed>%38048213E7A8
00401   {
00402 
00403     public:
00404 
00405 
00406 
00407       class WrongExtensionType : public FitsException  //## Inherits: <unnamed>%39E61E630349
00408       {
00409         public:
00410             WrongExtensionType (const String& msg, bool silent = true);
00411 
00412         protected:
00413         private:
00414         private: //## implementation
00415       };
00416         ExtHDU(const ExtHDU &right);
00417         virtual ~ExtHDU();
00418         friend bool operator<(const ExtHDU &left,const ExtHDU &right);
00419 
00420         friend bool operator>(const ExtHDU &left,const ExtHDU &right);
00421 
00422         friend bool operator<=(const ExtHDU &left,const ExtHDU &right);
00423 
00424         friend bool operator>=(const ExtHDU &left,const ExtHDU &right);
00425 
00426         static void readHduName (const fitsfile* fptr, int hduIndex, String& hduName, int& hduVersion);
00427         virtual void readData (bool readFlag = false, const std::vector<String>& keys = std::vector<String>()) = 0;
00428         const String& name () const;
00429         virtual HDU * clone (FITSBase* p) const = 0;
00430         //      By all means necessary, set the fitsfile pointer so that
00431         //      this HDU is the current HDU.
00432         //
00433         //      This would appear to be a good candidate for the public
00434         //      interface.
00435         virtual void makeThisCurrent () const;
00436         virtual Column& column (const String& colName) const;
00437         virtual Column& column (int colIndex) const;
00438         virtual long rows () const;
00439         virtual void addColumn (ValueType type, const String& columnName, long repeatWidth, const String& colUnit = String(""), long decimals = -1, size_t columnNumber = 0);
00440         virtual void deleteColumn (const String& columnName);
00441         virtual long getRowsize () const;
00442         int version () const;
00443         void version (int value);
00444         static const String& missHDU ();
00445         static void setMissHDU (const String& value);
00446 
00447     public:
00448       // Additional Public Declarations
00449 
00450       // interface is virtually identical to PHDU. The implementation is
00451       // similar apart from a check for wrong extension type.
00452 
00453 
00454 
00455 
00456       template <typename S>
00457       void write(const std::vector<long>& first,
00458                     long nElements,
00459                     const std::valarray<S>& data,
00460                     S* nullValue);
00461 
00462 
00463       template <typename S>
00464       void write(long first,
00465                     long nElements,
00466                     const std::valarray<S>& data,
00467                     S* nullValue);                
00468 
00469       template <typename S>
00470       void write(const std::vector<long>& first,
00471                     long nElements,
00472                     const std::valarray<S>& data);
00473 
00474 
00475       template <typename S>
00476       void write(long first,
00477                     long nElements,
00478                     const std::valarray<S>& data);
00479 
00480       template <typename S>
00481       void write(const std::vector<long>& firstVertex,
00482                     const std::vector<long>& lastVertex,
00483                     const std::valarray<S>& data);     
00484 
00485       // read image data & return the array. Can't return a reference because type
00486       // conversion in general requires allocating a new object.
00487       // note semantics of reading column data are easily distinguished: they require
00488       // the user to perform the operation EXT.column({name,index}).read(...)
00489 
00490       template <typename S>
00491       void read (std::valarray<S>& image) ; 
00492 
00493       template<typename S> 
00494       void read (std::valarray<S>& image, 
00495                       long first,
00496                       long nElements, 
00497                       S* nullValue) ; 
00498 
00499       template<typename S>
00500       void read (std::valarray<S>& image, 
00501                       const std::vector<long>& first, 
00502                       long nElements, 
00503                       S* nullValue) ; 
00504 
00505       template<typename S>
00506       void read (std::valarray<S>& image, 
00507                       const std::vector<long>& firstVertex, 
00508                       const std::vector<long>& lastVertex, 
00509                       const std::vector<long>& stride) ; 
00510 
00511       template<typename S>
00512       void read (std::valarray<S>& image, 
00513                       long first,
00514                       long nElements) ; 
00515 
00516       template<typename S>
00517       void read (std::valarray<S>& image, 
00518                       const std::vector<long>& first,
00519                       long nElements) ; 
00520 
00521       template<typename S>
00522       void read (std::valarray<S>& image, 
00523                       const std::vector<long>& firstVertex, 
00524                       const std::vector<long>& lastVertex, 
00525                       const std::vector<long>& stride, 
00526                       S* nullValue) ; 
00527 
00528     protected:
00529         //      ExtHDU needs a default constructor. This is it.
00530         ExtHDU (FITSBase* p, HduType xtype, const String &hduName, int version);
00531         //      The writing constructor. Forces the user to supply a name
00532         //      for the HDU
00533         ExtHDU (FITSBase* p, HduType xtype, const String &hduName, int bitpix, int naxis, const std::vector<long>& axes, int version);
00534         //      ExtHDU constructor for getting ExtHDUs by number.
00535         //      Necessary since EXTNAME is a reserved not required
00536         //      keyword.
00537         ExtHDU (FITSBase* p, HduType xtype, int number);
00538 
00539         virtual std::ostream & put (std::ostream &s) const = 0;
00540         virtual void column (const String& colname, Column* value);
00541         virtual void checkExtensionType () const;
00542         int getVersion ();
00543         long pcount () const;
00544         void pcount (long value);
00545         long gcount () const;
00546         void gcount (long value);
00547         HduType xtension () const;
00548         void xtension (HduType value);
00549 
00550       // Additional Protected Declarations
00551 
00552     private:
00553         virtual void initRead () = 0;
00554         void checkXtension ();
00555 
00556       // Additional Private Declarations
00557 
00558     private: //## implementation
00559       // Data Members for Class Attributes
00560         long m_pcount;
00561         long m_gcount;
00562         int m_version;
00563         HduType m_xtension;
00564         static String s_missHDU;
00565 
00566       // Data Members for Associations
00567         String m_name;
00568 
00569       // Additional Implementation Declarations
00570 
00571   };
00572 
00573   // Class CCfits::ExtHDU::WrongExtensionType 
00574 
00575   // Class CCfits::ExtHDU 
00576 
00577   inline bool operator<(const ExtHDU &left,const ExtHDU &right)
00578   {
00579         if (left.m_name < right.m_name) return true; 
00580         if (left.m_name > right.m_name) return false;
00581         if (left.m_name == right.m_name)
00582         {
00583                 if (left.m_version < right.m_version) return true;
00584         }      
00585         return false;       
00586   }
00587 
00588   inline bool operator>(const ExtHDU &left,const ExtHDU &right)
00589   {
00590      return !operator<=(left,right);
00591   }
00592 
00593   inline bool operator<=(const ExtHDU &left,const ExtHDU &right)
00594   {
00595         if (left.m_name <= right.m_name) 
00596         {
00597                 if (left.m_version <= right.m_version) return true;
00598         }
00599         return false;     
00600   }
00601 
00602   inline bool operator>=(const ExtHDU &left,const ExtHDU &right)
00603   {
00604     return !operator<(left,right);    
00605   }
00606 
00607 
00608   inline const String& ExtHDU::name () const
00609   {
00610 
00611     return m_name;
00612   }
00613 
00614   inline long ExtHDU::pcount () const
00615   {
00616     return m_pcount;
00617   }
00618 
00619   inline void ExtHDU::pcount (long value)
00620   {
00621     m_pcount = value;
00622   }
00623 
00624   inline long ExtHDU::gcount () const
00625   {
00626     return m_gcount;
00627   }
00628 
00629   inline void ExtHDU::gcount (long value)
00630   {
00631     m_gcount = value;
00632   }
00633 
00634   inline int ExtHDU::version () const
00635   {
00636     return m_version;
00637   }
00638 
00639   inline void ExtHDU::version (int value)
00640   {
00641     m_version = value;
00642   }
00643 
00644   inline HduType ExtHDU::xtension () const
00645   {
00646     return m_xtension;
00647   }
00648 
00649   inline void ExtHDU::xtension (HduType value)
00650   {
00651     m_xtension = value;
00652   }
00653 
00654   inline const String& ExtHDU::missHDU ()
00655   {
00656     return s_missHDU;
00657   }
00658 
00659   inline void ExtHDU::setMissHDU (const String& value)
00660   {
00661     s_missHDU = value;
00662   }
00663 
00664 } // namespace CCfits
00665 
00666 
00667 #endif

Generated on Thu Nov 6 10:44:38 2008 for CCfits by  doxygen 1.5.4