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