00001 //# FunctionMarshallable.h: a class for serializing/reconstituting Function objects to/from Records 00002 //# Copyright (C) 2002 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 //# 00027 //# $Id$ 00028 00029 #ifndef SCIMATH_FUNCTIONMARSHALLABLE_H 00030 #define SCIMATH_FUNCTIONMARSHALLABLE_H 00031 00032 #include <casacore/casa/aips.h> 00033 #include <casacore/scimath/Functionals/Function.h> 00034 #include <casacore/scimath/Functionals/FunctionFactoryErrors.h> 00035 #include <casacore/scimath/Functionals/SerialHelper.h> 00036 00037 namespace casacore { //# NAMESPACE CASACORE - BEGIN 00038 00039 // <summary> 00040 // a class for serializing/reconstituting Function objects to/from Records 00041 // </summary> 00042 00043 // <use visibility=export> 00044 00045 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00046 // </reviewed> 00047 00048 // <prerequisite> 00049 // <li> FunctionFactory 00050 // <li> Function 00051 // </prerequisite> 00052 // 00053 // <etymology> 00054 // Marshalling (a.k.a. serialization) is the process of converting the 00055 // state of an object into a transmitable form so that an another object with 00056 // identical state can be created in another execution context. This class 00057 // defines an interface for marshalling Functions. 00058 // </etymology> 00059 // 00060 // <synopsis> 00061 // 00062 // 00063 // 00064 // 00065 // </synopsis> 00066 // 00067 // <example> 00068 // 00069 // 00070 // 00071 // </example> 00072 // 00073 // <motivation> 00074 // 00075 // 00076 // 00077 // </motivation> 00078 // 00079 // <thrown> 00080 // </thrown> 00081 // 00082 // <todo asof="yyyy/mm/dd"> 00083 // </todo> 00084 00085 class FunctionMarshallable { 00086 public: 00087 00088 // create a FunctionMarshallable. <em>functype</em> is the name that 00089 // store() will load into the Record's <tt>functype</tt> field. 00090 FunctionMarshallable(const String& functype) : ftype(functype) {} 00091 FunctionMarshallable(const FunctionMarshallable& other) : ftype() { 00092 ftype = other.ftype; 00093 } 00094 virtual ~FunctionMarshallable() {} 00095 00096 // store the state of this Function into a Record 00097 // <thrown> 00098 // <li> InvalidSerializationError if an error during serialization 00099 // </thrown> 00100 virtual void store(Record& gr) const = 0; 00101 00102 virtual FunctionMarshallable& 00103 operator=(const FunctionMarshallable& other) 00104 { 00105 ftype = other.ftype; 00106 return *this; 00107 } 00108 00109 // return the name representing the Function type that will be placed 00110 // in the <tt>functype</tt> field of Record passed to store(). 00111 const String& getFuncType() const { return ftype; } 00112 00113 // load functype field into the given Record 00114 void loadFuncType(Record& gr) const { 00115 gr.define(SerialHelper::FUNCTYPE.c_str(), ftype.c_str()); 00116 } 00117 00118 private: 00119 FunctionMarshallable() : ftype() {} 00120 00121 String ftype; 00122 }; 00123 00124 00125 } //# NAMESPACE CASACORE - END 00126 00127 #endif 00128 00129