Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

PyFitsController.cxx

Go to the documentation of this file.
00001 
00012 #ifdef _MSC_VER
00013 // nonstandard extension used 'extern' before...
00014 # pragma warning(disable:4231)  
00015 
00016 // needs to have dll-interface used by client
00017 # pragma warning(disable:4251)  
00018 
00019 // non dll-interface struct
00020 # pragma warning(disable:4275)  
00021 
00022 // 'int' : forcing value to bool 'true' or 'false' (performance warning)
00023 # pragma warning(disable:4800)  
00024 #endif
00025 
00026 #include "PyFitsController.h"
00027 
00028 #include "PyDataSource.h"
00029 
00030 #include "fits/FitsController.h"
00031 #include "fits/FitsNTuple.h"
00032 
00033 #include "datasrcs/DataSourceException.h"
00034 
00035 #include <boost/python.hpp>
00036 
00037 using std::vector;
00038 using namespace boost::python;
00039 
00040 namespace hippodraw {
00041 namespace Python {
00042 
00043 void 
00044 export_FitsController()
00045 {
00046   class_ < PyFitsController, bases<>,
00047     PyFitsController, boost::noncopyable >
00048     ( "FitsController",
00049       "A class for creation of DataSource objects from a FITS file.",
00050       no_init )
00051 
00052     .def ( "instance",  &PyFitsController::instance,
00053            return_value_policy < reference_existing_object >  (),
00054            "instance () -> FitsController\n"
00055            "\n"
00056            "Returns the single instance of the controller." )
00057 
00058     .staticmethod( "instance" )
00059 
00060     .def ( "getNTupleNames",
00061            &PyFitsController::getNTupleNames,
00062            return_value_policy < copy_const_reference > (),
00063            "getNTupleNames ( string ) -> sequence\n"
00064            "\n"
00065            "Returns the names of the HDU data source objects in the file." )
00066 
00067     .def ( "createNTuple",
00068            &PyFitsController::createNTuple,
00069            return_value_policy < reference_existing_object >  (),
00070            "createNTuple ( string, string ) -> FitsNTuple\n"
00071            "\n"
00072            "Creates FitsNTuple from the named file with key name." )
00073 
00074     .def ( "createDataArray",
00075            &PyFitsController::createDataArray,
00076            return_value_policy < reference_existing_object >  (),
00077            "createDataArray ( string, string ) -> DataArray\n"
00078            "\n"
00079            "Creates DataArray from a file with key name" )
00080     ;
00081 
00082 }
00083 
00084 } // namespace Python
00085 } // namespace hippodraw
00086 
00087 FitsController   * PyFitsController::m_instance = 0;
00088 PyFitsController * PyFitsController::s_instance = 0;
00089 
00090 
00091 PyFitsController::
00092 PyFitsController()
00093 {
00094 }
00095 
00096 PyFitsController *
00097 PyFitsController::
00098 instance ()
00099 {
00100   if ( s_instance == 0 ) {
00101     s_instance = new PyFitsController ();
00102     m_instance = FitsController::instance ();
00103   }
00104 
00105   return s_instance;
00106 }
00107 
00108 FitsNTuple *
00109 PyFitsController::
00110 createNTuple ( const std::string & filename, const std::string & hduname )
00111 {
00112   FitsNTuple * ftuple = 0;
00113 
00114   try {
00115     DataSource * ntuple = m_instance -> createNTuple ( filename, hduname );
00116     ftuple = dynamic_cast < FitsNTuple * > ( ntuple );
00117   }
00118   catch ( const DataSourceException & e ) {
00119     throw e;
00120   }
00121   return ftuple;
00122 }
00123 
00124 PyDataSource *
00125 PyFitsController::
00126 createDataArray ( const std::string & filename, const std::string & hduname )
00127 {
00128   FitsNTuple * tuple = createNTuple ( filename, hduname );
00129   PyDataSource * ds = new PyDataSource ( "FitsNTuple", tuple );
00130 
00131   return ds;
00132 }
00133 
00134 const std::vector < std::string > &
00135 PyFitsController::
00136 getNTupleNames ( const std::string & filename )
00137 {
00138   try {
00139     const std::vector< std::string > & names 
00140       =  m_instance -> getNTupleNames ( filename );
00141     return names;
00142   }
00143   catch ( const DataSourceException & e ) {
00144     throw e;
00145   }
00146   static const std::vector < std::string > names;
00147 
00148   return names;
00149 }

Generated for HippoDraw-1.14.8.5 by doxygen 1.4.3