MPQC 2.3.1
comptmpl.h
1//
2// comptmpl.h
3//
4// Copyright (C) 1996 Limit Point Systems, Inc.
5//
6// Author: Curtis Janssen <cljanss@limitpt.com>
7// Maintainer: LPS
8//
9// This file is part of the SC Toolkit.
10//
11// The SC Toolkit is free software; you can redistribute it and/or modify
12// it under the terms of the GNU Library General Public License as published by
13// the Free Software Foundation; either version 2, or (at your option)
14// any later version.
15//
16// The SC Toolkit is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU Library General Public License for more details.
20//
21// You should have received a copy of the GNU Library General Public License
22// along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24//
25// The U.S. Government is granted a limited license as per AL 91-7.
26//
27
28namespace sc {
29
34template <class T>
35class Result: public ResultInfo {
36 private:
37 T _result;
38 public:
39 Result(Compute*c):ResultInfo(c) {};
40 Result(const Result<T> &r, Compute*c):ResultInfo(c)
41 { _result=r._result; }
42 operator T&() { update(); return _result; };
43 T* operator ->() { update(); return &_result; };
44 T& result() { update(); return _result; };
45 T& result_noupdate() { return _result; };
46 const T& result_noupdate() const { return _result; };
47 void operator=(const T& a) { _result = a; }
48 void operator=(const Result<T> &r)
49 { ResultInfo::operator=(r); _result = r._result; };
50};
51
54template <class T>
55class NCResult: public ResultInfo {
56 private:
57 T _result;
58 public:
59 NCResult(Compute*c):ResultInfo(c) {};
60 NCResult(const NCResult<T> &r, Compute*c):ResultInfo(c)
61 { _result=r._result; }
62 operator T&() { update(); return _result; };
63 T& result() { update(); return _result; };
64 T& result_noupdate() { return _result; };
65 const T& result_noupdate() const { return _result; };
66 void operator=(const T& a) { _result = a; }
67 void operator=(const NCResult<T> &r)
68 { ResultInfo::operator=(r); _result = r._result; };
69};
70
73template <class T>
74class AccResult: public AccResultInfo {
75 private:
76 T _result;
77 public:
78 AccResult(Compute*c):AccResultInfo(c) {};
79 AccResult(const AccResult<T> &r, Compute*c):AccResultInfo(c)
80 { _result=r._result; }
81 operator T&() { update(); return _result; };
82 T* operator ->() { update(); return &_result; };
83 T& result() { update(); return _result; };
84 T& result_noupdate() { return _result; };
85 const T& result_noupdate() const { return _result; };
86 void operator=(const T& a) { _result = a; }
87 void operator=(const AccResult<T> &r)
88 { AccResultInfo::operator=(r); _result = r._result; };
89 void restore_state(StateIn&s) {
90 AccResultInfo::restore_state(s);
91 }
92 void save_data_state(StateOut&s)
93 {
94 AccResultInfo::save_data_state(s);
95 }
96 AccResult(StateIn&s,Compute*c): AccResultInfo(s,c) {}
97};
98
101template <class T>
102class SSAccResult: public AccResultInfo {
103 private:
104 T _result;
105 public:
106 SSAccResult(Compute*c):AccResultInfo(c) {};
107 SSAccResult(const SSAccResult<T> &r, Compute*c):AccResultInfo(c)
108 { _result=r._result; }
109 operator T&() { update(); return _result; };
110 T* operator ->() { update(); return &_result; };
111 T& result() { update(); return _result; };
112 T& result_noupdate() { return _result; };
113 const T& result_noupdate() const { return _result; };
114 void operator=(const T& a) { _result = a; }
115 void operator=(const SSAccResult<T> &r)
116 { AccResultInfo::operator=(r); _result = r._result; };
117 void restore_state(StateIn&s) {
118 AccResultInfo::restore_state(s);
119 _result.restore_state(s);
120 }
121 void save_data_state(StateOut&s)
122 {
123 AccResultInfo::save_data_state(s);
124 _result.save_data_state(s);
125 }
126 SSAccResult(StateIn&s,Compute*c): AccResultInfo(s,c), _result(s) {}
127};
128
130template <class T>
131class NCAccResult: public AccResultInfo {
132 private:
133 T _result;
134 public:
135 NCAccResult(Compute*c):AccResultInfo(c) {};
136 NCAccResult(const NCAccResult<T> &r, Compute*c):AccResultInfo(c)
137 { _result=r._result; }
138 operator T&() { update(); return _result; };
139 T& result() { update(); return _result; };
140 T& result_noupdate() { return _result; };
141 const T& result_noupdate() const { return _result; };
142 void operator=(const T& a) { _result = a; }
143 void operator=(const NCAccResult<T> &r)
144 { AccResultInfo::operator=(r); _result = r._result; };
145 void restore_state(StateIn&s) {
146 AccResultInfo::restore_state(s);
147 s.get(_result);
148 }
149 void save_data_state(StateOut&s)
150 {
151 AccResultInfo::save_data_state(s);
152 s.put(_result);
153 }
154 NCAccResult(StateIn&s,Compute*c): AccResultInfo(s,c) {s.get(_result);}
155};
156
157}
158
159// ///////////////////////////////////////////////////////////////////////////
160
161// Local Variables:
162// mode: c++
163// c-file-style: "CLJ"
164// End:
The Compute class provides a means of keeping results up to date.
Definition compute.h:56
Restores objects that derive from SavableState.
Definition statein.h:70
virtual int get(const ClassDesc **)
This restores ClassDesc's.
Serializes objects that derive from SavableState.
Definition stateout.h:61
virtual int put(const ClassDesc *)
Write out information about the given ClassDesc.

Generated at Mon Jan 20 2025 00:00:00 for MPQC 2.3.1 using the documentation package Doxygen 1.13.2.