XMLFileReaderWriter.h

Go to the documentation of this file.
00001 //# XMLFileReaderWriter.h: Implementation for reading/writing XML files.
00002 //# Copyright (C) 2008
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id$
00027 #ifndef XMLFILEREADERWRITIER_H_
00028 #define XMLFILEREADERWRITIER_H_
00029 
00030 #include <QtXml>
00031 
00032 #include <display/RegionShapes/RSFileReaderWriter.h>
00033 
00034 #include <casa/namespace.h>
00035 
00036 namespace casa {
00037 
00038 // Constants and methods for reading/writing RS XML files.
00039         class RSXML {
00040         public:
00041                 // Converts a Record to/from a QDomElement.
00042                 // <group>
00043                 static QDomElement recordToXML(const RecordInterface& record,
00044                                                String elementName = "casa-record");
00045                 static Record XMLToRecord(const QDomElement& element);
00046                 // </group>
00047 
00048         private:
00049                 // Document used for creating nodes.
00050                 static QDomDocument DOCUMENT;
00051 
00052                 // Constants.
00053                 // <group>
00054                 static const QString ARRAY;
00055                 static const QString FIELD;
00056                 static const QString NAME;
00057                 static const QString SHAPE;
00058                 static const QString TYPE;
00059                 static const QString VAL;
00060                 // </group>
00061 
00062                 // Converts an IPosition to/from a QString.
00063                 // <group>
00064                 static QString shapeToString(const IPosition& shape);
00065                 static IPosition stringToShape(const QString& shape);
00066                 // </group>
00067         };
00068 
00069 
00070 // Implementation of RegionFileReader/RegionFileWriter for reading/writing
00071 // CASA-XML files.
00072         class XMLFileReaderWriter : public RSFileReader, public RSFileWriter {
00073         public:
00074                 // Static Members //
00075 
00076                 // Returns the shapes represented by the given QDomElement.  The top-level
00077                 // element MUST have tag name SHAPE_OPTIONS, and will have zero or more
00078                 // children elements, each representing a RegionShape, with tag name
00079                 // SHAPE.
00080                 static vector<RegionShape*> DOMToShapes(QDomElement& element);
00081 
00082                 // Returns a QDomElement that represents the given shapes.  The top-level
00083                 // element will have tag name SHAPE_OPTIONS, and will have zero or more
00084                 // children elements, each representing a RegionShape, with tag name SHAPE.
00085                 // The given document is used to create the element, but the element is NOT
00086                 // added to the document.
00087                 static QDomElement shapesToDOM(QDomDocument& document,
00088                                                const vector<RegionShape*>& shapes);
00089 
00090                 // XML file constants.
00091                 // <group>
00092                 static const QString DOCROOT_NAME;
00093                 static const pair<QString, QString> VERSION;
00094                 static const QString SHAPE_OPTIONS;
00095                 static const QString SHAPE;
00096                 // </group>
00097 
00098 
00099                 // Non-Static Members //
00100 
00101                 // Constructor.
00102                 XMLFileReaderWriter();
00103 
00104                 // Destructor.
00105                 ~XMLFileReaderWriter();
00106 
00107                 // RSFileReader methods //
00108 
00109                 // Implements RSFileReader::read.
00110                 bool read(vector<RegionShape*>& shapes);
00111 
00112                 // RSFileWriter methods //
00113 
00114                 // Implements RSFileWriter::optionsWidget.
00115                 QWidget* optionsWidget() const;
00116 
00117                 // Implements RSFileWriter::setOptions.
00118                 void setOptions(const QWidget* widget);
00119 
00120                 // Implements RSFileWriter::write.
00121                 bool write(const vector<RegionShape*>& shapes) const;
00122         };
00123 
00124 }
00125 
00126 #endif /* XMLFILEREADERWRITIER_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1