SheafSystem  0.0.0.0
section_space_schema_jims_index_space_handle.cc
Go to the documentation of this file.
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 
20 
21 #include "SheafSystem/section_space_schema_jims_index_space_handle.h"
22 #include "SheafSystem/assert_contract.h"
23 #include "SheafSystem/ij_product_structure.h"
24 #include "SheafSystem/index_space_family.h"
25 #include "SheafSystem/section_space_schema_jims_index_space_state.h"
26 #include "SheafSystem/scoped_index.h"
27 
28 using namespace fiber_bundle; // Workaround for MS C++ bug.
29 
30 // ===========================================================
31 // SPACE FACTORY FACET
32 // ===========================================================
33 
34 // PUBLIC MEMBER FUNCTIONS
35 
39  const std::string& xname,
40  const index_space_handle& xbase_space_id_space,
41  const index_space_handle& xfiber_schema_id_space,
42  const ij_product_structure& xsection_space_schema_product)
43 {
44  // Preconditions:
45 
46  require(!xname.empty());
47  require(!xid_spaces.contains(xname));
48 
49  // Body:
50 
53  xname,
54  xbase_space_id_space,
55  xfiber_schema_id_space,
56  xsection_space_schema_product);
57 
58  // Postconditions:
59 
60  ensure(&result.id_spaces() == &xid_spaces);
61  ensure(xid_spaces.contains(xname));
62  ensure(result.conforms_to_state(xname));
63 
64  ensure(result.name() == xname);
65  ensure(!result.is_persistent());
66 
67  ensure(result.base_space() == xbase_space_id_space);
68  ensure(result.fiber_schema() == xfiber_schema_id_space);
69  ensure(unexecutable("result.section_space_schema_product_structure() == xsection_space_schema_product"));
70 
71  ensure(result.begin() == 0);
72  ensure(result.end() == xbase_space_id_space.end()*xfiber_schema_id_space.end());
73  ensure(result.ct() == xbase_space_id_space.ct()*xfiber_schema_id_space.ct());
74 
75  // Exit:
76 
77  return result;
78 }
79 
80 // PROTECTED MEMBER FUNCTIONS
81 
82 // PRIVATE MEMBER FUNCTIONS
83 
84 
85 // ===========================================================
86 // SECTION_SPACE_SCHEMA_JIMS_INDEX_SPACE_HANDLE FACET
87 // ===========================================================
88 
89 // PUBLIC MEMBER FUNCTIONS
90 
94 {
95  // Preconditions:
96 
97  // Body:
98 
99  // Postconditions:
100 
101  ensure(invariant());
102 
103  // Exit:
104 
105  return;
106 }
107 
110 {
111  // Preconditions:
112 
113  // Body:
114 
115  (*this) = xother;
116 
117  // Postconditions:
118 
119  ensure(invariant());
120  ensure((*this) == xother);
121 
122  // Exit:
123 
124  return;
125 }
126 
129  pod_type xindex)
130 {
131  // Preconditions:
132 
133  require(xid_spaces.contains(xindex));
134  require(conforms_to_state(xid_spaces, xindex));
135 
136  // Body:
137 
138  attach_to(xid_spaces, xindex);
139 
140  // Postconditions:
141 
142  ensure(invariant());
143  ensure(is_attached());
144  ensure(&id_spaces() == &xid_spaces);
145  ensure(index() == xindex);
146 
147  // Exit:
148 
149  return;
150 }
151 
154  const std::string& xname)
155 {
156  // Preconditions:
157 
158  require(xid_spaces.contains(xname));
159  require(conforms_to_state(xid_spaces, xname));
160 
161  // Body:
162 
163  attach_to(xid_spaces, xname);
164 
165  // Postconditions:
166 
167  ensure(invariant());
168  ensure(is_attached());
169  ensure(&id_spaces() == &xid_spaces);
170  ensure(name() == xname);
171 
172  // Exit:
173 
174  return;
175 }
176 
180 {
181  // Preconditions:
182 
183  require(xother.is_attached() ? conforms_to_state(xother) : true);
184 
185  // Body:
186 
187  attach_to(xother);
188 
189  // Postconditions:
190 
191  ensure(invariant());
192  ensure((*this) == xother);
193 
194  // Exit:
195 
196  return *this;
197 }
198 
201 {
202  // Preconditions:
203 
204  // Body:
205 
206  // nothing to do.
207 
208  // Postconditions:
209 
210  // Exit:
211 
212  return;
213 }
214 
215 // PROTECTED MEMBER FUNCTIONS
216 
219 {
220  // Preconditions:
221 
222  // Body:
223 
224  attach_to(&xstate);
225 
226  // Postconditions:
227 
228  ensure(invariant());
229  ensure(is_attached());
230  ensure(&state() == &xstate);
231 
232  // Exit:
233 
234  return;
235 }
236 
240 {
241  // Preconditions:
242 
243  require(is_attached());
244 
245  // Body:
246 
248  reinterpret_cast<section_space_schema_jims_index_space_state&>(*_state);
249 
250  // Postconditions:
251 
252  ensure(is_basic_query);
253 
254  // Exit:
255 
256  return result;
257 }
258 
261 state() const
262 {
263  // Preconditions:
264 
265  require(is_attached());
266 
267  // Body:
268 
270  reinterpret_cast<const section_space_schema_jims_index_space_state&>(*_state);
271 
272  // Postconditions:
273 
274  ensure(is_basic_query);
275 
276  // Exit:
277 
278  return result;
279 }
280 
281 // PRIVATE MEMBER FUNCTIONS
282 
283 
284 // ===========================================================
285 // SECTION SPACE SCHEMA JIMS INDEX SPACE FACET
286 // ===========================================================
287 
288 // PUBLIC MEMBER FUNCTIONS
289 
290 void
292 put_factors(const index_space_handle& xbase_space_id_space,
293  const index_space_handle& xfiber_schema_id_space,
294  const ij_product_structure& xsection_space_schema_product)
295 {
296  // Preconditions:
297 
298  // Body:
299 
300  state().put_factors(xbase_space_id_space,
301  xfiber_schema_id_space,
302  xsection_space_schema_product);
303 
304  // Postconditions:
305 
306  ensure(invariant());
307  ensure(is_consistent());
308 
309  // Exit:
310 
311  return;
312 }
313 
316 base_space() const
317 {
318  // Preconditions:
319 
320  // Body:
321 
322  // Postconditions:
323 
324  ensure(is_basic_query);
325 
326  // Exit:
327 
328  return state().base_space();
329 }
330 
334 {
335  // Preconditions:
336 
337  // Body:
338 
339  // Postconditions:
340 
341  ensure(is_basic_query);
342 
343  // Exit:
344 
345  return state().fiber_schema();
346 }
347 
351 {
352  // Preconditions:
353 
354  // Body:
355 
356  // Postconditions:
357 
358  ensure(is_basic_query);
359 
360  // Exit:
361 
363 }
364 
365 bool
368 {
369  // Preconditions:
370 
371  // Body:
372 
373  bool result = state().is_consistent();
374 
375  // Postconditions:
376 
377  ensure(is_basic_query);
378 
379  // Exit:
380 
381  return result;
382 }
383 
384 void
387 {
388  // Preconditions:
389 
390  // Body:
391 
392  state().update();
393 
394  // Postconditions:
395 
396  ensure(is_consistent());
397 
398  // Exit:
399 
400  return;
401 }
402 
403 // PROTECTED MEMBER FUNCTIONS
404 
405 // PRIVATE MEMBER FUNCTIONS
406 
407 
408 // ===========================================================
409 // EXPLICIT_INDEX_SPACE_HANDLE FACET
410 // ===========================================================
411 
412 // PUBLIC MEMBER FUNCTIONS
413 
414 // PROTECTED MEMBER FUNCTIONS
415 
416 // PRIVATE MEMBER FUNCTIONS
417 
418 
419 // ===========================================================
420 // INDEX_SPACE_HANDLE FACET
421 // ===========================================================
422 
423 // PUBLIC MEMBER FUNCTIONS
424 
428 {
429  // Preconditions:
430 
431  require(xother.is_attached() ? conforms_to_state(xother) : true);
432 
433  // Body:
434 
435  attach_to(xother);
436 
437  // Postconditions:
438 
439  ensure(invariant());
440  ensure((*this) == xother);
441 
442  // Exit:
443 
444  return *this;
445 }
446 
449 clone() const
450 {
451  // Preconditions:
452 
453  // Body:
454 
456 
457  // Postconditions:
458 
459  ensure(result != 0);
460  ensure(is_same_type(result));
461  ensure(*result == *this);
462 
463  // Exit:
464 
465  return result;
466 }
467 
468 // PROTECTED MEMBER FUNCTIONS
469 
470 // PRIVATE MEMBER FUNCTIONS
471 
472 
473 // ===========================================================
474 // HANDLE FACET
475 // ===========================================================
476 
477 // PUBLIC MEMBER FUNCTIONS
478 
479 bool
482  pod_type xlocal_id) const
483 {
484  // Preconditions:
485 
486  require(xhost.contains(xlocal_id));
487 
488  // Body:
489 
490  bool result =
491  (dynamic_cast<section_space_schema_jims_index_space_state*>(state(xhost, xlocal_id)) != 0);
492 
493  // Postconditions:
494 
495  ensure(is_basic_query);
496 
497  // Exit:
498 
499  return result;
500 }
501 
502 // PROTECTED MEMBER FUNCTIONS
503 
504 // PRIVATE MEMBER FUNCTIONS
505 
506 
507 // ===========================================================
508 // ANY FACET
509 // ===========================================================
510 
511 // PUBLIC MEMBER FUNCTIONS
512 
513 bool
515 is_ancestor_of(const any *other) const
516 {
517  // Preconditions:
518 
519  require(other != 0);
520 
521  // Body:
522 
523  // True if other conforms to this
524 
525  bool result = dynamic_cast<const section_space_schema_jims_index_space_handle*>(other) != 0;
526 
527  // Postconditions:
528 
529  // Exit:
530 
531  return result;
532 }
533 
534 bool
536 invariant() const
537 {
538  bool result = true;
539 
540  if(invariant_check())
541  {
542  // Prevent recursive calls to invariant
543 
545 
546  // Must satisfy base class invariant
547 
549 
550  // Invariances for this class:
551 
552  // Finished, turn invariant checking back on.
553 
555  }
556 
557  // Exit
558 
559  return result;
560 }
561 
562 // PROTECTED MEMBER FUNCTIONS
563 
564 // PRIVATE MEMBER FUNCTIONS
565 
566 
567 // ===========================================================
568 // NON-MEMBER FUNCTIONS
569 // ===========================================================
570 
571 
An implementation of class explicit_index_space_handle that has a section space schema jims id space ...
virtual void attach_to(pod_type xindex)
Attach to the state with index xindex in the id space family id_spaces().
virtual pod_type index() const
Index of this space.
virtual pod_type end() const =0
Ending id of this space.
void put_factors(const index_space_handle &xbase_space_id_space, const index_space_handle &xfiber_schema_id_space, const ij_product_structure &xsection_space_schema_product)
Set the factors for this section space schema id space.
const index_space_handle & fiber_schema() const
The fiber schema jims id space.
virtual const index_space_family & id_spaces() const
The id space family for this (const version).
An abstract handle to a space of alternate integer identifiers (aliases) for a subset of a hub set of...
section_space_schema_jims_index_space_handle & operator=(const section_space_schema_jims_index_space_handle &xother)
Assignment operator; attach this handle to the state of xother. synonym for attach_to(xother).
virtual bool is_attached() const =0
True if this handle is attached to a state.
bool is_consistent() const
True, if this id space is consistent with the base space and the fiber schema jims id spaces...
virtual bool conforms_to_state(const index_space_collection &xhost, pod_type xlocal_id) const
True if this conforms to the handle type required by the state with local scope id xlocal_id in the h...
Abstract base class with useful features for all objects.
Definition: any.h:39
const ij_product_structure & section_space_schema_product_structure() const
The product structure of the section space schema id space.
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
An implementation of class index_space_handle for an explicit_index_space_state.
std::string name() const
Name of this space.
pod_index_type pod_type
The "plain old data" index type for this.
static section_space_schema_jims_index_space_handle new_space(index_space_family &xid_spaces, const std::string &xname, const index_space_handle &xbase_space_id_space, const index_space_handle &xfiber_schema_id_space, const ij_product_structure &xsection_space_schema_product)
Create a new section space schema jims id space in the id space family xid_space with name xname...
virtual bool is_attached() const
True if this handle is attached to a state.
section_space_schema_jims_index_space_state & state()
The section space schema jims id space state (mutable version).
const index_space_handle & base_space() const
The base space jims id space.
virtual bool invariant() const
Class invariant.
const ij_product_structure & section_space_schema_product_structure() const
The product structure of the section space schema id space.
virtual size_type ct() const =0
The number of members.
static section_space_schema_jims_index_space_handle new_space(index_space_family &xid_spaces, const std::string &xname, const index_space_handle &xbase_space_id_space, const index_space_handle &xfiber_schema_id_space, const ij_product_structure &xsection_space_schema_product)
Create a new section space schema jims id space in the id space family xid_space at the next availabl...
A collection of id space states. This is a virtual class with provides an interface for accessing the...
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
Definition: any.h:97
virtual bool contains(pod_type xlocal_id) const =0
True if this collection contains the id space with local id xlocal_id.
virtual section_space_schema_jims_index_space_handle * clone() const
Virtual constructor, makes a new instance of the same type as this. If the handle is attached...
bool invariant_check() const
True if invariant checking is enabled.
Definition: any.h:79
A 2D implementation of abstract_product_structure.
An implementation class explicit_index_space_state for the jims id space of the section space schema...
bool contains(pod_type xid) const
True, if this contains an id space with id xid.
const index_space_handle & base_space() const
The base space jims id space.
void put_factors(const index_space_handle &xbase_space_id_space, const index_space_handle &xfiber_schema_id_space, const ij_product_structure &xsection_space_schema_product)
Set the factors for this section space schema id space.
void update()
Make this id space consistent with the base space and fiber schema jims id spaces.
Factory and container for a family of id spaces.
bool is_consistent() const
True, if this id space is consistent with the base space and the fiber schema jims id spaces...
Namespace for the fiber_bundles component of the sheaf system.
bool is_same_type(const any *other) const
True if other is the same type as this.
Definition: any.cc:79
void enable_invariant_check() const
Enable invariant checking.
Definition: any.h:87
const index_space_handle & fiber_schema() const
The fiber schema jims id space.
void update()
Make this id space consistent with the base space and fiber schema jims id spaces.