| 1 | //
|
|---|
| 2 | // C++ Interface: MSFillerWrapper
|
|---|
| 3 | //
|
|---|
| 4 | // Description:
|
|---|
| 5 | //
|
|---|
| 6 | // This class is wrapper class for MSFiller
|
|---|
| 7 | //
|
|---|
| 8 | // Author: Takeshi Nakazato <takeshi.nakazato@nao.ac.jp>, (C) 2010
|
|---|
| 9 | //
|
|---|
| 10 | // Copyright: See COPYING file that comes with this distribution
|
|---|
| 11 | //
|
|---|
| 12 | //
|
|---|
| 13 | #ifndef ASAPMSFILLER_WRAPPER_H
|
|---|
| 14 | #define ASAPMSFILLER_WRAPPER_H
|
|---|
| 15 |
|
|---|
| 16 | #include <casa/aips.h>
|
|---|
| 17 | #include <casa/Exceptions.h>
|
|---|
| 18 | #include <casa/Utilities/CountedPtr.h>
|
|---|
| 19 | #include <casa/Containers/Record.h>
|
|---|
| 20 | #include <casa/OS/File.h>
|
|---|
| 21 |
|
|---|
| 22 | #include <string>
|
|---|
| 23 |
|
|---|
| 24 | #include "ScantableWrapper.h"
|
|---|
| 25 | #include "MSFiller.h"
|
|---|
| 26 |
|
|---|
| 27 | namespace asap
|
|---|
| 28 | {
|
|---|
| 29 |
|
|---|
| 30 | class MSFillerWrapper
|
|---|
| 31 | {
|
|---|
| 32 | public:
|
|---|
| 33 | explicit MSFillerWrapper( ScantableWrapper tbl )
|
|---|
| 34 | : filler_( 0 ),
|
|---|
| 35 | attached_( false )
|
|---|
| 36 | { stable_ = tbl.getCP() ; }
|
|---|
| 37 |
|
|---|
| 38 | virtual ~MSFillerWrapper() { close() ; }
|
|---|
| 39 |
|
|---|
| 40 | void open(const std::string& filename, const casa::Record& rec)
|
|---|
| 41 | {
|
|---|
| 42 | casa::File file( filename ) ;
|
|---|
| 43 | if ( !file.exists() ) {
|
|---|
| 44 | throw casa::AipsError( "File does not exist" ) ;
|
|---|
| 45 | }
|
|---|
| 46 | filler_ = new MSFiller( stable_ ) ;
|
|---|
| 47 | if ( filler_->open( filename, rec ) ) {
|
|---|
| 48 | attached_ = true ;
|
|---|
| 49 | return ;
|
|---|
| 50 | }
|
|---|
| 51 | else {
|
|---|
| 52 | throw casa::AipsError( "Failed to open file" ) ;
|
|---|
| 53 | }
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | void close()
|
|---|
| 57 | {
|
|---|
| 58 | if ( attached_ ) {
|
|---|
| 59 | filler_->close() ;
|
|---|
| 60 | }
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | void fill()
|
|---|
| 64 | {
|
|---|
| 65 | if ( attached_ ) {
|
|---|
| 66 | filler_->fill() ;
|
|---|
| 67 | }
|
|---|
| 68 | }
|
|---|
| 69 |
|
|---|
| 70 | // add dummy method for consistency
|
|---|
| 71 | void setReferenceRegex(const std::string& rx) {
|
|---|
| 72 | // do nothing
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | private:
|
|---|
| 76 |
|
|---|
| 77 | MSFillerWrapper() ;
|
|---|
| 78 | MSFillerWrapper(const MSFillerWrapper&) ;
|
|---|
| 79 | MSFillerWrapper& operator=(const MSFillerWrapper&) ;
|
|---|
| 80 |
|
|---|
| 81 | casa::CountedPtr<MSFiller> filler_ ;
|
|---|
| 82 | bool attached_ ;
|
|---|
| 83 | casa::CountedPtr<Scantable> stable_ ;
|
|---|
| 84 | };
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 | };
|
|---|
| 88 | #endif
|
|---|