source: branches/polybatch/src/FillerWrapper.h@ 2656

Last change on this file since 2656 was 1904, checked in by Malte Marquarding, 14 years ago

pass down record for filler options

File size: 1.8 KB
Line 
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>
16#include <casa/Exceptions.h>
17#include <casa/Utilities/CountedPtr.h>
18#include <casa/Containers/Record.h>
19#include <casa/OS/File.h>
20
21#include <string>
22
23#include "ScantableWrapper.h"
24#include "FillerBase.h"
25#include "PKSFiller.h"
26#include "NROFiller.h"
27
28
29namespace asap
30{
31class FillerWrapper
32{
33public:
34
35 explicit FillerWrapper(ScantableWrapper tbl) : filler_(0), attached_(false)
36 { stable_ = tbl.getCP(); }
37
38 virtual ~FillerWrapper() { close(); }
39
40
41 void open(const std::string& filename, const casa::Record& rec) {
42 // void open(const std::string& filename) {
43 casa::File file(filename);
44 if ( !file.exists() ) {
45 throw(AipsError("File does not exist"));
46 }
47 filler_ = new PKSFiller(stable_);
48 if (filler_->open(filename, rec)) {
49 // if (filler_->open(filename)) {
50 attached_ = true;
51 return;
52 }
53 filler_ = new NROFiller(stable_);
54 if (filler_->open(filename, rec)) {
55 // if (filler_->open(filename)) {
56 attached_ = true;
57 return;
58 }
59 filler_ = 0;
60 attached_ = false;
61 throw casa::AipsError("Unknown Data Format");
62 }
63 void close() {
64 if (attached_) {
65 filler_->close();
66 }
67 }
68
69 void fill() {
70 if (attached_) {
71 filler_->fill();
72 }
73 }
74
75 void setReferenceRegex(const std::string& rx) {
76 if (attached_) {
77 filler_->setReferenceRegex(rx);
78 }
79 }
80
81private:
82
83 FillerWrapper();
84 FillerWrapper(const FillerWrapper&);
85 FillerWrapper& operator=(const FillerWrapper&);
86
87 casa::CountedPtr<FillerBase> filler_;
88 bool attached_;
89 casa::CountedPtr<Scantable> stable_;
90};
91
92};
93#endif
Note: See TracBrowser for help on using the repository browser.