Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

comptmpl.h

00001 //
00002 // comptmpl.h
00003 //
00004 // Copyright (C) 1996 Limit Point Systems, Inc.
00005 //
00006 // Author: Curtis Janssen <cljanss@limitpt.com>
00007 // Maintainer: LPS
00008 //
00009 // This file is part of the SC Toolkit.
00010 //
00011 // The SC Toolkit is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Library General Public License as published by
00013 // the Free Software Foundation; either version 2, or (at your option)
00014 // any later version.
00015 //
00016 // The SC Toolkit is distributed in the hope that it will be useful,
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 // GNU Library General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Library General Public License
00022 // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
00024 //
00025 // The U.S. Government is granted a limited license as per AL 91-7.
00026 //
00027 
00032 template <class T>
00033 class Result: public ResultInfo {
00034   private:
00035     T _result;
00036   public:
00037     Result(Compute*c):ResultInfo(c) {};
00038     Result(const Result<T> &r, Compute*c):ResultInfo(c)
00039     { _result=r._result; }
00040     operator T&() { update(); return _result; };
00041     T* operator ->() { update(); return &_result; };
00042     T& result() { update(); return _result; };
00043     T& result_noupdate() { return _result; };
00044     const T& result_noupdate() const { return _result; };
00045     void operator=(const T& a) { _result = a; }
00046     void operator=(const Result<T> &r)
00047        { ResultInfo::operator=(r); _result = r._result; };
00048 };
00049 
00052 template <class T>
00053 class NCResult: public ResultInfo {
00054   private:
00055     T _result;
00056   public:
00057     NCResult(Compute*c):ResultInfo(c) {};
00058     NCResult(const NCResult<T> &r, Compute*c):ResultInfo(c)
00059     { _result=r._result; }
00060     operator T&() { update(); return _result; };
00061     T& result() { update(); return _result; };
00062     T& result_noupdate() { return _result; };
00063     const T& result_noupdate() const { return _result; };
00064     void operator=(const T& a) { _result = a; }
00065     void operator=(const NCResult<T> &r)
00066        { ResultInfo::operator=(r); _result = r._result; };
00067 };
00068 
00071 template <class T>
00072 class AccResult: public AccResultInfo {
00073   private:
00074     T _result;
00075   public:
00076     AccResult(Compute*c):AccResultInfo(c) {};
00077     AccResult(const AccResult<T> &r, Compute*c):AccResultInfo(c)
00078     { _result=r._result; }
00079     operator T&() { update(); return _result; };
00080     T* operator ->() { update(); return &_result; };
00081     T& result() { update(); return _result; };
00082     T& result_noupdate() { return _result; };
00083     const T& result_noupdate() const { return _result; };
00084     void operator=(const T& a) { _result = a; }
00085     void operator=(const AccResult<T> &r)
00086        { AccResultInfo::operator=(r); _result = r._result; };
00087     void restore_state(StateIn&s) {
00088       AccResultInfo::restore_state(s);
00089     }
00090     void save_data_state(StateOut&s)
00091     {
00092       AccResultInfo::save_data_state(s);
00093     }
00094     AccResult(StateIn&s,Compute*c): AccResultInfo(s,c) {}
00095 };
00096 
00099 template <class T>
00100 class SSAccResult: public AccResultInfo {
00101   private:
00102     T _result;
00103   public:
00104     SSAccResult(Compute*c):AccResultInfo(c) {};
00105     SSAccResult(const SSAccResult<T> &r, Compute*c):AccResultInfo(c)
00106     { _result=r._result; }
00107     operator T&() { update(); return _result; };
00108     T* operator ->() { update(); return &_result; };
00109     T& result() { update(); return _result; };
00110     T& result_noupdate() { return _result; };
00111     const T& result_noupdate() const { return _result; };
00112     void operator=(const T& a) { _result = a; }
00113     void operator=(const SSAccResult<T> &r)
00114        { AccResultInfo::operator=(r); _result = r._result; };
00115     void restore_state(StateIn&s) {
00116       AccResultInfo::restore_state(s);
00117       _result.restore_state(s);
00118     }
00119     void save_data_state(StateOut&s)
00120     {
00121       AccResultInfo::save_data_state(s);
00122       _result.save_data_state(s);
00123     }
00124     SSAccResult(StateIn&s,Compute*c): AccResultInfo(s,c), _result(s) {}
00125 };
00126 
00128 template <class T>
00129 class NCAccResult: public AccResultInfo {
00130   private:
00131     T _result;
00132   public:
00133     NCAccResult(Compute*c):AccResultInfo(c) {};
00134     NCAccResult(const NCAccResult<T> &r, Compute*c):AccResultInfo(c)
00135     { _result=r._result; }
00136     operator T&() { update(); return _result; };
00137     T& result() { update(); return _result; };
00138     T& result_noupdate() { return _result; };
00139     const T& result_noupdate() const { return _result; };
00140     void operator=(const T& a) { _result = a; }
00141     void operator=(const NCAccResult<T> &r)
00142        { AccResultInfo::operator=(r); _result = r._result; };
00143     void restore_state(StateIn&s) {
00144       AccResultInfo::restore_state(s);
00145       s.get(_result);
00146     }
00147     void save_data_state(StateOut&s)
00148     {
00149       AccResultInfo::save_data_state(s);
00150       s.put(_result);
00151     }
00152     NCAccResult(StateIn&s,Compute*c): AccResultInfo(s,c) {s.get(_result);}
00153 };
00154 
00155 // ///////////////////////////////////////////////////////////////////////////
00156 
00157 // Local Variables:
00158 // mode: c++
00159 // c-file-style: "CLJ"
00160 // End:

Generated at Thu Oct 4 18:08:42 2001 for MPQC 2.0.0 using the documentation package Doxygen 1.2.5.