ExtHDU.h

00001 //   Read the documentation to learn more about C++ code generator
00002 //   versioning.
00003 //      This is version 1.8 release dated Oct 2007
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, L3-Communications EER Systems Inc.
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 
00392   class ExtHDU : public HDU  //## Inherits: <unnamed>%38048213E7A8
00393   {
00394 
00395     public:
00396 
00397 
00398 
00399       class WrongExtensionType : public FitsException  //## Inherits: <unnamed>%39E61E630349
00400       {
00401         public:
00402             WrongExtensionType (const String& msg, bool silent = true);
00403 
00404         protected:
00405         private:
00406         private: //## implementation
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         //      By all means necessary, set the fitsfile pointer so that
00423         //      this HDU is the current HDU.
00424         //
00425         //      This would appear to be a good candidate for the public
00426         //      interface.
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       // Additional Public Declarations
00440 
00441       // interface is virtually identical to PHDU. The implementation is
00442       // similar apart from a check for wrong extension type.
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       // read image data & return the array. Can't return a reference because type
00477       // conversion in general requires allocating a new object.
00478       // note semantics of reading column data are easily distinguished: they require
00479       // the user to perform the operation EXT.column({name,index}).read(...)
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         //      ExtHDU needs a default constructor. This is it.
00521         ExtHDU (FITSBase* p, HduType xtype, const String &hduName, int version);
00522         //      The writing constructor. Forces the user to supply a name
00523         //      for the HDU
00524         ExtHDU (FITSBase* p, HduType xtype, const String &hduName, int bitpix, int naxis, const std::vector<long>& axes, int version);
00525         //      ExtHDU constructor for getting ExtHDUs by number.
00526         //      Necessary since EXTNAME is a reserved not required
00527         //      keyword.
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       // Additional Protected Declarations
00542 
00543     private:
00544         virtual void initRead () = 0;
00545         void checkXtension ();
00546 
00547       // Additional Private Declarations
00548 
00549     private: //## implementation
00550       // Data Members for Class Attributes
00551         long m_pcount;
00552         long m_gcount;
00553         int m_version;
00554         HduType m_xtension;
00555         static String s_missHDU;
00556 
00557       // Data Members for Associations
00558         String m_name;
00559 
00560       // Additional Implementation Declarations
00561 
00562   };
00563 
00564   // Class CCfits::ExtHDU::WrongExtensionType 
00565 
00566   // Class CCfits::ExtHDU 
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 } // namespace CCfits
00656 
00657 
00658 #endif

Generated on Fri Oct 12 13:39:38 2007 for CCfits by  doxygen 1.4.7