00001 /********************************************************************** 00002 * * 00003 * Copyright (c) 2002 Lorenzo Moneta, CERN/IT * 00004 * <Lorenzo.Moneta.cern.ch> * 00005 * * 00006 * This library is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Lesser General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2.1 of the License, or (at your option) any later version. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * Lesser General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with this library (see file COPYING); if not, write * 00018 * to the Free Software Foundation, Inc., 59 Temple Place, Suite * 00019 * 330, Boston, MA 02111-1307 USA, or contact the author. * 00020 * * 00021 **********************************************************************/ 00022 00023 // Header file for class DataPointSetTranslator 00024 // 00025 // Created by: moneta at Mon Sep 23 09:54:17 2002 00026 // 00027 // Last update: Mon Sep 23 09:54:17 2002 00028 // 00029 00030 /* 00031 * class containing methods to transfrom a DataPointSet to and from XML 00032 * using DataXML library. 00033 * When translating to XML the class it is constructed using 00034 * AIDA DataPointSet plus name and path and creates a DataXML::DataObject. 00035 * The DataObject is filled with all data point set information when the 00036 * toXML() methos is called, and the data object is returned using the 00037 * dataObject() method. 00038 * Transforming from XML, the class is constructed using a 00039 * DataXML::DataObject in the constructor and method createFromXML 00040 * takes an AIDA::Dev::IDevDataPointSetFactory to create the corresponding 00041 * AIDA DataPointSet 00042 * The helper methods used to transfrom to/from XML are in the base class 00043 * Translator since are used also by the other AIDA objects. 00044 * 00045 */ 00046 00047 00048 #ifndef DATAPOINTSETTRANSLATOR 00049 #define DATAPOINTSETTRANSLATOR 1 00050 00051 #include "Translator.h" 00052 #include <string> 00053 00054 #include "DataXML/DataObject.h" 00055 00056 namespace AIDA { 00057 class IDataPointSet; 00058 namespace Dev { 00059 class IDevDataPointSet; 00060 class IDevDataPointSetFactory; 00061 } 00062 } 00063 00064 namespace Anaphe { 00065 namespace AIDA_XMLStore { 00066 00067 00068 00069 class DataPointSetTranslator : public Translator { 00070 00071 public: 00072 // constructor for writing to XML 00073 DataPointSetTranslator(const AIDA::IDataPointSet * dpSet, const std::string & name, const std::string & path ); 00074 // constructor for reading from XML 00075 DataPointSetTranslator(const DataXML::DataObject * element); 00076 // destructors 00077 virtual ~DataPointSetTranslator(); 00078 00079 private: 00080 // usually copying is non trivial, so we make this unaccessible 00081 DataPointSetTranslator(const DataPointSetTranslator &); 00082 DataPointSetTranslator & operator = (const DataPointSetTranslator &); 00083 00084 public: 00085 00087 bool toXML(); 00089 AIDA::Dev::IDevDataPointSet * createFromXML(AIDA::Dev::IDevDataPointSetFactory& factory); 00090 00092 DataXML::DataObject & dataObject() { return m_element; } 00093 const AIDA::IDataPointSet * histo() { return m_dataset; } 00094 const std::string & name() { return m_name; } 00095 const std::string & path() { return m_path; } 00096 00097 protected: 00098 00099 00100 private: 00101 00102 // private methods 00103 bool setData(); 00104 00106 00108 DataXML::DataObject m_element; 00110 const AIDA::IDataPointSet * m_dataset; 00112 std::string m_name; 00114 std::string m_path; 00115 00116 00117 }; 00118 00119 } // end of namespace Anaphe::AIDA_XMLStore 00120 } 00121 00122 00123 #endif /* DATAPOINTSETTRANSLATOR */