Line data Source code
1 : //# AsciiRegionLine.cc 2 : //# Copyright (C) 1998,1999,2000,2001 3 : //# Associated Universities, Inc. Washington DC, USA. 4 : //# 5 : //# This library is free software; you can redistribute it and/or modify it 6 : //# under the terms of the GNU Library General Public License as published by 7 : //# the Free Software Foundation; either version 2 of the License, or (at your 8 : //# option) any later version. 9 : //# 10 : //# This library is distributed in the hope that it will be useful, but WITHOUT 11 : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 : //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 13 : //# License for more details. 14 : //# 15 : //# You should have received a copy of the GNU Library General Public License 16 : //# along with this library; if not, write to the Free Software Foundation, 17 : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 18 : //# 19 : //# Correspondence concerning AIPS++ should be addressed as follows: 20 : //# Internet email: casa-feedback@nrao.edu. 21 : //# Postal address: AIPS++ Project Office 22 : //# National Radio Astronomy Observatory 23 : //# 520 Edgemont Road 24 : //# Charlottesville, VA 22903-2475 USA 25 : //# 26 : 27 : #include <imageanalysis/IO/AsciiAnnotationFileLine.h> 28 : 29 : using namespace casacore; 30 : namespace casa { 31 : 32 0 : AsciiAnnotationFileLine::AsciiAnnotationFileLine() 33 0 : : _type(UNKNOWN_TYPE), 34 0 : _comment(""), _annotationBase(0), 35 0 : _globals() {} 36 : 37 : 38 0 : AsciiAnnotationFileLine::AsciiAnnotationFileLine( 39 : const String& comment 40 0 : ) : _type(COMMENT), 41 0 : _comment(comment), 42 0 : _annotationBase(0), 43 0 : _globals() { 44 0 : String b = _comment; 45 0 : b.trim(); 46 0 : if (! b.empty() && ! b.startsWith("#")) { 47 0 : _comment = "#" + comment; 48 : } 49 0 : } 50 : 51 0 : AsciiAnnotationFileLine::AsciiAnnotationFileLine( 52 : CountedPtr<const AnnotationBase> annotationBase 53 0 : ) : _type(ANNOTATION), _comment(""), 54 0 : _annotationBase(annotationBase), 55 0 : _globals() {} 56 : 57 0 : AsciiAnnotationFileLine::AsciiAnnotationFileLine( 58 : const std::map<AnnotationBase::Keyword, String>& globals 59 0 : ) : _type(GLOBAL), _comment(""), 60 0 : _annotationBase(0), 61 0 : _globals(globals) {} 62 : 63 : 64 0 : AsciiAnnotationFileLine& AsciiAnnotationFileLine::operator= ( 65 : const AsciiAnnotationFileLine& other 66 : ) { 67 0 : if (this != &other) { 68 0 : _type = other._type; 69 0 : _comment = other._comment; 70 0 : _annotationBase = other._annotationBase; 71 0 : _globals = other._globals; 72 : } 73 0 : return *this; 74 : } 75 : 76 0 : String AsciiAnnotationFileLine::getComment() const { 77 0 : return _comment; 78 : } 79 : 80 0 : std::map<AnnotationBase::Keyword, String> AsciiAnnotationFileLine::getGloabalParams() const { 81 0 : return _globals; 82 : } 83 : 84 0 : CountedPtr<const AnnotationBase> AsciiAnnotationFileLine::getAnnotationBase() const { 85 0 : return _annotationBase; 86 : } 87 : 88 0 : AsciiAnnotationFileLine::Type AsciiAnnotationFileLine::getType() const { 89 0 : return _type; 90 : } 91 : 92 0 : ostream& AsciiAnnotationFileLine::print(ostream& os) const { 93 0 : switch(_type) { 94 0 : case COMMENT: 95 0 : os << _comment; 96 0 : return os; 97 0 : case ANNOTATION: 98 0 : os << *_annotationBase; 99 0 : return os; 100 0 : case GLOBAL: 101 0 : os << "global " << _globals; 102 0 : return os; 103 0 : default: 104 0 : return os; 105 : } 106 : 107 : } 108 : 109 : } 110 : 111 :