[1778] | 1 | // |
---|
| 2 | // C++ Interface: Filler |
---|
| 3 | // |
---|
| 4 | // Description: |
---|
| 5 | // |
---|
| 6 | // |
---|
| 7 | // Author: Malte Marquarding <asap@atnf.csiro.au>, (C) 2010 |
---|
| 8 | // |
---|
| 9 | // Copyright: See COPYING file that comes with this distribution |
---|
| 10 | // |
---|
| 11 | // |
---|
| 12 | #ifndef ASAPFILLER_H |
---|
| 13 | #define ASAPFILLER_H |
---|
| 14 | |
---|
| 15 | #include <casa/aips.h> |
---|
[1786] | 16 | #include <casa/Exceptions.h> |
---|
[1778] | 17 | #include <casa/Utilities/CountedPtr.h> |
---|
[1904] | 18 | #include <casa/Containers/Record.h> |
---|
[1813] | 19 | #include <casa/OS/File.h> |
---|
| 20 | |
---|
[1778] | 21 | #include <string> |
---|
| 22 | |
---|
[1786] | 23 | #include "ScantableWrapper.h" |
---|
| 24 | #include "FillerBase.h" |
---|
| 25 | #include "PKSFiller.h" |
---|
| 26 | #include "NROFiller.h" |
---|
| 27 | |
---|
[1794] | 28 | |
---|
[1778] | 29 | namespace asap |
---|
| 30 | { |
---|
[1786] | 31 | class FillerWrapper |
---|
[1778] | 32 | { |
---|
| 33 | public: |
---|
| 34 | |
---|
[1787] | 35 | explicit FillerWrapper(ScantableWrapper tbl) : filler_(0), attached_(false) |
---|
[1786] | 36 | { stable_ = tbl.getCP(); } |
---|
| 37 | |
---|
| 38 | virtual ~FillerWrapper() { close(); } |
---|
| 39 | |
---|
| 40 | |
---|
[1904] | 41 | void open(const std::string& filename, const casa::Record& rec) { |
---|
| 42 | // void open(const std::string& filename) { |
---|
[1813] | 43 | casa::File file(filename); |
---|
| 44 | if ( !file.exists() ) { |
---|
| 45 | throw(AipsError("File does not exist")); |
---|
| 46 | } |
---|
[1806] | 47 | filler_ = new PKSFiller(stable_); |
---|
[1904] | 48 | if (filler_->open(filename, rec)) { |
---|
| 49 | // if (filler_->open(filename)) { |
---|
[1786] | 50 | attached_ = true; |
---|
[1778] | 51 | return; |
---|
| 52 | } |
---|
[1792] | 53 | filler_ = new NROFiller(stable_); |
---|
[1904] | 54 | if (filler_->open(filename, rec)) { |
---|
| 55 | // if (filler_->open(filename)) { |
---|
[1786] | 56 | attached_ = true; |
---|
[1778] | 57 | return; |
---|
| 58 | } |
---|
[1786] | 59 | filler_ = 0; |
---|
| 60 | attached_ = false; |
---|
| 61 | throw casa::AipsError("Unknown Data Format"); |
---|
[1778] | 62 | } |
---|
| 63 | void close() { |
---|
[1786] | 64 | if (attached_) { |
---|
| 65 | filler_->close(); |
---|
[1778] | 66 | } |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | void fill() { |
---|
[1786] | 70 | if (attached_) { |
---|
| 71 | filler_->fill(); |
---|
[1778] | 72 | } |
---|
| 73 | } |
---|
[1786] | 74 | |
---|
| 75 | void setReferenceRegex(const std::string& rx) { |
---|
| 76 | if (attached_) { |
---|
| 77 | filler_->setReferenceRegex(rx); |
---|
[1778] | 78 | } |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | private: |
---|
[1786] | 82 | |
---|
[1811] | 83 | FillerWrapper(); |
---|
| 84 | FillerWrapper(const FillerWrapper&); |
---|
| 85 | FillerWrapper& operator=(const FillerWrapper&); |
---|
[1787] | 86 | |
---|
[1786] | 87 | casa::CountedPtr<FillerBase> filler_; |
---|
| 88 | bool attached_; |
---|
| 89 | casa::CountedPtr<Scantable> stable_; |
---|
[1778] | 90 | }; |
---|
| 91 | |
---|
| 92 | }; |
---|
[1786] | 93 | #endif |
---|