IterationPack: General framework for building iterative algorithms  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IterationPack_IterQuantity.hpp
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
5 // Copyright (2003) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 //
42 // Change Log:
43 // 11/18/99:
44 // * last_updated() Added
45 // * set_not_updated(k) Added
46 
47 #ifndef ITER_QUANTITY_H
48 #define ITER_QUANTITY_H
49 
50 #include <stdexcept>
51 #include <string>
52 #include <iomanip>
53 #include <limits>
54 
55 #include "IterationPack_Types.hpp"
56 
57 namespace IterationPack {
58 
68 class IterQuantity {
69 public:
70 
73 
75  enum { NONE_UPDATED = INT_MIN };
76 
78  class NoStorageAvailable : public std::logic_error
79  {public: NoStorageAvailable(const std::string& what_arg) : std::logic_error(what_arg) {}};
80 
82  class QuanityNotSet : public std::logic_error
83  {public: QuanityNotSet(const std::string& what_arg) : std::logic_error(what_arg) {}};
84 
86 
89 
90  // Virtual destructor
91  virtual ~IterQuantity() {}
92 
93  // Clone this iteration quantity
94  virtual IterQuantity* clone() const = 0;
95 
97 
100 
102  virtual const char* name() const = 0;
103 
110  virtual bool has_storage_k(int offset) const = 0;
111 
120  virtual bool updated_k(int offset) const = 0;
121 
127  virtual int last_updated() const = 0;
128 
180  virtual bool will_loose_mem(int offset, int set_offset) const = 0;
181 
183 
186 
197  virtual void set_not_updated_k(int offset) = 0;
198 
201  virtual void set_all_not_updated() = 0;
202 
204 
207 
216  virtual void next_iteration() = 0;
217 
219 
222 
231  virtual void print_concrete_type( std::ostream& out ) const = 0;
232 
234 
237 
239  void assert_has_storage_k(int offset) const;
240 
242  void assert_updated_k(int offset) const;
243 
245 
246 }; // end class IterQuantity
247 
248 } // end namespace IterationPack
249 
250 #endif // ITER_QUANTITY_H
virtual void set_all_not_updated()=0
Causes updated_k(k) to return false for all k.
void assert_updated_k(int offset) const
Assert updated_k(offset) == true (throw QuanityNotSet).
virtual void print_concrete_type(std::ostream &out) const =0
Print to an output stream a description of this iteration quantity.
virtual const char * name() const =0
Return the name (zero terminated string) of this quantity.
void assert_has_storage_k(int offset) const
Assert has_storage_k(offset) == true (throw NoStorageAvailable).
Thrown when memory access is attempted when it has not yet been updated.
virtual bool has_storage_k(int offset) const =0
Determine if there is storage advailable for the k offset iteration quanity.
Thrown memory if attempted to be set that storage can not be allocated to.
virtual void next_iteration()=0
Shift the reference point from the k to the k+1 iteration.
virtual void set_not_updated_k(int offset)=0
Causes updated_k(k) to return false.
virtual bool updated_k(int offset) const =0
Determine if the quanity for the k offset iteration has been accessed by a call to set_k() (see IterQ...
Iterface for information about Iteration Quantities.
virtual bool will_loose_mem(int offset, int set_offset) const =0
Determine if the memory for the k + offset quantityy will be lost if set_k(set_offset) is called (see...
virtual int last_updated() const =0
Return the highest k such that updated_k(k) returns true.