source: branches/alma/src/FillerWrapper.h@ 2670

Last change on this file since 2670 was 1818, checked in by Kana Sugimoto, 14 years ago

New Development: Yes

JIRA Issue: No (merge)

Ready for Test: Yes

Interface Changes: No

Description:

Merged changes -r1774:1817 in newfiller branch to alma branch


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