- Main Page
- Related Pages
- Classes
- Files

- File List

# 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
    00028 namespace sc {
    00029
    00034 template <class T>
    00035 class Result: public ResultInfo {
    00036   private:
    00037     T _result;
    00038   public:
    00039     Result(Compute*c):ResultInfo(c) {};
    00040     Result(const Result<T> &r, Compute*c):ResultInfo(c)
    00041     { _result=r._result; }
    00042     operator T&() { update(); return _result; };
    00043     T* operator ->() { update(); return &_result; };
    00044     T& result() { update(); return _result; };
    00045     T& result_noupdate() { return _result; };
    00046     const T& result_noupdate() const { return _result; };
    00047     void operator=(const T& a) { _result = a; }
    00048     void operator=(const Result<T> &r)
    00049        { ResultInfo::operator=(r); _result = r._result; };
    00050 };
    00051
    00054 template <class T>
    00055 class NCResult: public ResultInfo {
    00056   private:
    00057     T _result;
    00058   public:
    00059     NCResult(Compute*c):ResultInfo(c) {};
    00060     NCResult(const NCResult<T> &r, Compute*c):ResultInfo(c)
    00061     { _result=r._result; }
    00062     operator T&() { update(); return _result; };
    00063     T& result() { update(); return _result; };
    00064     T& result_noupdate() { return _result; };
    00065     const T& result_noupdate() const { return _result; };
    00066     void operator=(const T& a) { _result = a; }
    00067     void operator=(const NCResult<T> &r)
    00068        { ResultInfo::operator=(r); _result = r._result; };
    00069 };
    00070
    00073 template <class T>
    00074 class AccResult: public AccResultInfo {
    00075   private:
    00076     T _result;
    00077   public:
    00078     AccResult(Compute*c):AccResultInfo(c) {};
    00079     AccResult(const AccResult<T> &r, Compute*c):AccResultInfo(c)
    00080     { _result=r._result; }
    00081     operator T&() { update(); return _result; };
    00082     T* operator ->() { update(); return &_result; };
    00083     T& result() { update(); return _result; };
    00084     T& result_noupdate() { return _result; };
    00085     const T& result_noupdate() const { return _result; };
    00086     void operator=(const T& a) { _result = a; }
    00087     void operator=(const AccResult<T> &r)
    00088        { AccResultInfo::operator=(r); _result = r._result; };
    00089     void restore_state(StateIn&s) {
    00090       AccResultInfo::restore_state(s);
    00091     }
    00092     void save_data_state(StateOut&s)
    00093     {
    00094       AccResultInfo::save_data_state(s);
    00095     }
    00096     AccResult(StateIn&s,Compute*c): AccResultInfo(s,c) {}
    00097 };
    00098
    00101 template <class T>
    00102 class SSAccResult: public AccResultInfo {
    00103   private:
    00104     T _result;
    00105   public:
    00106     SSAccResult(Compute*c):AccResultInfo(c) {};
    00107     SSAccResult(const SSAccResult<T> &r, Compute*c):AccResultInfo(c)
    00108     { _result=r._result; }
    00109     operator T&() { update(); return _result; };
    00110     T* operator ->() { update(); return &_result; };
    00111     T& result() { update(); return _result; };
    00112     T& result_noupdate() { return _result; };
    00113     const T& result_noupdate() const { return _result; };
    00114     void operator=(const T& a) { _result = a; }
    00115     void operator=(const SSAccResult<T> &r)
    00116        { AccResultInfo::operator=(r); _result = r._result; };
    00117     void restore_state(StateIn&s) {
    00118       AccResultInfo::restore_state(s);
    00119       _result.restore_state(s);
    00120     }
    00121     void save_data_state(StateOut&s)
    00122     {
    00123       AccResultInfo::save_data_state(s);
    00124       _result.save_data_state(s);
    00125     }
    00126     SSAccResult(StateIn&s,Compute*c): AccResultInfo(s,c), _result(s) {}
    00127 };
    00128
    00130 template <class T>
    00131 class NCAccResult: public AccResultInfo {
    00132   private:
    00133     T _result;
    00134   public:
    00135     NCAccResult(Compute*c):AccResultInfo(c) {};
    00136     NCAccResult(const NCAccResult<T> &r, Compute*c):AccResultInfo(c)
    00137     { _result=r._result; }
    00138     operator T&() { update(); return _result; };
    00139     T& result() { update(); return _result; };
    00140     T& result_noupdate() { return _result; };
    00141     const T& result_noupdate() const { return _result; };
    00142     void operator=(const T& a) { _result = a; }
    00143     void operator=(const NCAccResult<T> &r)
    00144        { AccResultInfo::operator=(r); _result = r._result; };
    00145     void restore_state(StateIn&s) {
    00146       AccResultInfo::restore_state(s);
    00147       s.get(_result);
    00148     }
    00149     void save_data_state(StateOut&s)
    00150     {
    00151       AccResultInfo::save_data_state(s);
    00152       s.put(_result);
    00153     }
    00154     NCAccResult(StateIn&s,Compute*c): AccResultInfo(s,c) {s.get(_result);}
    00155 };
    00156
    00157 }
    00158
    00159 // ///////////////////////////////////////////////////////////////////////////
    00160
    00161 // Local Variables:
    00162 // mode: c++
    00163 // c-file-style: "CLJ"
    00164 // End: