Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Bound.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file utility/Bound.hh
11 /// @brief Bound value class
12 /// @author Stuart G. Mentzer (Stuart_Mentzer@objexx.com)
13 
14 
15 #ifndef INCLUDED_utility_Bound_hh
16 #define INCLUDED_utility_Bound_hh
17 
18 
19 // Unit headers
20 #include <utility/Bound.fwd.hh>
21 
22 // C++ headers
23 #include <utility/assert.hh>
24 
25 
26 namespace utility {
27 
28 
29 /// @brief Bound value class
30 template< typename T >
31 class Bound
32 {
33 
34 
35 public: // Types
36 
37 
38  // Project style
39  typedef T Value;
40 
41  // STL/Boost style
42  typedef T value_type;
43 
44 
45 public: // Creation
46 
47 
48  /// @brief Default constructor
49  inline
50  Bound() :
51  active_( false ),
52  value_( Value() ),
53  strict_( false )
54  {}
55 
56 
57  // Value constructor
58  inline
59  explicit
61  Value const & value_a,
62  bool const strict_a = false
63  ) :
64  active_( true ),
65  value_( value_a ),
66  strict_( strict_a )
67  {}
68 
69 
70  // Strict named constructor
71  inline
72  static
73  Bound
74  Strict( Value const & value_a )
75  {
76  return Bound( value_a, true );
77  }
78 
79 
80  /// @brief Destructor
81  inline
83  {}
84 
85 
86 public: // Methods
87 
88 
89  /// @brief Value assignment
90  inline
91  Bound &
93  Value const & value_a,
94  bool const strict_a = false
95  )
96  {
97  active_ = true;
98  value_ = value_a;
99  strict_ = strict_a;
100  return *this;
101  }
102 
103 
104  /// @brief Value assignment
105  inline
106  Bound &
108  Value const & value_a,
109  bool const strict_a = false
110  )
111  {
112  active_ = true;
113  value_ = value_a;
114  strict_ = strict_a;
115  return *this;
116  }
117 
118 
119  /// @brief Activate
120  inline
121  Bound &
123  {
124  active_ = true;
125  return *this;
126  }
127 
128 
129  /// @brief Deactivate
130  inline
131  Bound &
133  {
134  active_ = false;
135  return *this;
136  }
137 
138 
139  /// @brief Clear
140  inline
141  Bound &
143  {
144  active_ = false;
145  value_ = Value();
146  strict_ = false;
147  return *this;
148  }
149 
150 
151 public: // Properties
152 
153 
154  /// @brief Active bound?
155  inline
156  bool
157  active() const
158  {
159  return active_;
160  }
161 
162 
163  /// @brief Inactive bound?
164  inline
165  bool
166  inactive() const
167  {
168  return ( ! active_ );
169  }
170 
171 
172  /// @brief Bound value
173  inline
174  Value const &
175  operator ()() const
176  {
178  return value_;
179  }
180 
181 
182  /// @brief Bound value
183  inline
184  Value const &
185  value() const
186  {
188  return value_;
189  }
190 
191 
192  /// @brief Strict inequality (< or >) bound?
193  inline
194  bool
195  strict() const
196  {
197  return strict_;
198  }
199 
200 
201 private: // Fields
202 
203 
204  /// @brief Active bound?
205  bool active_;
206 
207  /// @brief Bound value
209 
210  /// @brief Strict inequality (< or >) bound?
211  bool strict_;
212 
213 
214 }; // Bound
215 
216 
217 } // namespace utility
218 
219 
220 #endif // INCLUDED_utility_Bound_HH
static Bound Strict(Value const &value_a)
Definition: Bound.hh:74
#define debug_assert(condition)
Definition: backtrace.hh:140
bool active() const
Active bound?
Definition: Bound.hh:157
Bound & deactivate()
Deactivate.
Definition: Bound.hh:132
Bound value class.
Definition: Bound.fwd.hh:23
Bound()
Default constructor.
Definition: Bound.hh:50
Value const & value() const
Bound value.
Definition: Bound.hh:185
Bound(Value const &value_a, bool const strict_a=false)
Definition: Bound.hh:60
Value const & operator()() const
Bound value.
Definition: Bound.hh:175
Value value_
Bound value.
Definition: Bound.hh:208
Bound & value(Value const &value_a, bool const strict_a=false)
Value assignment.
Definition: Bound.hh:92
bool strict() const
Strict inequality (< or >) bound?
Definition: Bound.hh:195
bool inactive() const
Inactive bound?
Definition: Bound.hh:166
bool strict_
Strict inequality (< or >) bound?
Definition: Bound.hh:211
utility::Bound forward declarations
~Bound()
Destructor.
Definition: Bound.hh:82
Bound & activate()
Activate.
Definition: Bound.hh:122
bool active_
Active bound?
Definition: Bound.hh:205
Bound & clear()
Clear.
Definition: Bound.hh:142