SheafSystem  0.0.0.0
section_dof_iterator_2.cc
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
18 // Implementation for class section_dof_iterator
19 
20 #include "SheafSystem/section_dof_iterator.h"
21 
22 #include "SheafSystem/poset_state_handle.h"
23 #include "SheafSystem/section_space_schema_member.h"
24 #include "SheafSystem/section_space_schema_poset.h"
25 #include "SheafSystem/assert_contract.h"
26 #include "SheafSystem/discretization_iterator.h"
27 #include "SheafSystem/postorder_iterator.h"
28 
29 using namespace fiber_bundle; // Workaround for MS C++ bug.
30 
33 operator=(const poset_dof_iterator& xother)
34 {
35 
36  // Preconditions:
37 
38  require(is_ancestor_of(&xother));
39 
40  // Body:
41 
42  (void) poset_dof_iterator::operator=(xother);
43 
44  // Postconditions:
45 
46  ensure(invariant());
47  ensure(is_initialized() == xother.is_initialized());
48  ensure(is_initialized() ? anchor().is_same_state(&xother.anchor()) : true);
49  ensure(is_initialized() ? item().is_same_type(&xother.item()) : true);
50  ensure(unexecutable(this is first member of iteration or is_done()));
51  // Exit
52 
53  return *this;
54 }
55 
58 operator=(const section_dof_iterator& xother)
59 {
60 
61  // Preconditions:
62 
63  require(is_ancestor_of(&xother));
64 
65  // Body:
66 
67  not_implemented();
68 
69  // Postconditions:
70 
71  ensure(invariant());
72 
73  // Exit:
74 
75  return *this;
76 }
77 
78 
81 {
82 
83  // Preconditions:
84 
85  // Body:
86 
87  // nothing to do
88 
89  // Postconditions:
90 
91  // Exit:
92 
93  return;
94 }
95 
96 bool
98 is_ancestor_of(const any* xother) const
99 {
100  bool result;
101 
102  // Preconditions:
103 
104  // Body:
105 
106  result = dynamic_cast<const section_dof_iterator*>(xother) != 0;
107 
108  // Postconditions:
109 
110  // Exit
111 
112  return result;
113 }
114 
115 bool
117 invariant() const
118 {
119  bool result = true;
120 
121  // Preconditions:
122 
123  // Body:
124 
125  invariance( poset_dof_iterator::invariant() );
126 
127  if(invariant_check())
128  {
129  disable_invariant_check();
130 
131  // Finished, turn invariant checking back on.
132 
133  enable_invariant_check();
134  }
135 
136  // Postconditions:
137 
138  // Exit
139 
140  return result;
141 }
142 
143 // ITERATOR FACET
144 
147 anchor()
148 {
149  // Preconditions:
150 
151  require(is_initialized());
152 
153  // Body:
154 
156  reinterpret_cast<section_space_schema_member&>(*_anchor);
157 
158  // Postconditions:
159 
160  // Exit
161 
162  return result;
163 }
164 
167 anchor() const
168 {
169  // Preconditions:
170 
171  require(is_initialized());
172 
173  // Body:
174 
176  reinterpret_cast<section_space_schema_member&>(*_anchor);
177 
178  // Postconditions:
179 
180  // Exit
181 
182  return result;
183 }
184 
185 // MEMBER ITERATOR FACET
186 
189 item()
190 {
191  // Preconditions:
192 
193  require(is_initialized());
194 
195  // Body:
196 
198  reinterpret_cast<section_space_schema_member&>(*_item);
199 
200  // Postconditions:
201 
202  // Exit
203 
204  return result;
205 }
206 
209 item() const
210 {
211  // Preconditions:
212 
213  require(is_initialized());
214 
215  // Body:
216 
218  reinterpret_cast<section_space_schema_member&>(*_item);
219 
220  // Postconditions:
221 
222  // Exit
223 
224  return result;
225 }
226 
227 bool
229 item_is_ancestor_of(const schema_poset_member& xmbr) const
230 {
231  bool result;
232 
233  // Preconditions:
234 
235  // Body:
236 
237  // Always true in this class;
238  // intended to be redefined in descendants.
239 
240  result = dynamic_cast<const section_space_schema_member*>(&xmbr) != 0;
241 
242  // Postconditions:
243 
244  // Exit
245 
246  return result;
247 }
248 
249 // PROTECTED MEMBER FUNCTIONS
250 
254 {
255  // Preconditions:
256 
257  // Body:
258 
259  // Postconditions:
260 
261  ensure(invariant());
262  ensure(!is_initialized());
263 
264  // Exit
265 
266  return;
267 }
268 
271  : poset_dof_iterator(xother)
272 {
273  // Preconditions:
274 
275  // Body:
276 
277  // Postconditions:
278 
279  ensure(invariant());
280  ensure(is_initialized() == xother.is_initialized());
281  ensure(is_initialized() ? anchor().is_same_state(&xother.anchor()) : true);
282  ensure(is_initialized() ? anchor().version() == xother.anchor().version() : true);
283  ensure(is_initialized() ? item().is_same_type(&xother.item()) : true);
284  ensure(is_table_dof() == xother.is_table_dof());
285 
286  // Exit:
287 
288  return;
289 }
290 
293  bool xis_table_dof,
294  int xversion)
295  : poset_dof_iterator(xanchor, xis_table_dof, xversion)
296 {
297 
298  // Preconditions:
299 
300  require(item_is_ancestor_of(xanchor));
301  require(xanchor.state_is_read_accessible());
302  require(xanchor.host()->is_schematized(false));
303  require(xanchor.has_version(xversion));
304 
305  // Body:
306 
307  // Postconditions:
308 
309  ensure(invariant());
310  ensure(is_initialized());
311  ensure(anchor().is_same_state(&xanchor));
312  ensure(anchor().is_same_type(&xanchor));
313  ensure(anchor().version() == xanchor.unaliased_version(xversion));
314  ensure(unexecutable(!is_done() implies this is first member));
315  ensure(item().is_attached() == !is_done());
316 
317  return;
318 }
319 
int unaliased_version(int xversion) const
The actual version associated with (possibly aliased) version xversion in this.
section_space_schema_poset * host() const
The poset which this is a handle to a component of.
int version(bool xunalias=true) const
The (possibly aliased) version of this component. The version of the host used when evaluating proper...
virtual bool invariant() const
The class invariant.
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
schema_poset_member & item()
The current member of the iteration (mutable version).
virtual bool is_schematized(bool xauto_access) const
True if this poset has been prepared for use as a schema, that is, if the top member has been schemat...
virtual bool is_initialized() const
True if this has been initialized for iteration with respect to a specific anchor.
Iterates in postorder over dofs of a schema member anchor. Attaches an a handle of type section_space...
section_dof_iterator()
Default constructor; creates an unattached iterator. Protected because this class is abstract...
virtual section_dof_iterator & operator=(const poset_dof_iterator &xother)
Assignment operator.
Abstract base class with useful features for all objects.
Definition: any.h:39
virtual bool is_done() const
True if iteration finished.
virtual bool is_initialized() const
True if this has been initialized for iteration with respect to a specific anchor.
virtual bool invariant() const
The class invariant.
virtual bool is_ancestor_of(const any *other) const
True if other conforms to this.
bool is_table_dof() const
True if iterating over table dofs.
schema_poset_member & anchor()
The schema member whose downset is being iterated over; the top member of the domain of iteration (mu...
Iterates in postorder over dofs of a schema member anchor. Attaches a handle of type schema_poset_mem...
A client handle for a poset member which has been prepared for use as a schema for a section space...
section_space_schema_member & item()
The current member of the iteration (mutable version).
virtual bool item_is_ancestor_of(const schema_poset_member &xmbr) const
True if xmbr conforms to the type of item of this.
Namespace for the fiber_bundles component of the sheaf system.
section_space_schema_member & anchor()
The schema member whose downset is being iterated over; the top member of the domain of iteration (mu...
bool is_same_type(const any *other) const
True if other is the same type as this.
Definition: any.cc:79
A client handle for a poset member which has been prepared for use as a schema.
bool has_version(int xversion) const
True if xversion is a valid version for this.