source: branches/newfiller/src/FillerWrapper.h@ 2067

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

Check for existing file here

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