SheafSystem  0.0.0.0
abstract_poset_member.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/abstract_poset_member.impl.h"
22 #include "SheafSystem/assert_contract.h"
23 
24 #include "SheafSystem/array_poset_dof_map.h"
25 #include "SheafSystem/array_index_space_state.h"
26 #include "SheafSystem/dof_descriptor_array.h"
27 #include "SheafSystem/error_message.h"
28 #include "SheafSystem/index_space_iterator.h"
29 #include "SheafSystem/scattered_insertion_index_space_handle.h"
30 #include "SheafSystem/namespace_poset.h"
31 #include "SheafSystem/pool.h"
32 #include "SheafSystem/poset.h"
33 #include "SheafSystem/poset_crg_state.h"
34 #include "SheafSystem/poset_dof_map.h"
35 #include "SheafSystem/poset_joiner.h"
36 #include "SheafSystem/poset_path.h"
37 #include "SheafSystem/poset_slicer.h"
38 #include "SheafSystem/poset_state.h"
39 #include "SheafSystem/poset_state_handle.h"
40 #include "SheafSystem/postorder_itr.h"
41 #include "SheafSystem/preorder_itr.h"
42 #include "SheafSystem/primitives_poset.h"
43 #include "SheafSystem/primitives_poset_dof_map.h"
44 #include "SheafSystem/primitives_poset_schema.h"
45 #include "SheafSystem/schema_poset_member.h"
46 #include "SheafSystem/sheaves_namespace.h"
47 #include "SheafSystem/hub_index_space_handle.h"
48 #include "SheafSystem/std_set.h"
49 #include "SheafSystem/std_vector.h"
50 #include "SheafSystem/stop_watch.h"
51 #include "SheafSystem/subposet.h"
52 #include "SheafSystem/subposet_member_iterator.h"
53 #include "SheafSystem/subposet_state.h"
54 #include "SheafSystem/tern.h"
55 #include "SheafSystem/triorder_itr.h"
56 #include "SheafSystem/zn_to_bool.h"
57 
58 using namespace std;
59 
60 //#define DIAGNOSTIC_OUTPUT
61 
62 // ============================================================================
63 // CLASS ABSTRACT_POSET_MEMBER_TABLE_DOFS_TYPE
64 // ============================================================================
65 
66 // ===========================================================
67 // ABSTRACT_POSET_MEMBER_TABLE_DOFS_TYPE FACET
68 // ===========================================================
69 
70 // PUBLIC MEMBER FUNCTIONS
71 
75 {
76  return reinterpret_cast<dof_type*>(this)[xi];
77 }
78 
82 {
83  return reinterpret_cast<const dof_type*>(this)[xi];
84 }
85 
88 clone() const
89 {
91 }
92 
93 // PROTECTED MEMBER FUNCTIONS
94 
95 // PRIVATE MEMBER FUNCTIONS
96 
97 
98 // ============================================================================
99 // CLASS ABSTRACT_POSET_MEMBER_ROW_DOFS_TYPE
100 // ============================================================================
101 
102 // ===========================================================
103 // ABSTRACT_POSET_MEMBER_ROW_DOFS_TYPE FACET
104 // ===========================================================
105 
106 // PUBLIC MEMBER FUNCTIONS
107 
111 {
112  return reinterpret_cast<dof_type*>(this)[xi];
113 };
114 
118 {
119  return reinterpret_cast<const dof_type*>(this)[xi];
120 };
121 
124 clone() const
125 {
127 };
128 
129 // PROTECTED MEMBER FUNCTIONS
130 
131 // PRIVATE MEMBER FUNCTIONS
132 
133 
134 // ============================================================================
135 // CLASS ABSTRACT_POSET_MEMBER
136 // ============================================================================
137 
138 // ===========================================================
139 // HOST FACTORY FACET
140 // ===========================================================
141 
142 // PUBLIC MEMBER FUNCTIONS
143 
146 new_host(namespace_type& xns, const poset_path& xhost_path, const poset_path& xschema_path, bool xauto_access)
147 {
148  // cout << endl << "Entering abstract_poset_member::new_host." << endl;
149 
150  // Preconditions:
151 
152  require(xns.state_is_auto_read_write_accessible(xauto_access));
153 
154  require(!xhost_path.empty());
155  require(!xns.contains_path(xhost_path, xauto_access));
156 
157  require(xschema_path.full());
158  require(xns.path_is_auto_read_accessible(xschema_path, xauto_access));
159 
160 
161  // Body:
162 
163  host_type& result = host_type::new_table(xns, xhost_path, xschema_path, xauto_access);
164 
165  // Postconditions:
166 
167  ensure(xns.owns(result, xauto_access));
168  ensure(result.path(true) == xhost_path);
169  ensure(result.state_is_not_read_accessible());
170  ensure(result.schema(true).path(xauto_access) == xschema_path);
171 
172  // Exit:
173 
174  // cout << "Leaving abstract_poset_member::new_host." << endl;
175  return result;
176 }
177 
178 
179 // PROTECTED MEMBER FUNCTIONS
180 
181 // PRIVATE MEMBER FUNCTIONS
182 
183 // ===========================================================
184 // ABSTRACT_POSET_MEMBER FACET
185 // ===========================================================
186 
187 // PUBLIC MEMBER FUNCTIONS
188 
192 {
193  // Preconditions:
194 
195  // Body:
196 
197  attach_to_state(&xother);
198 
199  // Postconditions:
200 
201  ensure(is_same_state(&xother));
202 
203  // Exit
204 
205  return *this;
206 }
207 
210 {
211  // Preconditions:
212 
213  // Body:
214 
215  // Nothing to do.
216 
217  // Postconditions:
218 
219  // Exit
220 
221  return;
222 }
223 
226 clone(bool xnew_state, bool xauto_access) const
227 {
228 
229  // Preconditions:
230 
231  require(is_attached());
232  require(xauto_access || (xnew_state ? host()->in_jim_edit_mode() :
233  host()->state_is_read_accessible()));
234 
235  // Body:
236 
237  // create new version of current
238 
239  abstract_poset_member *result = clone();
240 
241  // Either attach to a new state or attach to the current state.
242 
243  if(xnew_state)
244  {
245  result->new_jim_state(host(), 0, false, xauto_access);
246  }
247  else
248  {
249  if(xauto_access)
250  host()->get_read_access();
251 
252  result->attach_to_state(this);
253 
254  if(xauto_access)
255  host()->release_access();
256  }
257 
258  // Postconditions:
259 
260  ensure(result != 0);
261  ensure(is_same_type(result));
262 
263  // Exit:
264 
265  return result;
266 }
267 
268 // EXISTING HANDLE, NEW STATE "CONSTRUCTORS"
269 
270 void
272 new_jim_state(poset_dof_map* xdof_map, bool xcopy_dof_map, bool xauto_access)
273 {
274  // Preconditions:
275 
276  require(!xauto_access ? host()->in_jim_edit_mode() : true);
277  require(!xauto_access && xdof_map != 0 ? xdof_map->host()->state_is_read_accessible() : true);
278 
279  // Get access if auto access is requested. Need to do it here so the
280  // remaining preconditions can be executed.
281 
282  if(xauto_access)
283  {
284  host()->begin_jim_edit_mode();
285 
286  if(xdof_map != 0)
287  xdof_map->host()->get_read_access();
288  }
289 
290  require(xdof_map != 0 ? host()->row_dof_map_conforms(xdof_map) : true);
291  require(xdof_map != 0 ? dof_map_is_ancestor_of(xdof_map) : true);
292  require(xdof_map != 0 ? xdof_map->schema().row_conforms_to(host()->schema()) : true);
293 
294  // Body:
295 
296  // new_jim_state(_host, xdof_map, xcopy_dof_map);
297 
298  // Create new jim and attach to it.
299  // Attach_to_state(xindex) attaches but does not reinitialize handle data members.
300 
301  pod_index_type lindex = _host->new_member(true, xdof_map, xcopy_dof_map);
302  attach_to_state(lindex);
303 
304  // Postconditions:
305 
306  ensure(invariant());
307  ensure(is_attached());
308  ensure(!is_restricted());
309 
310  // Release access if auto access was requested.
311 
312  if(xauto_access)
313  {
314  host()->end_jim_edit_mode();
315 
316  if(xdof_map != 0)
317  xdof_map->host()->release_access();
318  }
319 
320  // Exit:
321 
322  return;
323 }
324 
325 void
327 new_jim_state(pod_index_type xtuple_id, bool xauto_access)
328 {
329  // Preconditions:
330 
331  require(!xauto_access ? host()->in_jim_edit_mode() : true);
332 
333  // Get access if auto access is requested. Need to do it here so the
334  // remaining preconditions can be executed.
335 
336  if(xauto_access)
337  host()->begin_jim_edit_mode();
338 
339  require(host()->contains_row_dof_tuple(xtuple_id));
340 
341  // Body:
342 
343  // Get auto access
344 
345  // Create new jim and attach to it.
346  // Attach_to_state(xindex) attaches but does not reinitialize handle data members.
347 
348  pod_index_type lindex = _host->new_member(true, xtuple_id);
349  attach_to_state(lindex);
350 
351  // Postconditions:
352 
353  ensure(invariant());
354  ensure(is_attached());
355  ensure(!is_restricted());
356  ensure(dof_tuple_id(false) == xtuple_id);
357 
358  // Release access if auto access was requested.
359 
360  if(xauto_access)
361  host()->end_jim_edit_mode();
362 
363  // Exit:
364 
365  return;
366 }
367 
368 void
370 new_jim_state(const scoped_index& xtuple_id, bool xauto_access)
371 {
372  // Preconditions:
373 
374  require(!xauto_access ? host()->in_jim_edit_mode() : true);
375 
376  // Get access if auto access is requested. Need to do it here so the
377  // remaining preconditions can be executed.
378 
379  if(xauto_access)
380  host()->begin_jim_edit_mode();
381 
382  require(host()->contains_row_dof_tuple(xtuple_id));
383 
384  // Body:
385 
386  new_jim_state(xtuple_id.hub_pod(), xauto_access);
387 
388  // Postconditions:
389 
390  ensure(invariant());
391  ensure(is_attached());
392  ensure(!is_restricted());
393  ensure(dof_tuple_id(false) == xtuple_id.hub_pod());
394 
395  // Release access if auto access was requested.
396 
397  if(xauto_access)
398  host()->end_jim_edit_mode();
399 
400  // Exit:
401 
402  return;
403 }
404 
405 void
407 new_jim_state(poset_state_handle* xhost, poset_dof_map* xdof_map, bool xcopy_dof_map, bool xauto_access)
408 {
409  // Preconditions:
410 
411  require(xhost != 0);
412  require(!xauto_access ? xhost->in_jim_edit_mode() : true);
413  require(!xauto_access && xdof_map != 0 ? xdof_map->host()->state_is_read_accessible() : true);
414 
415  // Get access if auto access is requested. Need to do it here so the
416  // remaining preconditions can be executed.
417 
418  if(xauto_access)
419  {
420  xhost->begin_jim_edit_mode();
421 
422  if(xdof_map != 0)
423  xdof_map->host()->get_read_access();
424  }
425 
426  require(host_is_ancestor_of(xhost));
427  require(xdof_map != 0 ? xhost->row_dof_map_conforms(xdof_map) : true);
428  require(xdof_map != 0 ? dof_map_is_ancestor_of(xdof_map) : true);
429  require(xdof_map != 0 ? xdof_map->schema().row_conforms_to(xhost->schema()) : true);
430 
431  // Body:
432 
433  // Create new jim and attach to it.
434  // Attach_to_state(xhost, xindex) reinitializes and attaches handle data members.
435 
436  pod_index_type lindex = xhost->new_member(true, xdof_map, xcopy_dof_map);
437  attach_to_state(xhost, lindex);
438 
439  // Postconditions:
440 
441  ensure(abstract_poset_member::invariant());
442  ensure(unexecutable(host()->member_ct() == old host->member_ct() + 1));
443  ensure(is_attached());
444  ensure(!is_restricted());
445 
446  // Release access if auto access was requested.
447 
448  if(xauto_access)
449  {
450  xhost->end_jim_edit_mode();
451 
452  if(xdof_map != 0)
453  xdof_map->host()->release_access();
454  }
455 
456  // Exit:
457 
458  return;
459 }
460 
461 void
463 new_jim_state(poset_state_handle* xhost, pod_index_type xtuple_id, bool xauto_access)
464 {
465  // Preconditions:
466 
467  require(xhost != 0);
468  require(!xauto_access ? xhost->in_jim_edit_mode() : true);
469 
470  // Get access if auto access is requested. Need to do it here so the
471  // remaining preconditions can be executed.
472 
473  if(xauto_access)
474  xhost->begin_jim_edit_mode();
475 
476  require(host_is_ancestor_of(xhost));
477  require(xhost->contains_row_dof_tuple(xtuple_id));
478 
479  // Body:
480 
481  // Create new jim and attach to it.
482  // Attach_to_state(xhost, xindex) reinitializes and attaches handle data members.
483 
484  pod_index_type lindex = xhost->new_member(true, xtuple_id);
485  attach_to_state(xhost, lindex);
486 
487  // Postconditions:
488 
489  ensure(abstract_poset_member::invariant());
490  ensure(unexecutable(host()->member_ct() == old host->member_ct() + 1));
491  ensure(is_attached());
492  ensure(!is_restricted());
493  ensure(dof_tuple_id(false) == xtuple_id);
494 
495  // Release access if auto access was requested.
496 
497  if(xauto_access)
498  xhost->end_jim_edit_mode();
499 
500  // Exit:
501 
502  return;
503 }
504 
505 void
507 new_jim_state(poset_state_handle* xhost, const scoped_index& xtuple_id, bool xauto_access)
508 {
509  // Preconditions:
510 
511  require(xhost != 0);
512  require(!xauto_access ? xhost->in_jim_edit_mode() : true);
513 
514  // Get access if auto access is requested. Need to do it here so the
515  // remaining preconditions can be executed.
516 
517  if(xauto_access)
518  xhost->begin_jim_edit_mode();
519 
520  require(host_is_ancestor_of(xhost));
521  require(xhost->contains_row_dof_tuple(xtuple_id));
522 
523  // Body:
524 
525  new_jim_state(xhost, xtuple_id.hub_pod(), false);
526 
527  // Postconditions:
528 
529  ensure(abstract_poset_member::invariant());
530  ensure(unexecutable(host()->member_ct() == old host->member_ct() + 1));
531  ensure(is_attached());
532  ensure(!is_restricted());
533  ensure(dof_tuple_id(false) == xtuple_id.hub_pod());
534 
535  // Release access if auto access was requested.
536 
537  if(xauto_access)
538  xhost->end_jim_edit_mode();
539 
540  // Exit:
541 
542  return;
543 }
544 
545 void
547 new_jrm_state(bool xauto_access)
548 {
549  // Preconditions:
550 
551  require(xauto_access ? is_attached() : state_is_read_write_accessible());
552 
553  // Body:
554 
555  if(xauto_access)
556  {
557  host()->get_read_write_access(true);
558  }
559 
560 
562 
563  // Create new jrm and attach to it.
564  // Attach_to_state(xindex) attaches but does not reinitialize handle data members.
565 
566  attach_to_state(host()->new_member(false));
567 
568  // Postconditions:
569 
570  ensure(abstract_poset_member::invariant());
571  ensure(is_attached());
572  ensure(!is_restricted());
573 
574  // Release access if auto access was requested.
575 
576  if(xauto_access)
577  {
578  host()->release_access();
579  }
580 
581  // Exit:
582 
583  return;
584 }
585 
586 void
588 new_jrm_state(poset_state_handle* xhost, bool xauto_access)
589 {
590  // Preconditions:
591 
592  require(xhost != 0);
593  require(host_is_ancestor_of(xhost));
594  require(!xauto_access ? xhost->state_is_read_write_accessible() : true);
595 
596  // Get access if auto access is requested. Need to do it here so the
597  // remaining preconditions can be executed.
598 
599  if(xauto_access)
600  {
601  xhost->get_read_write_access(true);
602  }
603 
604  // Body:
605 
607 
608  // Create new jrm and attach to it.
609  // Attach_to_state(xhost, xindex) reinitializes and attaches handle data memebrs.
610 
611  pod_index_type lmbr_id = xhost->new_member(false);
612  attach_to_state(xhost, lmbr_id);
613 
614  // Postconditions:
615 
616  ensure(abstract_poset_member::invariant());
617  ensure(is_attached());
618  ensure(!is_restricted());
619 
620  // Release access if auto access was requested.
621 
622  if(xauto_access)
623  {
624  xhost->release_access();
625  }
626 
627  // Exit:
628 
629  return;
630 }
631 
632 void
634 new_jrm_state(const scoped_index* xexpansion,
635  int xexpansion_ct,
636  const tern& xgreatest,
637  bool xauto_access)
638 {
639  // Preconditions:
640 
641  require(xauto_access ? is_attached() : state_is_read_write_accessible());
642  require(precondition_of(new_jrm_state(host(), xexpansion, xexpansion_ct, xgreatest, xauto_access)));
643 
644  // Body:
645 
646  new_jrm_state(host(), xexpansion, xexpansion_ct, xgreatest, false);
647 
648  // Postconditions:
649 
650  ensure(postcondition_of(new_jrm_state(host(), xexpansion, xexpansion_ct, xgreatest, xauto_access)));
651 
652  // Exit:
653 
654  return;
655 }
656 
657 void
660  const scoped_index* xexpansion,
661  int xexpansion_ct,
662  const tern& xgreatest,
663  bool xauto_access)
664 {
665  // Preconditions:
666 
667  require(xhost != 0);
668  require(host_is_ancestor_of(xhost));
669  require(xhost->state_is_auto_read_write_accessible(xauto_access));
670  require(xexpansion != 0);
671 
672  // Get access if auto access is requested. Need to do it here so the
673  // remaining preconditions can be executed.
674 
675  if(xauto_access)
676  {
677  xhost->get_read_write_access(true);
678  }
679 
680  require(xhost->contains_members(xexpansion, xexpansion_ct));
681 
682  // Body:
683 
684  // Joiner attaches this to result using attach_to_state(xhost, xindex);
685  // reinitializes and attaches handle data members.
686 
687  poset_joiner joiner(xhost);
688 
689  joiner.join(xexpansion, xexpansion_ct, xgreatest, *this);
690 
691  // Postconditions:
692 
693  ensure(invariant());
694  ensure(is_attached());
695  ensure(!is_restricted());
696  ensure(host() == xhost);
697  ensure(unexecutable(is_jim() == this is max member of xexpansion));
698 
699  // Release access if auto access was requested.
700 
701  if(xauto_access)
702  {
703  xhost->release_access();
704  }
705 
706  // Exit:
707 
708  return;
709 }
710 
711 void
713 new_jem_state(abstract_poset_member* xother, bool xgreatest, bool xauto_access)
714 {
715  // Preconditions:
716 
717  require(xother != 0);
718  require(xother->state_is_auto_read_write_accessible(xauto_access));
719  require(precondition_of(new_jem_state(xother->host(), xother->index(), xgreatest, xauto_access)));
720 
721  // Body:
722 
723  new_jem_state(xother->host(), xother->index(), xgreatest, xauto_access);
724 
725  // Postconditions:
726 
727  require(postcondition_of(new_jem_state(xother->host(), xother->index(), xgreatest, xauto_access)));
728 
729  // Exit:
730 
731  return;
732 }
733 
734 void
737  pod_index_type xhub_id,
738  bool xgreatest,
739  bool xauto_access)
740 {
741  // Preconditions:
742 
743  require(xhost != 0);
744  require(xhost->state_is_auto_read_write_accessible(xauto_access));
745  require(host_is_ancestor_of(xhost));
746  require(xhost->contains_member(xhub_id, xauto_access));
747 
748  // Body:
749 
750  if(xauto_access)
751  {
752  xhost->get_read_write_access(true);
753  }
754 
755  // Create new jem and attach to it;
756  // new_member ensures upper and lower cover empty.
757  // Attach_to_state(xhost, xhub_id) reinitializes and attaches handle data members.
758 
759  pod_index_type lindex = xhost->new_member(false);
760  if(xgreatest)
761  {
762  xhost->link_greatest_jem(lindex, xhub_id);
763  }
764  else
765  {
766  xhost->link_least_jem(lindex, xhub_id);
767  }
768 
769  attach_to_state(xhost, lindex);
770 
771  // Postconditions:
772 
773  ensure(invariant());
774  ensure(is_attached());
775  ensure(!is_restricted());
776  ensure(host()->is_jem(xhub_id, index().pod()));
777 
778  // If xgreatest, then either this is greatest jem or top is,
779  // otherwise either this is least jem or bottom is.
780 
781  ensure(xgreatest ?
782  (host()->greatest_jem(xhub_id) == index().pod() ||
783  host()->greatest_jem(xhub_id) == TOP_INDEX) :
784  (host()->least_jem(xhub_id) == index().pod() ||
785  host()->is_jim(host()->least_jem(xhub_id)) ||
786  host()->least_jem(xhub_id) == BOTTOM_INDEX));
787 
788  // Release access if auto access was requested.
789 
790  if(xauto_access)
791  {
792  xhost->release_access();
793  }
794 
795  // Exit:
796 
797  return;
798 }
799 
800 void
803  const scoped_index& xid,
804  bool xgreatest,
805  bool xauto_access)
806 {
807  // Preconditions:
808 
809  require(precondition_of(new_jem_state(xhost, xindex.hub_pod(), xgreatest, xauto_access)));
810 
811  // Body:
812 
813  new_jem_state(xhost, xid.hub_pod(), xgreatest, xauto_access);
814 
815  // Postconditions:
816 
817  ensure(postcondition_of(new_jem_state(xhost, xindex.hub_pod(), xgreatest, xauto_access)));
818 
819  // Exit:
820 
821  return;
822 }
823 
824 // PROTECTED MEMBER FUNCTIONS
825 
828 {
829  // Preconditions:
830 
831  // Body:
832 
833  // Postconditions:
834 
835  ensure(invariant());
836  ensure(!is_attached());
837 }
838 
839 void
842 {
843  // Preconditions:
844 
845  require(state_is_read_accessible());
846  require(unexecutable(data members created));
847 
848  // Body:
849 
850  // Have just attached to a new or different member in the same host.
851  // Attach the handle data members for the different member.
852 
853  // This routine is conceptually abstract.
854  // Implemented as empty body here to define the postcondition.
855  // Does nothing in this class.
856  // Intended for redefinition in derived classes,
857  // c.f. partial_poset_member and schema_poset_member.
858 
859  // Postconditions:
860 
861  ensure(!is_restricted());
862 
863  // Exit
864 
865  return;
866 }
867 
868 char*
870 table_dof_ptr(bool xrequire_write_access) const
871 {
872  // Preconditions:
873 
874  require(xrequire_write_access ? state_is_read_write_accessible() : state_is_read_accessible());
875 
876  // Body:
877 
878  char* result = host()->table_dof_map(xrequire_write_access).dofs();
879 
880  // Postconditions:
881 
883  // ensure(invariant());
884  ensure(result != 0);
885 
886  // Exit:
887 
888  return result;
889 }
890 
891 char*
893 row_dof_ptr(bool xrequire_write_access)
894 {
895  // Preconditions:
896 
897  require(xrequire_write_access ? state_is_read_write_accessible() : state_is_read_accessible());
898 
899  // Body:
900 
901  char* result =
902  reinterpret_cast<char*>(dof_map(xrequire_write_access).dof_tuple());
903 
904  // Postconditions:
905 
906  ensure(invariant());
907  ensure(result != 0);
908 
909  // Exit:
910 
911  return result;
912 }
913 
914 // PRIVATE MEMBER FUNCTIONS
915 
916 
917 // ===========================================================
918 // MEMBER ATTRIBUTE FACET
919 // ===========================================================
920 
921 // PUBLIC MEMBER FUNCTIONS
922 
923 bool
925 is_jim(bool xin_current_version) const
926 {
927  bool result;
928 
929  // Preconditions:
930 
931  require(state_is_read_accessible());
932 
933  // Body:
934 
935  result = host()->is_jim(index(), xin_current_version);
936 
937  // Postconditions:
938 
939  // Exit
940 
941  return result;
942 }
943 
944 bool
946 is_atom() const
947 {
948  bool result;
949 
950  // Preconditions:
951 
952  require(state_is_read_accessible());
953 
954  // Body:
955 
956  result = host()->is_atom(index());
957 
958  // Postconditions:
959 
960  // Exit
961 
962  return result;
963 }
964 
965 // PROTECTED MEMBER FUNCTIONS
966 
967 // PRIVATE MEMBER FUNCTIONS
968 
969 
970 // ===========================================================
971 // SCHEMA FACET
972 // ===========================================================
973 
974 // PUBLIC MEMBER FUNCTIONS
975 
979 {
980  // Preconditions:
981 
982  require(state_is_read_accessible());
983 
984  // Body:
985 
986  // This routine is conceptually abstract;
987  // implemented here only to establish the contract.
988 
989  // The following implementation is overidden
990  // in all direct descendants, and is used here
991  // only to make the compiler happy with the postcondition.
992 
993  schema_poset_member& result = unrestricted_schema();
994 
995  // Postconditions:
996 
997  ensure(result.le(&(unrestricted_schema())));
998 
999  // Exit:
1000 
1001  return result;
1002 }
1003 
1006 schema() const
1007 {
1008  // Preconditions:
1009 
1010  require(state_is_read_accessible());
1011 
1012  // Body:
1013 
1014  // This routine is conceptually abstract;
1015  // implemented here only to establish the contract.
1016 
1017  // The following implementation is overidden
1018  // in all direct descendants, and is used here
1019  // only to make the compiler happy with the postcondition.
1020 
1021  const schema_poset_member& result = unrestricted_schema();
1022 
1023  // Postconditions:
1024 
1025  ensure(result.le(&(unrestricted_schema())));
1026 
1027  // Exit:
1028 
1029  return result;
1030 }
1031 
1034 schema(bool xauto_access)
1035 {
1036  // Preconditions:
1037 
1038  require(xauto_access || state_is_read_accessible());
1039 
1040  // Body:
1041 
1042  if(xauto_access)
1043  {
1044  get_read_access();
1045  }
1046 
1047 
1048  schema_poset_member& result = schema();
1049 
1050  if(xauto_access)
1051  {
1052  release_access();
1053  }
1054 
1055  // Postconditions:
1056 
1057  ensure(postcondition_of(schema()));
1058 
1059  // Exit:
1060 
1061  return result;
1062 }
1063 
1066 schema(bool xauto_access) const
1067 {
1068  // Preconditions:
1069 
1070  require(xauto_access || state_is_read_accessible());
1071 
1072  // Body:
1073 
1074  if(xauto_access)
1075  {
1076  get_read_access();
1077  }
1078 
1079  const schema_poset_member& result = schema();
1080 
1081  if(xauto_access)
1082  {
1083  release_access();
1084  }
1085 
1086  // Postconditions:
1087 
1088  ensure(postcondition_of(schema()));
1089 
1090  // Exit:
1091 
1092  return result;
1093 }
1094 
1098 {
1099  // Preconditions:
1100 
1101  require(state_is_read_accessible());
1102 
1103  // Body:
1104 
1105  // If this has a dof map, the unrestricted schema of this is the schema of
1106  // its dof map, otherwise, use the schema of the host.
1107  // Note that the version of the schema used by the dof map is
1108  // not necessarily the version currently used by the host.
1109  // Also note that if the host has multiple versions, a member
1110  // has a dof map if it is a jim in some version of the host.
1111 
1113 
1114  schema_poset_member& result = is_jim(false) ? dof_map().schema() : host()->schema();
1115 
1116  // Postconditions:
1117 
1118  ensure(result.leqv(host()->schema().index()));
1119 
1120  // Exit
1121 
1122  return result;
1123 }
1124 
1128 {
1129  // Preconditions:
1130 
1131  require(state_is_read_accessible());
1132 
1133  // Body:
1134 
1135  // If this has a dof map, the unrestricted schema of this is the schema of
1136  // its dof map, otherwise, use the schema of the host.
1137  // Note that the version of the schema used by the dof map is
1138  // not necessarily the version currently used by the host.
1139  // Also note that if the host has multiple versions, a member
1140  // has a dof map if it is a jim in some version of the host.
1141 
1143 
1144  const schema_poset_member& result = is_jim(false) ? dof_map().schema() : host()->schema();
1145 
1146  // Postconditions:
1147 
1148  ensure(result.leqv(host()->schema().index()));
1149 
1150  // Exit
1151 
1152  return result;
1153 }
1154 
1155 bool
1157 schema_is(const std::string& xschema_name) const
1158 {
1159  bool result;
1160 
1161  // Preconditions:
1162 
1163  require(state_is_read_accessible());
1164 
1165  // Body:
1166 
1167  result = schema().name() == xschema_name;
1168 
1169  // Postconditions:
1170 
1171  // Exit
1172 
1173  return result;
1174 }
1175 
1176 bool
1179 {
1180  bool result;
1181 
1182  // Preconditions:
1183 
1184  require(state_is_read_accessible());
1185  require(xother != 0);
1186  require(xother->state_is_read_accessible());
1187 
1188 
1189  // Body:
1190 
1191  result = schema().is_same_state(&(xother->schema()));
1192 
1193  // Postconditions:
1194 
1195  // Exit
1196 
1197  return result;
1198 }
1199 
1200 // PROTECTED MEMBER FUNCTIONS
1201 
1202 // PRIVATE MEMBER FUNCTIONS
1203 
1204 
1205 // ===========================================================
1206 // RESTRICTION FACET
1207 // ===========================================================
1208 
1209 // PUBLIC MEMBER FUNCTIONS
1210 
1211 bool
1214 {
1215  bool result;
1216 
1217  // Preconditions:
1218 
1219  require(is_attached() ? state_is_read_accessible() : true); // required by host()->schema()
1220 
1221  // Body:
1222 
1223  result = ( is_attached() && !schema().is_same_state(&(unrestricted_schema())) );
1224 
1225  // Postconditions:
1226 
1227  ensure(result == ( is_attached() && !schema().is_same_state(&(unrestricted_schema())) ));
1228 
1229  // Exit
1230 
1231  return result;
1232 }
1233 
1234 bool
1237 {
1238  bool result;
1239 
1240  // Preconditions:
1241 
1242  require(is_attached() ? state_is_read_accessible() : true); // may be required by schema()
1243  require(xother != 0);
1244  require(xother->is_attached() ? xother->state_is_read_accessible() : true);
1245 
1246  // Body:
1247 
1248  if(is_attached())
1249  {
1250  result = xother->is_attached() && schema().is_same_state(&(xother->schema()));
1251  }
1252  else
1253  {
1254  result = !xother->is_attached();
1255  }
1256 
1257  // Postconditions:
1258 
1259  ensure(unexecutable(result == this and xother are attached and have the same schema or both are unattached));
1260 
1261  // Exit
1262 
1263  return result;
1264 }
1265 
1266 // PROTECTED MEMBER FUNCTIONS
1267 
1268 // PRIVATE MEMBER FUNCTIONS
1269 
1270 
1271 // ===========================================================
1272 // DEGREE OF FREEDOM (DOF) TUPLE FACET
1273 // ===========================================================
1274 
1275 // PUBLIC MEMBER FUNCTIONS
1276 
1279 dof_map(bool xrequire_write_access)
1280 {
1281  // Preconditions:
1282 
1283  require(xrequire_write_access ?
1284  state_is_read_write_accessible() :
1285  state_is_read_accessible());
1286  require(is_jim(false));
1287 
1288  // Body:
1289 
1290  return _host->member_dof_map(_index.pod(), xrequire_write_access);
1291 }
1292 
1293 const sheaf::poset_dof_map&
1295 dof_map(bool xrequire_write_access) const
1296 {
1297  // Preconditions:
1298 
1299  require(xrequire_write_access ?
1300  state_is_read_write_accessible() :
1301  state_is_read_accessible());
1302  require(is_jim(false));
1303 
1304  // Body:
1305 
1306  return _host->member_dof_map(_index.pod(), xrequire_write_access);
1307 }
1308 
1309 bool
1312 {
1313  bool result;
1314 
1315  // Preconditions:
1316 
1317  require(xdof_map != 0);
1318 
1319  // Body:
1320 
1321  // This handle requires xdof_map to be of type poset_dof_map,
1322  // so the result is always true.
1323 
1324  result = true;
1325 
1326  // Postconditions:
1327 
1328  // Exit
1329 
1330  return result;
1331 }
1332 
1333 void
1335 dof_tuple(const void* xbuf, size_t xbuflen) const
1336 {
1337  // Preconditions:
1338 
1339  require(state_is_read_accessible());
1340  require(!is_restricted());
1341  require(xbuf != 0);
1342  require(unexecutable(xbuf points to a buffer of length xbuflen));
1343  require(xbuflen >= dof_map().dof_tuple_ub());
1344 
1345  // Body:
1346 
1347  dof_map().get_dof_tuple(const_cast<void*>(xbuf), xbuflen);
1348 
1349  // Postconditions:
1350 
1351  ensure(unexecutable(xbuf contains copy of dof tuple));
1352 
1353  // Exit
1354 
1355  return;
1356 }
1357 
1358 void
1360 put_dof_tuple(const void* xbuf, size_t xbuflen)
1361 {
1362  // Preconditions:
1363 
1364  require(state_is_read_write_accessible());
1365  require(!is_restricted());
1366  require(xbuf != 0);
1367  require(unexecutable(xbuf points to a buffer of length xbuflen));
1368  require(xbuflen >= dof_map().dof_tuple_ub());
1369  require(unexecutable(xbuf contains copy of dof tuple));
1370 
1371  // Body:
1372 
1373  dof_map().put_dof_tuple(xbuf, xbuflen);
1374 
1375  // Postconditions:
1376 
1377  ensure(unexecutable(dof tuple has been copied to internal storage));
1378 
1379  // Exit
1380 
1381  return;
1382 }
1383 
1386 dof_tuple_id(bool xauto_access) const
1387 {
1388  // Preconditions:
1389 
1390  require(state_is_auto_read_accessible(xauto_access));
1391 
1392  // Body:
1393 
1394  pod_index_type result = host()->member_dof_tuple_id(index().pod(), xauto_access);
1395 
1396  // Postconditions:
1397 
1398  ensure(host()->contains_row_dof_tuple(result) || (!is_valid(result)));
1399 
1400  // Exit
1401 
1402  return result;
1403 }
1404 
1405 void
1407 dof_tuple_id(scoped_index& result, bool xauto_access) const
1408 {
1409  // Preconditions:
1410 
1411  require(state_is_auto_read_accessible(xauto_access));
1412 
1413  // Body:
1414 
1415  host()->member_dof_tuple_id(index(), result, xauto_access);
1416 
1417  // Postconditions:
1418 
1419  ensure(host()->contains_row_dof_tuple(result) || (!result.is_valid()));
1420 
1421  // Exit
1422 
1423  return;
1424 }
1425 
1426 void
1428 put_dof_tuple_id(pod_index_type xtuple_index, bool xauto_access)
1429 {
1430  // Preconditions:
1431 
1432  require(state_is_auto_read_write_accessible(xauto_access));
1433  require(host()->contains_row_dof_tuple(xtuple_index) || !is_valid(xtuple_index));
1434 
1435  // Body:
1436 
1437  host()->put_member_dof_tuple_id(_index.pod(), xtuple_index, xauto_access);
1438 
1439  // Postconditions:
1440 
1441  ensure(dof_tuple_id(xauto_access) == xtuple_index);
1442 
1443  // Exit
1444 
1445  return;
1446 }
1447 
1448 void
1450 put_dof_tuple_id(const scoped_index& xtuple_index, bool xauto_access)
1451 {
1452  // Preconditions:
1453 
1454  require(state_is_auto_read_write_accessible(xauto_access));
1455  require(host()->contains_row_dof_tuple(xtuple_index) || !xtuple_index.is_valid());
1456 
1457  // Body:
1458 
1459  host()->put_member_dof_tuple_id(_index, xtuple_index, xauto_access);
1460 
1461  // Postconditions:
1462 
1463  ensure(dof_tuple_id(xauto_access) == xtuple_index.hub_pod());
1464 
1465  // Exit
1466 
1467  return;
1468 }
1469 
1470 void*
1473 {
1474  // Preconditions:
1475 
1476  require(state_is_read_write_accessible());
1477 
1478  // Body:
1479 
1480  void* result = _host->table_dof_map(true).dof_tuple();
1481 
1482  // Postconditions:
1483 
1484  // Exit:
1485 
1486  return result;
1487 }
1488 
1489 const void*
1491 table_dofs() const
1492 {
1493  // Preconditions:
1494 
1495  require(state_is_read_accessible());
1496 
1497  // Body:
1498 
1499  const void* result = _host->table_dof_map(false).dof_tuple();
1500 
1501  // Postconditions:
1502 
1503  // Exit:
1504 
1505  return result;
1506 }
1507 
1508 void*
1510 table_dofs(bool xauto_access)
1511 {
1512  // Preconditions:
1513 
1514  require(state_is_auto_read_write_accessible(xauto_access));
1515 
1516  // Body:
1517 
1518  if(xauto_access)
1519  {
1520  get_read_write_access(true);
1521  }
1522 
1523  void* result = table_dofs();
1524 
1525  if(xauto_access)
1526  {
1527  release_access();
1528  }
1529 
1530  // Postconditions:
1531 
1532  // Exit:
1533 
1534  return result;
1535 }
1536 
1537 const void*
1539 table_dofs(bool xauto_access) const
1540 {
1541  // Preconditions:
1542 
1543  require(state_is_auto_read_accessible(xauto_access));
1544 
1545  // Body:
1546 
1547  if(xauto_access)
1548  {
1549  get_read_access();
1550  }
1551 
1552  const void* result = table_dofs();
1553 
1554  if(xauto_access)
1555  {
1556  release_access();
1557  }
1558 
1559  // Postconditions:
1560 
1561  // Exit:
1562 
1563  return result;
1564 }
1565 
1566 void*
1569 {
1570  // Preconditions:
1571 
1572  require(state_is_read_write_accessible());
1573 
1574  // Body:
1575 
1576  void* result = _host->member_dof_map(_index.pod(), true).dof_tuple();
1577 
1578  // Postconditions:
1579 
1580  // Exit:
1581 
1582  return result;
1583 }
1584 
1585 const void*
1587 row_dofs() const
1588 {
1589  // Preconditions:
1590 
1591  require(state_is_read_accessible());
1592 
1593  // Body:
1594 
1595  const void* result = _host->member_dof_map(_index.pod(), false).dof_tuple();
1596 
1597  // Postconditions:
1598 
1599  // Exit:
1600 
1601  return result;
1602 }
1603 
1604 void*
1606 row_dofs(bool xauto_access)
1607 {
1608  // Preconditions:
1609 
1610  require(state_is_auto_read_write_accessible(xauto_access));
1611 
1612  // Body:
1613 
1614  if(xauto_access)
1615  {
1616  get_read_write_access(true);
1617  }
1618 
1619  void* result = row_dofs();
1620 
1621  if(xauto_access)
1622  {
1623  release_access();
1624  }
1625 
1626  // Postconditions:
1627 
1628  // Exit:
1629 
1630  return result;
1631 }
1632 
1633 const void*
1635 row_dofs(bool xauto_access) const
1636 {
1637  // Preconditions:
1638 
1639  require(state_is_auto_read_accessible(xauto_access));
1640 
1641  // Body:
1642 
1643  if(xauto_access)
1644  {
1645  get_read_access();
1646  }
1647 
1648  const void* result = row_dofs();
1649 
1650  if(xauto_access)
1651  {
1652  release_access();
1653  }
1654 
1655  // Postconditions:
1656 
1657  // Exit:
1658 
1659  return result;
1660 }
1661 
1662 // PROTECTED MEMBER FUNCTIONS
1663 
1664 // PRIVATE MEMBER FUNCTIONS
1665 
1666 
1667 // ===========================================================
1668 // DOF ACCESS FACET
1669 // ===========================================================
1670 
1671 // PUBLIC MEMBER FUNCTIONS
1672 
1675 dof(pod_index_type xdof_id) const
1676 {
1677  // Preconditions:
1678 
1679  require(state_is_read_accessible());
1680  require(schema().row_dof_id_space().contains(xdof_id));
1681 
1682  // Body:
1683 
1684  primitive_value result = dof_map(false).dof(xdof_id);
1685 
1686  // Postconditions:
1687 
1688  // Exit:
1689 
1690  return result;
1691 }
1692 
1695 dof(const scoped_index& xdof_id, bool xauto_access) const
1696 {
1697  // Preconditions:
1698 
1699  require(state_is_auto_read_accessible(xauto_access));
1700  require(schema(xauto_access).row_dof_id_space(xauto_access).contains(xdof_id));
1701 
1702  // Body:
1703 
1704  if(xauto_access)
1705  {
1706  get_read_access();
1707  }
1708 
1709  primitive_value result = dof_map(false).dof(xdof_id);
1710 
1711  if(xauto_access)
1712  {
1713  release_access();
1714  }
1715 
1716  // Postconditions:
1717 
1718  // Exit:
1719 
1720  return result;
1721 }
1722 
1723 void
1726 {
1727  // Preconditions:
1728 
1729  require(state_is_read_write_accessible());
1730  require(schema().row_dof_id_space().contains(xdof_id));
1731  require(xdof.id() == schema().type(xdof_id, false));
1732 
1733  // Body:
1734 
1735  dof_map(true).put_dof(xdof_id, xdof);
1736 
1737  // Postconditions:
1738 
1739  ensure(dof(xdof_id) == xdof);
1740 
1741  // Exit:
1742 
1743  return;
1744 }
1745 
1746 void
1748 put_dof(const scoped_index& xdof_id, const primitive_value& xdof, bool xauto_access)
1749 {
1750  // Preconditions:
1751 
1752  require(state_is_auto_read_write_accessible(xauto_access));
1753  require(schema(xauto_access).row_dof_id_space(xauto_access).contains(xdof_id));
1754  require(xdof.id() == schema(xauto_access).type(xdof_id, false, xauto_access));
1755 
1756  // Body:
1757 
1758  if(xauto_access)
1759  {
1760  get_read_write_access(true);
1761  }
1762 
1763  dof_map(true).put_dof(xdof_id, xdof);
1764 
1765  if(xauto_access)
1766  {
1767  release_access();
1768  }
1769 
1770  // Postconditions:
1771 
1772  ensure(dof(xdof_id.hub_pod()) == xdof);
1773 
1774  // Exit:
1775 
1776  return;
1777 }
1778 
1779 void
1781 get_dof(pod_index_type xdof_id, void* xdof, size_type xdof_size) const
1782 {
1783  // Preconditions:
1784 
1785  require(state_is_read_accessible());
1786  require(schema().row_dof_id_space().contains(xdof_id));
1787  require(unexecutable("xdof points to buffer of size xdof_size"));
1788  require(xdof_size >= schema().size(xdof_id, false));
1789 
1790  // Body:
1791 
1792  dof_map(false).get_dof(xdof_id, xdof, xdof_size);
1793 
1794  // Postconditions:
1795 
1796  // Exit:
1797 
1798  return;
1799 }
1800 
1801 void
1803 get_dof(const scoped_index& xdof_id, void* xdof, size_type xdof_size, bool xauto_access) const
1804 {
1805  // Preconditions:
1806 
1807  require(state_is_auto_read_accessible(xauto_access));
1808  require(schema(xauto_access).row_dof_id_space(xauto_access).contains(xdof_id));
1809  require(unexecutable("xdof points to buffer of size xdof_size"));
1810  require(xdof_size >= schema(xauto_access).size(xdof_id, false, xauto_access));
1811 
1812  // Body:
1813 
1814  if(xauto_access)
1815  {
1816  get_read_access();
1817  }
1818 
1819  dof_map(false).get_dof(xdof_id, xdof, xdof_size);
1820 
1821  if(xauto_access)
1822  {
1823  release_access();
1824  }
1825 
1826  // Postconditions:
1827 
1828  // Exit:
1829 
1830  return;
1831 }
1832 
1833 void
1835 put_dof(pod_index_type xdof_id, const void* xdof, size_type xdof_size)
1836 {
1837  // Preconditions:
1838 
1839  require(state_is_read_write_accessible());
1840  require(schema().row_dof_id_space().contains(xdof_id));
1841  require(unexecutable("xdof points to buffer of size xdof_size"));
1842  require(xdof_size >= schema().size(xdof_id, false));
1843 
1844  // Body:
1845 
1846  dof_map(true).put_dof(xdof_id, xdof, xdof_size);
1847 
1848  // Postconditions:
1849 
1850  // Exit:
1851 
1852  return;
1853 }
1854 
1855 void
1857 put_dof(const scoped_index& xdof_id, const void* xdof, size_type xdof_size, bool xauto_access)
1858 {
1859  // Preconditions:
1860 
1861  require(state_is_auto_read_write_accessible(xauto_access));
1862  require(schema(xauto_access).row_dof_id_space(xauto_access).contains(xdof_id));
1863  require(unexecutable("xdof points to buffer of size xdof_size"));
1864  require(xdof_size >= schema(xauto_access).size(xdof_id, false, xauto_access));
1865 
1866  // Body:
1867 
1868  if(xauto_access)
1869  {
1870  get_read_write_access(true);
1871  }
1872 
1873  dof_map(true).put_dof(xdof_id, xdof, xdof_size);
1874 
1875  if(xauto_access)
1876  {
1877  release_access();
1878  }
1879 
1880  // Postconditions:
1881 
1882  // Exit:
1883 
1884  return;
1885 }
1886 
1887 // PROTECTED MEMBER FUNCTIONS
1888 
1889 // PRIVATE MEMBER FUNCTIONS
1890 
1891 
1892 // ===========================================================
1893 // ORDERING RELATION FACET
1894 // ===========================================================
1895 
1896 // PUBLIC MEMBER FUNCTIONS
1897 
1898 bool
1900 le(pod_index_type xother_index) const
1901 {
1902  bool result;
1903 
1904  // Preconditions:
1905 
1906  require(state_is_read_accessible());
1907  require(host()->contains_member(xother_index));
1908 
1909  // Body:
1910 
1911  result = _host->le(xother_index, _index.pod());
1912 
1913  // Postconditions:
1914 
1915  ensure(unexecutable(other is in the up set
1916  of this));
1917 
1918  // Exit
1919 
1920  return result;
1921 }
1922 
1923 bool
1925 le(const scoped_index& xother_index) const
1926 {
1927  bool result;
1928 
1929  // Preconditions:
1930 
1931  require(state_is_read_accessible());
1932  require(host()->contains_member(xother_index));
1933 
1934  // Body:
1935 
1936  result = le(xother_index.hub_pod());
1937 
1938  // Postconditions:
1939 
1940  ensure(unexecutable(other is in the up set
1941  of this));
1942 
1943  // Exit
1944 
1945  return result;
1946 }
1947 
1948 bool
1950 le(const abstract_poset_member* other) const
1951 {
1952  bool result;
1953 
1954  // Preconditions:
1955 
1956  require(state_is_read_accessible());
1957 
1958  // Body:
1959 
1960  result = has_same_host(other) && _host->le(other->index().pod(),
1961  _index.pod());
1962 
1963  // Postconditions:
1964 
1965  ensure(unexecutable(other is in the up set
1966  of this));
1967 
1968  // Exit
1969 
1970  return result;
1971 }
1972 
1973 bool
1975 leqv(pod_index_type xother_index) const
1976 {
1977  bool result;
1978 
1979  // Preconditions:
1980 
1981  require(state_is_read_accessible());
1982  require(host()->contains_member(xother_index));
1983 
1984  // Body:
1985 
1986  result = _host->leqv(xother_index, _index.pod());
1987 
1988  // Postconditions:
1989 
1990  ensure(unexecutable("other is in the up set of this or other is_jem(this)"));
1991 
1992  // Exit
1993 
1994  return result;
1995 }
1996 
1997 bool
1999 leqv(const scoped_index& xother_index) const
2000 {
2001  bool result;
2002 
2003  // Preconditions:
2004 
2005  require(state_is_read_accessible());
2006  require(host()->contains_member(xother_index));
2007 
2008  // Body:
2009 
2010  result = leqv(xother_index.hub_pod());
2011 
2012  // Postconditions:
2013 
2014  ensure(unexecutable("other is in the up set of this or other is_jem(this)"));
2015 
2016  // Exit
2017 
2018  return result;
2019 }
2020 
2021 bool
2023 lt(pod_index_type xother_index) const
2024 {
2025  bool result;
2026 
2027  // Preconditions:
2028 
2029  require(state_is_read_accessible());
2030  require(host()->contains_member(xother_index));
2031 
2032  // Body:
2033 
2034  result = le(xother_index) && (_index.pod() != xother_index);
2035 
2036  // Postconditions:
2037 
2038  ensure(result == (le(xother_index) && (index().pod() != xother_index)));
2039 
2040  // Exit
2041 
2042  return result;
2043 }
2044 
2045 bool
2047 lt(const scoped_index& xother_index) const
2048 {
2049  bool result;
2050 
2051  // Preconditions:
2052 
2053  require(state_is_read_accessible());
2054  require(host()->contains_member(xother_index));
2055 
2056  // Body:
2057 
2058  result = lt(xother_index.hub_pod());
2059 
2060  // Postconditions:
2061 
2062  ensure(result == (le(xother_index) && (index() !=~ xother_index)));
2063 
2064  // Exit
2065 
2066  return result;
2067 }
2068 
2069 bool
2071 lt(const abstract_poset_member* other) const
2072 {
2073  bool result;
2074 
2075  // Preconditions:
2076 
2077  require(state_is_read_accessible());
2078 
2079  // Body:
2080 
2081  result = le(other) && (_index != other->index());
2082 
2083  // Postconditions:
2084 
2085  ensure(result == (le(other) && (index() != other->index())));
2086 
2087  // Exit
2088 
2089  return result;
2090 }
2091 
2092 bool
2094 ge(pod_index_type xother_index) const
2095 {
2096  bool result;
2097 
2098  // Preconditions:
2099 
2100  require(state_is_read_accessible());
2101  require(host()->contains_member(xother_index));
2102 
2103  // Body:
2104 
2105  // This is >= other if other is <= this.
2106 
2107  result = _host->le(_index.pod(), xother_index);
2108 
2109  // Postconditions:
2110 
2111  ensure(unexecutable(other is in the up set
2112  of this));
2113 
2114  // Exit
2115 
2116  return result;
2117 }
2118 
2119 bool
2121 ge(const scoped_index& xother_index) const
2122 {
2123  bool result;
2124 
2125  // Preconditions:
2126 
2127  require(state_is_read_accessible());
2128  require(host()->contains_member(xother_index));
2129 
2130  // Body:
2131 
2132  result = ge(xother_index.hub_pod());
2133 
2134  // Postconditions:
2135 
2136  ensure(unexecutable(other is in the up set
2137  of this));
2138 
2139  // Exit
2140 
2141  return result;
2142 }
2143 
2144 bool
2146 ge(const abstract_poset_member* other) const
2147 {
2148  bool result;
2149 
2150  // Preconditions:
2151 
2152  require(state_is_read_accessible());
2153 
2154  // Body:
2155 
2156  // This is >= other if other is <= this.
2157 
2158  result = has_same_host(other) && _host->le(_index.pod(),
2159  other->index().pod());
2160 
2161  // Postconditions:
2162 
2163  ensure(unexecutable(other is in the up set
2164  of this));
2165 
2166  // Exit
2167 
2168  return result;
2169 }
2170 
2171 bool
2173 geqv(pod_index_type xother_index) const
2174 {
2175  bool result;
2176 
2177  // Preconditions:
2178 
2179  require(state_is_read_accessible());
2180  require(host()->contains_member(xother_index));
2181 
2182  // Body:
2183 
2184  // This is >= other if other is <= this.
2185 
2186  result = _host->leqv(_index.pod(), xother_index);
2187 
2188  // Postconditions:
2189 
2190  ensure(unexecutable("this is in the up set of other or this is_jem of other"));
2191 
2192  // Exit
2193 
2194  return result;
2195 }
2196 
2197 bool
2199 geqv(const scoped_index& xother_index) const
2200 {
2201  bool result;
2202 
2203  // Preconditions:
2204 
2205  require(state_is_read_accessible());
2206  require(host()->contains_member(xother_index));
2207 
2208  // Body:
2209 
2210  result = geqv(xother_index.hub_pod());
2211 
2212  // Postconditions:
2213 
2214  ensure(unexecutable("this is in the up set of other or this is_jem of other"));
2215 
2216  // Exit
2217 
2218  return result;
2219 }
2220 
2221 bool
2223 gt(pod_index_type xother_index) const
2224 {
2225  bool result;
2226 
2227  // Preconditions:
2228 
2229  require(state_is_read_accessible());
2230  require(host()->contains_member(xother_index));
2231 
2232  // Body:
2233 
2234  result = ge(xother_index) && (_index.pod() != xother_index);
2235 
2236  // Postconditions:
2237 
2238  ensure(result == (ge(xother_index) && (index().pod() != xother_index)));
2239 
2240  // Exit
2241 
2242  return result;
2243 }
2244 
2245 bool
2247 gt(const scoped_index& xother_index) const
2248 {
2249  bool result;
2250 
2251  // Preconditions:
2252 
2253  require(state_is_read_accessible());
2254  require(host()->contains_member(xother_index));
2255 
2256  // Body:
2257 
2258  result = ge(xother_index.hub_pod());
2259 
2260  // Postconditions:
2261 
2262  ensure(result == (ge(xother_index) && (index() !=~ xother_index)));
2263 
2264  // Exit
2265 
2266  return result;
2267 }
2268 
2269 bool
2271 gt(const abstract_poset_member* other) const
2272 {
2273  bool result;
2274 
2275  // Preconditions:
2276 
2277  require(state_is_read_accessible());
2278 
2279  // Body:
2280 
2281  result = ge(other) && (_index != other->index());
2282 
2283  // Postconditions:
2284 
2285  ensure(result == (ge(other) && (index() != other->index())));
2286 
2287  // Exit
2288 
2289  return result;
2290 }
2291 
2292 bool
2294 is_jem(const abstract_poset_member* xother) const
2295 {
2296  bool result;
2297 
2298  // Preconditions:
2299 
2300  require(state_is_read_accessible());
2301 
2302  // Body:
2303 
2304  result = _host->is_jem( index(), xother->index() );
2305 
2306  // Postconditions:
2307 
2308  // Exit
2309 
2310  return result;
2311 }
2312 
2316 {
2317  abstract_poset_member* result;
2318 
2319  // Preconditions:
2320 
2321  require(state_is_read_accessible());
2322 
2323  // Body:
2324 
2325  result = clone();
2326  greatest_jem_pa(result);
2327 
2328  // Postconditions:
2329 
2330  ensure(result != 0);
2331  ensure(result->is_same_type(this));
2332 
2333  // Exit
2334 
2335  return result;
2336 }
2337 
2338 void
2341 {
2342 
2343  // Preconditions:
2344 
2345  require(state_is_read_accessible());
2346  require(result->is_ancestor_of(this));
2347 
2348  // Body:
2349 
2350  result->attach_to_state(_host, _host->greatest_jem(_index.pod()));
2351 
2352  // Postconditions:
2353 
2354  // Exit
2355 
2356  return;
2357 }
2358 
2361 least_jem() const
2362 {
2363  abstract_poset_member* result;
2364 
2365  // Preconditions:
2366 
2367  require(state_is_read_accessible());
2368 
2369  // Body:
2370 
2371  result = clone();
2372  least_jem_pa(result);
2373 
2374  // Postconditions:
2375 
2376  ensure(result != 0);
2377  ensure(result->is_same_type(this));
2378 
2379  // Exit
2380 
2381  return result;
2382 }
2383 
2384 void
2387 {
2388 
2389  // Preconditions:
2390 
2391  require(state_is_read_accessible());
2392  require(result->is_ancestor_of(this));
2393 
2394  // Body:
2395 
2396  result->attach_to_state(_host, _host->least_jem(_index.pod()));
2397 
2398  // Postconditions:
2399 
2400  // Exit
2401 
2402  return;
2403 }
2404 
2405 void
2408 {
2409 
2410  // Preconditions:
2411 
2412  require(has_same_host(xjem));
2413  require(!xjem->is_jem(&(host()->bottom())));
2414  require(state_is_read_write_accessible());
2415  require(!is_jim());
2416  require(!xjem->is_jim());
2417  require(unexecutable(xjem really is join-equivalent to this));
2418 
2419  // Body:
2420 
2421  _host->merge_jems(_index.pod(), xjem->index().pod());
2422 
2423  // Postconditions:
2424 
2425  ensure(is_jem(xjem));
2426  ensure(xjem->le(this));
2427 
2428  // Exit
2429 
2430  return;
2431 }
2432 
2433 // PROTECTED MEMBER FUNCTIONS
2434 
2435 // PRIVATE MEMBER FUNCTIONS
2436 
2437 
2438 // ===========================================================
2439 // COVER RELATION FACET
2440 // ===========================================================
2441 
2442 // PUBLIC MEMBER FUNCTIONS
2443 
2444 bool
2446 covers(const abstract_poset_member* xother) const
2447 {
2448  bool result = false;
2449 
2450  // Preconditions:
2451 
2452  require(xother->host() == host());
2453  require(state_is_read_accessible());
2454 
2455  // Body:
2456 
2457  result = host()->contains_link(_index.pod(), xother->index().pod());
2458 
2459  // Postconditions:
2460 
2461  // Exit
2462 
2463  return result;
2464 }
2465 
2466 bool
2468 covers(pod_index_type xhub_id) const
2469 {
2470  bool result = false;
2471 
2472  // Preconditions:
2473 
2474  require(state_is_read_accessible());
2475  require(host()->contains_member(xhub_id));
2476 
2477  // Body:
2478 
2479  result = host()->contains_link(_index.pod(), xhub_id);
2480 
2481  // Postconditions:
2482 
2483  // Exit
2484 
2485  return result;
2486 }
2487 
2488 bool
2490 covers(const scoped_index& xid) const
2491 {
2492  // Preconditions:
2493 
2494  require(state_is_read_accessible());
2495  require(host()->contains_member(xid));
2496 
2497  // Body:
2498 
2499  return covers(xid.hub_pod());
2500 }
2501 
2502 void
2505 {
2506 
2507  // Preconditions:
2508 
2509  require(state_is_read_write_accessible());
2510  require(host()->in_jim_edit_mode());
2511  require(has_same_host(xlesser));
2512 
2515 
2516  // ensure acyclic and intransitive
2517  require(!le(xlesser) && !xlesser->le(this));
2518 
2519 
2520  // Body:
2521 
2522  (void) _host->new_link(_index.pod(), xlesser->index().pod());
2523 
2524  // Postconditions:
2525 
2526  ensure(invariant());
2527  ensure(covers(xlesser));
2528 
2529  return;
2530 }
2531 
2532 void
2535 {
2536  // Preconditions:
2537 
2538  require(state_is_read_write_accessible());
2539  require(host()->in_jim_edit_mode());
2540 
2543 
2544  // Body:
2545 
2546  _host->delete_link(_index.pod(), xlesser->index().pod());
2547 
2548  // Postconditions:
2549 
2550  ensure(invariant());
2551  ensure(!covers(xlesser));
2552 
2553  // Exit
2554 
2555  return;
2556 }
2557 
2560 get_cover_id_space(bool xlower) const
2561 {
2562  // Preconditions:
2563 
2564  require(state_is_read_accessible());
2565 
2566  // Body:
2567 
2568  return _host->get_cover_id_space(xlower, _index.pod());
2569 }
2570 
2571 void
2574 {
2575  // Preconditions:
2576 
2577  require(state_is_read_accessible());
2578 
2579  // Body:
2580 
2581  _host->release_cover_id_space(xcover_id_space);
2582 
2583  // Postconditions:
2584 
2585  // Exit:
2586 
2587  return;
2588 }
2589 
2593 {
2594  // Preconditions:
2595 
2596  require(state_is_read_accessible());
2597 
2598  // Body:
2599 
2600  return _host->get_cover_id_space_iterator(xlower, _index.pod());
2601 }
2602 
2603 void
2606 {
2607  // Preconditions:
2608 
2609  require(state_is_read_accessible());
2610 
2611  // Body:
2612 
2613  _host->release_cover_id_space_iterator(xitr);
2614 
2615  // Postconditions:
2616 
2617  // Exit:
2618 
2619  return;
2620 }
2621 
2622 bool
2624 cover_contains_iterator(bool xlower, const index_space_iterator& xitr) const
2625 {
2626  // Preconditions:
2627 
2628  require(state_is_read_accessible());
2629 
2630  // Body
2631 
2632  return _host->cover_contains_iterator(xlower, _index.pod(), xitr);
2633 }
2634 
2635 bool
2637 cover_is_empty(bool xlower) const
2638 {
2639  // Preconditions:
2640 
2641  require(state_is_read_accessible());
2642 
2643  return _host->cover_is_empty(xlower, _index.pod());
2644 }
2645 
2646 bool
2648 cover_is_singleton(bool xlower) const
2649 {
2650  bool result;
2651 
2652  // Preconditions:
2653 
2654  require(state_is_read_accessible());
2655 
2656  return _host->cover_is_singleton(xlower, _index.pod());
2657 }
2658 
2661 cover_ct(bool xlower) const
2662 {
2663  int result;
2664 
2665  // Preconditions:
2666 
2667  require(state_is_read_accessible());
2668 
2669  // Body:
2670 
2671  result = _host->cover_ct(xlower, _index.pod());
2672 
2673  // Postconditions:
2674 
2675  ensure(result >= 0);
2676 
2677  // Exit
2678 
2679  return result;
2680 }
2681 
2682 bool
2684 cover_contains_member(bool xlower, pod_index_type xother_mbr_index) const
2685 {
2686  // Preconditions:
2687 
2688  require(state_is_read_accessible());
2689 
2690  return _host->cover_contains_member(xlower, _index.pod(), xother_mbr_index);
2691 }
2692 
2693 bool
2695 cover_contains_member(bool xlower, const scoped_index& xother_mbr_index) const
2696 {
2697  // Preconditions:
2698 
2699  require(state_is_read_accessible());
2700 
2701  return cover_contains_member(xlower, xother_mbr_index.hub_pod());
2702 }
2703 
2704 bool
2706 cover_is_equal(bool xlower, pod_index_type xother_mbr_index) const
2707 {
2708  // Preconditions:
2709 
2710  require(state_is_read_accessible());
2711 
2712  return _host->cover_is_equal(xlower, _index.pod(), xother_mbr_index);
2713 }
2714 
2715 bool
2717 cover_is_equal(bool xlower, const scoped_index& xother_mbr_index) const
2718 {
2719  // Preconditions:
2720 
2721  require(state_is_read_accessible());
2722 
2723  return cover_is_equal(xlower, xother_mbr_index.hub_pod());
2724 }
2725 
2728 first_cover_member(bool xlower) const
2729 {
2730  // Preconditions:
2731 
2732  require(state_is_read_accessible());
2733 
2734  return _host->first_cover_member(xlower, _index.pod());
2735 }
2736 
2737 void
2739 first_cover_member(bool xlower, scoped_index& result) const
2740 {
2741  // Preconditions:
2742 
2743  require(state_is_read_accessible());
2744 
2745  result.put(_host->member_hub_id_space(false), first_cover_member(xlower));
2746 }
2747 
2748 void
2750 insert_cover_member(pod_index_type xother_mbr_index, bool xlower)
2751 {
2752  // Preconditions:
2753 
2754  require(state_is_read_write_accessible());
2755 
2756  // Body:
2757 
2758  _host->insert_cover_member(xother_mbr_index, xlower, _index.pod());
2759 
2760  // Postconditions:
2761 
2762  ensure(unexecutable(cover_contains_member(xlower, xother_mbr_index)));
2763 
2764  // Exit:
2765 
2766  return;
2767 }
2768 
2769 void
2771 insert_cover_member(const scoped_index& xother_mbr_index, bool xlower)
2772 {
2773  // Preconditions:
2774 
2775  require(state_is_read_write_accessible());
2776 
2777  // Body:
2778 
2779  insert_cover_member(xother_mbr_index.hub_pod(), xlower);
2780 
2781  // Postconditions:
2782 
2783  ensure(unexecutable(cover_contains_member(xlower, xother_mbr_index)));
2784 
2785  // Exit:
2786 
2787  return;
2788 }
2789 
2790 void
2792 remove_cover_member(pod_index_type xother_mbr_index, bool xlower)
2793 {
2794  // Preconditions:
2795 
2796  require(state_is_read_write_accessible());
2797 
2798  // Body:
2799 
2800  _host->remove_cover_member(xother_mbr_index, xlower, _index.pod());
2801 
2802  // Postconditions:
2803 
2804  ensure(unexecutable(!cover_contains_member(xlower, xother_mbr_index)));
2805 
2806  // Exit:
2807 
2808  return;
2809 }
2810 
2811 void
2813 remove_cover_member(const scoped_index& xother_mbr_index, bool xlower)
2814 {
2815  // Preconditions:
2816 
2817  require(state_is_read_write_accessible());
2818 
2819  // Body:
2820 
2821  remove_cover_member(xother_mbr_index.hub_pod(), xlower);
2822 
2823  // Postconditions:
2824 
2825  ensure(unexecutable(!cover_contains_member(xlower, xother_mbr_index)));
2826 
2827  // Exit:
2828 
2829  return;
2830 }
2831 
2832 void
2835 {
2836  // Preconditions:
2837 
2838  require(state_is_read_write_accessible());
2839 
2840  // Body:
2841 
2842  _host->remove_cover_member(xitr, xlower, _index.pod());
2843 
2844  // Postconditions:
2845 
2846  ensure(unexecutable(!cover_contains_member(xlower, xother_mbr_index)));
2847 
2848  // Exit:
2849 
2850  return;
2851 }
2852 
2853 void
2855 clear_cover(bool xlower)
2856 {
2857  // Preconditions:
2858 
2859  require(state_is_read_write_accessible());
2860 
2861  // Body:
2862 
2863  _host->clear_cover(xlower, _index.pod());
2864 
2865  // Postconditions:
2866 
2867  ensure(cover_is_empty(xlower));
2868 
2869  // Exit:
2870 
2871  return;
2872 }
2873 
2874 void
2876 copy_cover(bool xlower, pod_index_type xother_mbr_index)
2877 {
2878  // Preconditions:
2879 
2880  require(state_is_read_write_accessible());
2881  require(host()->contains_member(xother_mbr_index));
2882 
2883  // Body:
2884 
2885  _host->copy_cover(xlower, _index.pod(), xother_mbr_index);
2886 
2887  // Postconditions:
2888 
2889  ensure(cover_is_equal(xlower, xother_mbr_index));
2890 
2891  // Exit:
2892 
2893  return;
2894 }
2895 
2896 void
2898 copy_cover(bool xlower, const scoped_index& xother_mbr_index)
2899 {
2900  // Preconditions:
2901 
2902  require(state_is_read_write_accessible());
2903  require(host()->contains_member(xother_mbr_index));
2904 
2905  // Body:
2906 
2907  copy_cover(xlower, xother_mbr_index.hub_pod());
2908 
2909  // Postconditions:
2910 
2911  ensure(cover_is_equal(xlower, xother_mbr_index));
2912 
2913  // Exit:
2914 
2915  return;
2916 }
2917 
2918 // PROTECTED MEMBER FUNCTIONS
2919 
2920 // PRIVATE MEMBER FUNCTIONS
2921 
2922 
2923 // ===========================================================
2924 // DOWN SET FACET
2925 // ===========================================================
2926 
2927 // PUBLIC MEMBER FUNCTIONS
2928 
2929 int
2931 down_ct() const
2932 {
2933  // Preconditions:
2934 
2935  // Body:
2936 
2937  int result = down_ct(WHOLE_INDEX);
2938 
2939  // Postconditions:
2940 
2941  ensure(result > 0 );
2942 
2943  // Exit
2944 
2945  return result;
2946 }
2947 
2948 int
2950 down_ct(pod_index_type xfilter_index) const
2951 {
2952  int result = 0;
2953 
2954  // Preconditions:
2955 
2956  // Body:
2957 
2958  // Traverse down set
2959 
2960  zn_to_bool_postorder_itr itr(*this, xfilter_index, DOWN, NOT_STRICT);
2961  while(!itr.is_done())
2962  {
2963  result++;
2964  itr.next();
2965  }
2966 
2967  // Postconditions:
2968 
2969  ensure(result >= 0 );
2970 
2971  // Exit
2972 
2973  return result;
2974 }
2975 
2976 int
2978 down_ct(const scoped_index& xfilter_index) const
2979 {
2980  int result = 0;
2981 
2982  // Preconditions:
2983 
2984  // Body:
2985 
2986  result = down_ct(xfilter_index.hub_pod());
2987 
2988  // Postconditions:
2989 
2990  ensure(result > 0 );
2991 
2992  // Exit
2993 
2994  return result;
2995 }
2996 
2999 down() const
3000 {
3001  subposet* result;
3002 
3003  // Preconditions:
3004 
3005  require(state_is_read_write_accessible());
3006 
3007  // Body:
3008 
3009  result = new subposet(host(), 0, false);
3010  down_pa(result);
3011 
3012 
3013  // Postconditions:
3014 
3015  require(result != 0);
3016  require(postcondition_of(down_pa));
3017 
3018  // Exit
3019 
3020  return result;
3021 }
3022 
3023 void
3025 down_pa(subposet* result) const
3026 {
3027 
3028  // Preconditions:
3029 
3030  // Body:
3031 
3032  // Traverse down set, inserting members into result
3033 
3034  poset_slicer slicer(_host);
3035  abstract_poset_member* cthis = const_cast<abstract_poset_member*>(this);
3036  slicer.down_set_pa(cthis, result);
3037 
3038  // Postconditions:
3039 
3040  ensure(result->invariant());
3041  ensure(unexecutable(result is down set
3042  of this));
3043 
3044  // Exit
3045 
3046  return;
3047 }
3048 
3049 void
3051 delete_down(bool xdelete_exterior, bool xenter_jim_edit_mode)
3052 {
3053  // Preconditions:
3054 
3055  require(state_is_read_write_accessible());
3056  require(!xenter_jim_edit_mode ? host()->in_jim_edit_mode() : true);
3057  require(!name().empty());
3058  require(host()->contains_member(poset_path::boundary_name(name())));
3059  require(host()->includes_subposet("__boundary_jims"));
3060 
3061  // Body:
3062 
3063  poset_state_handle* lhost = host();
3064  bool old_host_in_jim_edit_mode = lhost->in_jim_edit_mode();
3065 
3066  if(!old_host_in_jim_edit_mode)
3067  {
3068  lhost->begin_jim_edit_mode();
3069  }
3070 
3071  // Block containing a single element is a special case:
3072 
3073  total_poset_member lbdy(host(), poset_path::boundary_name(name()));
3074  pod_index_type lblock_bdy_index = lbdy.index().pod();
3075 
3076  subposet lelements(lhost, "__elements");
3077  if(_host->cover_is_singleton(LOWER, _index.pod()))
3078  {
3079  pod_index_type lfirst_mbr = lhost->first_cover_member(LOWER, _index.pod());
3080  if(lelements.contains_member(lfirst_mbr))
3081  {
3082  // This block contains only a single element.
3083  // The block doesn't cover the boundary, the element does.
3084  // The algorithm below depends on the block covering the
3085  // boundary, so explicitly delete the element and
3086  // attach the boundary to the block.
3087 
3088  total_poset_member lele(lhost, lfirst_mbr);
3089  lele.delete_state();
3090  create_cover_link(&lbdy);
3091  }
3092  }
3093 
3094  lelements.detach_from_state();
3095  lbdy.detach_from_state();
3096 
3097  // The down set traversal:
3098  // Mark the members of the down set.
3099 
3100  zn_to_bool ldown_set(lhost->member_index_ub().pod());
3101  zn_to_bool_postorder_itr down_itr(*this, DOWN, NOT_STRICT);
3102  while(!down_itr.is_done())
3103  {
3104  ldown_set.put(down_itr.index().pod(), true);
3105  down_itr.next();
3106  }
3107 
3108  // The lower cover traversal:
3109  // Initialize the deletion traversal by removing the
3110  // links from this to the internal members of its lower cover.
3111  // A member is internal if this is the only member of its
3112  // upper cover and it is not the block boundary.
3113 
3114  index_space_iterator& lc_itr = _host->get_cover_id_space_iterator(LOWER, _index.pod());
3115  while(!lc_itr.is_done())
3116  {
3117  pod_index_type lindex = lc_itr.hub_pod();
3118 
3119  if(_host->cover_is_singleton(UPPER, lindex) &&
3120  (xdelete_exterior || (lindex != lblock_bdy_index)))
3121  {
3122  // This is an internal member of the lower cover.
3123  // Delete the only entry in its upper cover.
3124 
3125  _host->clear_cover(UPPER, lindex);
3126 
3127  // The upper cover should now be empty.
3128  // This is essential for the deletion algorithm.
3129 
3130  assertion(_host->cover_is_empty(UPPER, lindex));
3131 
3132  // Delete the entry from the lower cover of this.
3133 
3134  // Note that remove_cover_member invalidates the itr
3135  // passed to it, but the postfix increment passes a copy of lc_itr.
3136 
3137  _host->remove_cover_member(lc_itr, LOWER, _index.pod());
3138  }
3139 
3140  lc_itr.next();
3141  }
3142  _host->release_cover_id_space_iterator(lc_itr);
3143 
3144  // The deletion traversal:
3145  // Traverse the poset in postorder up from the bottom.
3146  // The actions are defined to detect internal members,
3147  // delete them, and remove them from the up set of bottom.
3148 
3149  subposet lbdy_jims(lhost, "__boundary_jims");
3150  set<pod_index_type> lclean_up_set;
3151  zn_to_bool lin_other_down_set(lhost->member_index_ub().pod());
3152  scoped_index lanchor = index();
3153  bool lnot_in_down_set = false;
3154 
3155  zn_to_bool_triorder_itr up_itr(lhost->bottom(), UP, NOT_STRICT);
3156  while(!up_itr.is_done())
3157  {
3158  const scoped_index& lindex = up_itr.index();
3159 
3160  switch(up_itr.action())
3161  {
3162  case zn_to_bool_triorder_itr::PREVISIT_ACTION:
3163 
3164  lnot_in_down_set = !ldown_set[lindex.pod()];
3165 
3166  if(lnot_in_down_set)
3167  {
3168  // The current member is not in the down set
3169  // of this, so it is in the down set of some
3170  // other block.
3171 
3172  lin_other_down_set.put(lindex.pod(), true);
3173  }
3174 
3175  // Don't need to go deeper if the current
3176  // member is not in the down set or if we're at this.
3177 
3178  up_itr.next(lnot_in_down_set || (lindex ==~ lanchor));
3179 
3180  break;
3181 
3182  case zn_to_bool_triorder_itr::LINK_ACTION:
3183 
3184  if(!lhost->contains_member(up_itr.lesser_index()))
3185  {
3186  // We've previously deleted the upper member of the link.
3187 
3188  // Remove it from the upper cover of the greater member.
3189  // Note that this is an ascending traversal, so
3190  // greater and lesser with respect to the link are
3191  // reversed with respect to the ordering relation.
3192  // The lesser member is the upper member.
3193 
3194  up_itr.erase_cover();
3195  }
3196  else
3197  {
3198  // The upper member of the link still exists.
3199 
3200  if(lin_other_down_set[up_itr.lesser_index().pod()])
3201  {
3202  // The lower member is in the other down set if
3203  // any member of its upper cover is.
3204 
3205  lin_other_down_set.put(lindex.pod(), true);
3206  }
3207 
3208  }
3209 
3210  up_itr.next();
3211  break;
3212 
3213  case zn_to_bool_triorder_itr::POSTVISIT_ACTION:
3214 
3215  if(lhost->cover_is_empty(UPPER, lindex))
3216  {
3217  // The entire upper cover of the current member
3218  // has been deleted, so it must be an internal member.
3219  // If it is not the bottom, delete it.
3220 
3221  if(lindex != BOTTOM_INDEX)
3222  {
3223  lhost->delete_member(lindex);
3224  }
3225  }
3226  else if(lbdy_jims.contains_member(lindex) &&
3227  lin_other_down_set[lindex.pod()] &&
3228  ldown_set[lindex.pod()])
3229  {
3230  // This boundary jim is shared with another block
3231  // and hence is not external. We'll delete it,
3232  // but first we have to save its upper cover for
3233  // clean up later.
3234 
3235  index_space_iterator& uc_itr = _host->get_cover_id_space_iterator(UPPER, lindex);
3236  while(!uc_itr.is_done())
3237  {
3238  lclean_up_set.insert(uc_itr.hub_pod());
3239 
3240  // Note that remove_cover_member invalidates the itr
3241  // passed to it, but the postfix increment passes a copy of lc_itr.
3242 
3243  _host->remove_cover_member(uc_itr, UPPER, lindex);
3244 
3245  uc_itr.next();
3246  }
3247  _host->release_cover_id_space_iterator(uc_itr);
3248 
3249  lhost->delete_member(lindex);
3250  }
3251 
3252  up_itr.next();
3253  break;
3254  }
3255  }
3256 
3257  lbdy_jims.detach_from_state();
3258 
3259  // Clean up the lower covers of the members
3260  // we have deleted boundary jims from.
3261 
3262  set<pod_index_type>::iterator cu_itr = lclean_up_set.begin();
3263  while(cu_itr != lclean_up_set.end())
3264  {
3265  index_space_iterator& lc_itr = _host->get_cover_id_space_iterator(LOWER, *cu_itr);
3266  while(!lc_itr.is_done())
3267  {
3268  if(!lhost->contains_member(lc_itr.hub_pod()))
3269  {
3270  // This member has been deleted, remove it from the lower cover.
3271  // Note tha remove_cover_member invalidates the iterator passed
3272  // to it, but the postfix increment operator passes a copy.
3273 
3274  _host->remove_cover_member(lc_itr, LOWER, *cu_itr);
3275  }
3276 
3277  lc_itr.next();
3278  }
3279  _host->release_cover_id_space_iterator(lc_itr);
3280 
3281  cu_itr++;
3282  }
3283 
3284  // Clean up this member itself.
3285 
3286  // We've removed the interior of this member.
3287  // There are two interpretations depending on whether
3288  // this member was ever a jim or not.
3289 
3290  if(is_jim(false))
3291  {
3292  // This member was originally a jim. Its interior
3293  // constitued a refinement and we've now unrefined it.
3294  // In order to maintain the semantics of this and its place in the
3295  // order relation, this must now go back to being a jim.
3296 
3297  lhost->jims().insert_member(this);
3298  }
3299  else if(lhost->cover_is_empty(LOWER, _index.pod()))
3300  {
3301  // This member was always a jrm, defined by the join
3302  // of its down set. The down set is now empty, so this
3303  // must be join-equivalent to the bottom.
3304 
3306 
3307  create_cover_link(&(lhost->bottom()));
3308 
3311  }
3312 
3313  // Restore jim edit mode.
3314 
3315  if(!old_host_in_jim_edit_mode)
3316  {
3317  lhost->end_jim_edit_mode();
3318  }
3319 
3320  // Postconditions:
3321 
3322  define_old_variable(poset_state_handle* old_host = lhost);
3323 
3324  ensure(old_host->in_jim_edit_mode() == old_host_in_jim_edit_mode);
3325 
3326  // Exit:
3327 
3328  return;
3329 }
3330 
3331 int
3333 up_ct() const
3334 {
3335  // Preconditions:
3336 
3337  // Body:
3338 
3339  int result = up_ct(WHOLE_INDEX);
3340 
3341  // Postconditions:
3342 
3343  ensure(result > 0 );
3344 
3345  // Exit
3346 
3347  return result;
3348 }
3349 
3350 int
3352 up_ct(pod_index_type xfilter_index) const
3353 {
3354  int result = 0;
3355 
3356  // Preconditions:
3357 
3358  // Body:
3359 
3360  // Traverse up set, including top
3361 
3362  zn_to_bool_postorder_itr itr(*this, xfilter_index, sheaf::UP);
3363  while(!itr.is_done())
3364  {
3365  result++;
3366  itr.next();
3367  }
3368 
3369  // Postconditions:
3370 
3371  ensure(result > 0 );
3372 
3373  // Exit
3374 
3375  return result;
3376 }
3377 
3378 int
3380 up_ct(const scoped_index& xfilter_index) const
3381 {
3382  int result = 0;
3383 
3384  // Preconditions:
3385 
3386  // Body:
3387 
3388  result = up_ct(xfilter_index.hub_pod());
3389 
3390  // Postconditions:
3391 
3392  ensure(result > 0 );
3393 
3394  // Exit
3395 
3396  return result;
3397 }
3398 
3401 up() const
3402 {
3403  subposet* result;
3404 
3405  // Preconditions:
3406 
3407  require(state_is_read_write_accessible());
3408 
3409  // Body:
3410 
3411  result = new subposet(host(), 0, false);
3412  up_pa(result);
3413 
3414  // Postconditions:
3415 
3416  ensure(result != 0);
3417  ensure(postcondition_of(up_pa));
3418 
3419  // Exit
3420 
3421  return result;
3422 }
3423 
3424 
3425 void
3427 up_pa(subposet* result) const
3428 {
3429  // Preconditions:
3430 
3431  // Body:
3432 
3433  // Traverse up set, inserting members into result
3434 
3436  not_implemented();
3437 
3438  // Postconditions:
3439 
3440  ensure(result->invariant());
3441  ensure(unexecutable(result is up set
3442  of this));
3443 
3444  // Exit
3445 
3446  return;
3447 }
3448 
3449 int
3451 jim_ct() const
3452 {
3453  // Preconditions:
3454 
3455  // Body:
3456 
3457  zn_to_bool_postorder_itr itr(*this, host()->jims(), DOWN, NOT_STRICT);
3458  int result = itr.ct();
3459 
3460  // Postconditions:
3461 
3462  ensure(is_jem(&(host()->bottom())) ? result == 0 : result > 0 );
3463 
3464  // Exit
3465 
3466  return result;
3467 }
3468 
3472 {
3473  subposet* result;
3474 
3475  // Preconditions:
3476 
3477  require(state_is_read_write_accessible());
3478 
3479  // Body:
3480 
3481  result = new subposet(host(), 0, false);
3482  jims_pa(result);
3483 
3484  // Postconditions:
3485 
3486  ensure(result != 0);
3487  ensure(postcondition_of(jims_pa));
3488 
3489  // Exit
3490 
3491  return result;
3492 }
3493 
3494 void
3497 {
3498 
3499  // Preconditions:
3500 
3501  require(state_is_read_write_accessible());
3502 
3503  // Body:
3504 
3505  // Traverse down set, inserting jims into result
3506 
3507  poset_slicer slicer(_host);
3508  slicer.find_jims_pa(this, result);
3509 
3510  // Postconditions:
3511 
3512  ensure(result->invariant());
3513  ensure(unexecutable(result is jims set
3514  of this));
3515 
3516  // Exit
3517 
3518  return;
3519 }
3520 
3521 int
3524 {
3525  int result = 0;
3526 
3527  // Preconditions:
3528 
3529  // Body:
3530 
3531  // Don't have an iterator for the maximal jims yet
3534 
3535  abstract_poset_member* cthis = const_cast<abstract_poset_member*>(this);
3536  subposet* lmax_jims = cthis->maximal_jims();
3537  result = lmax_jims->member_ct();
3538  delete lmax_jims;
3539 
3540  // Postconditions:
3541 
3542  ensure(is_jem(&(host()->bottom())) ? result == 0 : result > 0 );
3543 
3544  // Exit
3545 
3546  return result;
3547 }
3548 
3549 // Issue is that this ultimately requires poset_slicer::find_pa() to be const
3550 // yet this member sets attributes so it can't be const.
3551 
3555 {
3556  subposet* result;
3557 
3558  // Preconditions:
3559 
3560  require(state_is_read_write_accessible());
3561 
3562  // Body:
3563 
3564  result = new subposet(host(), 0, false);
3565  maximal_jims_pa(result);
3566 
3567  // Postconditions:
3568 
3569  ensure(has_same_host(result));
3570  ensure(postcondition_of(maximal_jims_pa));
3571 
3572  // Exit
3573 
3574  return result;
3575 }
3576 
3577 void
3580 {
3581 
3582  // Preconditions:
3583 
3584  require(has_same_host(result));
3585 
3586  // Body:
3587 
3588  abstract_poset_member* cthis = const_cast<abstract_poset_member*>(this);
3589 
3590  if(is_jim())
3591  {
3592  // This member is a jim, hence it is the only
3593  // member of its set of maximal jims
3594 
3595  result->insert_member(cthis);
3596  }
3597  else
3598  {
3599  // Traverse down set, inserting maximal jims into result
3600 
3601  poset_slicer slicer(_host);
3602  slicer.find_jims_pa( cthis, result, poset_slicer::MAXIMAL );
3603  }
3604 
3605  // Postconditions:
3606 
3607  ensure(result->invariant());
3608  ensure(unexecutable(result is union of maximal_jims of this with old result));
3609 
3610  // Exit
3611 
3612  return;
3613 }
3614 
3615 int
3617 atom_ct() const
3618 {
3619  int result = 0;
3620 
3621  // Preconditions:
3622 
3623  // Body:
3624 
3626  while(!itr.is_done())
3627  {
3628  if(host()->is_atom(itr.index()))
3629  {
3630  result++;
3631  itr.truncate();
3632  }
3633  else
3634  {
3635  itr.next();
3636  }
3637  }
3638 
3639  // Postconditions:
3640 
3641  ensure(is_same_state(&(host()->bottom())) ? result == 0 : result > 0 );
3642 
3643  // Exit
3644 
3645  return result;
3646 }
3647 
3650 atoms() const
3651 {
3652  subposet* result;
3653 
3654  // Preconditions:
3655 
3656  require(state_is_read_write_accessible());
3657 
3658  // Body:
3659 
3660  result = new subposet(host(), 0, false);
3661  atoms_pa(result);
3662 
3663  // Postconditions:
3664 
3665  ensure(result != 0);
3666  ensure(postcondition_of(atoms_pa));
3667 
3668  // Exit
3669 
3670  return result;
3671 }
3672 
3673 void
3675 atoms_pa(subposet* result) const
3676 {
3677  // Preconditions:
3678 
3679  require(state_is_read_write_accessible());
3680 
3681  // Body:
3682 
3684  while(!itr.is_done())
3685  {
3686  if(host()->is_atom(itr.index()))
3687  {
3688  result->insert_member(itr.index());
3689  itr.truncate();
3690  }
3691  else
3692  {
3693  itr.next();
3694  }
3695  }
3696 
3697  // Postconditions:
3698 
3699  ensure(result->invariant());
3700  ensure(unexecutable("for all members p of result: p.is_atom()"));
3701 
3702  // Exit
3703 
3704  return;
3705 }
3706 
3707 // PROTECTED MEMBER FUNCTIONS
3708 
3709 // PRIVATE MEMBER FUNCTIONS
3710 
3711 
3712 // ===========================================================
3713 // POSET ALGEBRA FACET
3714 // ===========================================================
3715 
3716 // PUBLIC MEMBER FUNCTIONS
3717 
3721 {
3722  abstract_poset_member* result;
3723 
3724  // Preconditions:
3725 
3726  require(has_same_host(other));
3727  require(state_is_read_accessible());
3728 
3729  // Body:
3730 
3731  result = clone();
3732  p_join_pa(other, result);
3733 
3734  // Postconditions:
3735 
3736  ensure(result != 0);
3737  ensure(result->is_same_type(this));
3738  ensure(postcondition_of(p_join_pa));
3739 
3740  // Exit
3741 
3742  return result;
3743 }
3744 
3745 void
3748 {
3749  // Preconditions:
3750 
3751  require(has_same_host(other));
3752  require(!result->is_attached());
3753  // this precondition ensures the attachment below will not
3754  // leave an orphan temporary in the poset
3755  require(result->is_ancestor_of(this));
3756  require(state_is_read_accessible());
3757 
3758  // Body:
3759 
3760  // if there is a unique minimal member of
3761  // the intersection of the up sets of this and other,
3762  // it is the p_join
3763 
3764  // get the up sets of this and other
3765 
3766  subposet tsp(host());
3767  up_pa(&tsp);
3768 
3769  subposet osp(host());
3770  other->up_pa(&osp);
3771 
3772  // intersect them
3773 
3774  tsp.p_intersection_sa(&osp);
3775 
3776  // find the minimal members of the intersection
3777 
3778  osp.make_empty();
3779  tsp.minimals_pa(&osp);
3780 
3782  if(!itr->is_done())
3783  {
3784  // at least one minimal member
3785  // assume it is unique and attach to it
3786  result->attach_to_state(host(), itr->index());
3787  // now lets see if it is unique
3788  itr->next();
3789  if(!itr->is_done())
3790  {
3791  // found a second minimal member
3792  // p_join does not exist
3793  result->detach_from_state();
3794  };
3795  };
3796 
3797  delete itr;
3798 
3799  // Postconditions:
3800 
3801  ensure(unexecutable(result is least upper bound in host of this and other));
3802 
3803  // Exit
3804 
3805  return;
3806 }
3807 
3808 void
3811 {
3812  // Preconditions:
3813 
3814  require(has_same_host(other));
3815  require(state_is_read_accessible());
3816 
3817  // Body:
3818 
3819  p_join_pa(other, this);
3820 
3821  // Postconditions:
3822 
3823  ensure(postcondition_of(p_join_pa));
3824 
3825  // Exit
3826 
3827  return;
3828 }
3829 
3833 {
3834  abstract_poset_member* result;
3835 
3836  // Preconditions:
3837 
3838  require(has_same_host(other));
3839  require(state_is_read_accessible());
3840 
3841  // Body:
3842 
3843  result = clone();
3844  p_meet_pa(other, result);
3845 
3846  // Postconditions:
3847 
3848  ensure(result != 0);
3849  ensure(result->is_same_type(this));
3850  ensure(postcondition_of(p_meet_pa));
3851 
3852 
3853  // Exit
3854 
3855  return result;
3856 }
3857 
3858 void
3861 {
3862  // Preconditions:
3863 
3864  require(has_same_host(other));
3865  require(!result->is_attached());
3866  // this precondition ensures the attachment below will not
3867  // leave an orphan temporary in the poset
3868  require(result->is_ancestor_of(this));
3869  require(state_is_read_accessible());
3870 
3871  // Body:
3872 
3873  // if there is a unique maximal member of
3874  // the intersection of the down sets of this and other,
3875  // it is the p_meet
3876 
3877  // get the down sets of this and other
3878 
3879  subposet tds(host());
3880  down_pa(&tds);
3881 
3882  subposet ods(host());
3883  other->down_pa(&ods);
3884 
3885  // intersect them
3886 
3887  tds.p_intersection_sa(&ods);
3888 
3889  // find the maximal members of the intersection
3890 
3891  ods.make_empty();
3892  tds.maximals_pa(&ods);
3893 
3895  if(!itr->is_done())
3896  {
3897  // at least one minimal member
3898  // assume it is unique and attach to it
3899  result->attach_to_state(host(), itr->index());
3900  // now lets see if it is unique
3901  itr->next();
3902  if(!itr->is_done())
3903  {
3904  // found a second minimal member
3905  // p_meet does not exist
3906  result->detach_from_state();
3907  };
3908  };
3909  delete itr;
3910 
3911  // Postconditions:
3912 
3913  ensure(unexecutable(result is least upper bound in host of this and other));
3914 
3915  // Exit
3916 
3917  return;
3918 }
3919 
3920 void
3923 {
3924  // Preconditions:
3925 
3926  require(has_same_host(other));
3927  require(state_is_read_accessible());
3928 
3929  // Body:
3930 
3931  p_meet_pa(other, this);
3932 
3933  // Postconditions:
3934 
3935  ensure(postcondition_of(p_meet_pa));
3936 
3937  // Exit
3938 
3939  return;
3940 }
3941 
3942 // PROTECTED MEMBER FUNCTIONS
3943 
3944 // PRIVATE MEMBER FUNCTIONS
3945 
3946 
3947 // ===========================================================
3948 // LATTICE ALGEBRA FACET
3949 // ===========================================================
3950 
3951 // PUBLIC MEMBER FUNCTIONS
3952 
3955 l_join(abstract_poset_member* other, bool xnew_jem)
3956 {
3957  abstract_poset_member* result;
3958 
3959  // Preconditions:
3960 
3961  require(has_same_host(other));
3962  require(state_is_read_accessible());
3963 
3964  // Body:
3965 
3966  result = clone();
3967  l_join_pa(other, result, xnew_jem);
3968 
3969  // Postconditions:
3970 
3971  ensure(result != 0);
3972  ensure(result->is_same_type(this));
3973  ensure(postcondition_of(l_join_pa));
3974 
3975  // Exit
3976 
3977  return result;
3978 }
3979 
3980 void
3983 {
3984  // Preconditions:
3985 
3986  require(state_is_read_accessible());
3987  require(!host()->in_jim_edit_mode());
3988  require(has_same_host(other));
3989  require(result->is_ancestor_of(this));
3990 
3991  // Body:
3992 
3993  scoped_index larray[2] = {_index, other->index()};
3994 
3997 
3998  result->new_jrm_state(_host, larray, 2, (xnew_jem ? tern::TRUE : tern::NEITHER));
3999 
4000  // Postconditions:
4001 
4002  ensure(unexecutable(result is least upper bound in host of this and other));
4003 
4004  // Exit
4005 
4006  return;
4007 }
4008 
4009 void
4011 l_join_sa(abstract_poset_member* other, bool xgreatest)
4012 {
4013  // Preconditions:
4014 
4015  require(has_same_host(other));
4016  require(state_is_read_accessible());
4017 
4018  // Body:
4019 
4020  l_join_pa(other, this, xgreatest);
4021 
4022  // Postconditions:
4023 
4024  ensure(postcondition_of(l_join_pa));
4025 
4026  // Exit
4027 
4028  return;
4029 }
4030 
4033 l_meet(abstract_poset_member* other, bool xnew_jem)
4034 {
4035  abstract_poset_member* result;
4036 
4037  // Preconditions:
4038 
4039  require(has_same_host(other));
4040  require(state_is_read_accessible());
4041 
4042  // Body:
4043 
4044  result = clone();
4045  l_meet_pa(other, result, xnew_jem);
4046 
4047  // Postconditions:
4048 
4049  ensure(result != 0);
4050  ensure(result->is_same_type(this));
4051  ensure(postcondition_of(l_meet_pa));
4052 
4053  // Exit
4054 
4055  return result;
4056 }
4057 
4058 void
4061 {
4062  // Preconditions:
4063 
4064  require(has_same_host(other));
4065  require(!result->is_attached());
4066  // this precondition ensures the attachment below will not
4067  // leave an orphan temporary in the poset
4068  require(result->is_ancestor_of(this));
4069  require(state_is_read_accessible());
4070 
4071  // Body:
4072 
4073  // Birkhoff representation theorem states that any jrm is equal to
4074  // the l_join of the jims contained in it.
4075  // The jims of c = a l_meet b are defined by:
4076  // J(c) = J(a) intersection J(b)
4077  // so we have:
4078  // c = l_join( J(a) intersection J(b) )
4079 
4080  // get the jim sets of this and other
4081 
4082  subposet jthis(host());
4083  jims_pa(&jthis);
4084 
4085  subposet jother(other->host());
4086  other->jims_pa(&jother);
4087 
4088  // intersect them
4089 
4090  jthis.p_intersection_sa(&jother);
4091 
4092  // join them
4093 
4094  jthis.l_join_jims_pa(result, xnew_jem);
4095 
4096  // Postconditions:
4097 
4098  ensure(unexecutable(result is least upper bound in host of this and other));
4099 
4100  // Exit
4101 
4102  return;
4103 }
4104 
4105 void
4107 l_meet_sa(abstract_poset_member* other, bool xnew_jem)
4108 {
4109  // Preconditions:
4110 
4111  require(has_same_host(other));
4112  require(state_is_read_accessible());
4113 
4114  // Body:
4115 
4116  l_meet_pa(other, this, xnew_jem);
4117 
4118  // Postconditions:
4119 
4120  ensure(postcondition_of(l_meet_pa));
4121 
4122  // Exit
4123 
4124  return;
4125 }
4126 
4129 l_not(bool xnew_jem) const
4130 {
4131  abstract_poset_member* result;
4132 
4133  // Preconditions:
4134 
4135  require(state_is_read_accessible());
4136 
4137  // Body:
4138 
4139  result = clone();
4140  l_not_pa(result, xnew_jem);
4141 
4142  // Postconditions:
4143 
4144  ensure(result != 0);
4145  ensure(result->is_same_type(this));
4146  ensure(postcondition_of(l_not_pa));
4147 
4148  // Exit
4149 
4150  return result;
4151 }
4152 
4153 void
4155 l_not_pa(abstract_poset_member* result, bool xnew_jem) const
4156 {
4157  // Preconditions:
4158 
4159  require(!result->is_attached());
4160  // this precondition ensures the attachment below will not
4161  // leave an orphan temporary in the poset
4162  require(result->is_ancestor_of(this));
4163  require(state_is_read_accessible());
4164 
4165  // Body:
4166 
4167  // Birkhoff representation theorem states that any jrm is equal to
4168  // the l_join of the jims contained in it. Let J(p) denote the jims in p.
4169  // The jims of a* = a.l_not() are defined by:
4170  // J(a*) = J(host) - (up set of J(a)), where the up set is computed
4171  // w.r.t. the poset J(host) not the lattice for which J is the set of jims.
4172  // So we have:
4173  // a* = l_join( J(host) - (up set in J(host) of J(a)) )
4174  // See exercise 8.22 in Davey and Priestley
4175 
4176 
4178 
4179  not_implemented();
4180 
4181  // get J(a), the jim set of this
4182 
4183  subposet tsp1(host());
4184  abstract_poset_member* cthis = const_cast<abstract_poset_member*>(this);
4185  cthis->jims_pa(&tsp1);
4186 
4187  // intersect the up set of J(a) in host with J(host)
4188  // to get the up set in the set of jims
4189 
4190  poset_slicer slicer(host());
4191  subposet tsp2(host());
4192  slicer.find_pa(&tsp1, &(host()->jims()), false, &tsp2);
4193 
4194  // compute all jims - up set of jims in this
4195 
4196  host()->jims().p_minus_pa(&tsp2, &tsp1);
4197 
4198  // join the difference
4199 
4200  tsp1.l_join_jims_pa(result, xnew_jem);
4201 
4202  // Postconditions:
4203 
4204  ensure(unexecutable(result is least upper bound in host of this and other));
4205 
4206  // Exit
4207 
4208  return;
4209 }
4210 
4211 void
4213 l_not_sa(bool xnew_jem) const
4214 {
4215  // Preconditions:
4216 
4217  require(state_is_read_accessible());
4218 
4219  // Body:
4220 
4221  abstract_poset_member* cthis = const_cast<abstract_poset_member*>(this);
4222  l_not_pa(cthis, xnew_jem);
4223 
4224  // Postconditions:
4225 
4226  ensure(postcondition_of(l_not_pa));
4227 
4228  // Exit
4229 
4230  return;
4231 }
4232 
4233 // PROTECTED MEMBER FUNCTIONS
4234 
4235 // PRIVATE MEMBER FUNCTIONS
4236 
4237 
4238 // ===========================================================
4239 // COMPONENT INDEX FACET
4240 // ===========================================================
4241 
4242 // PUBLIC MEMBER FUNCTIONS
4243 
4244 bool
4246 is_valid_index(const poset_state_handle* xhost, pod_index_type xhub_id, int xversion) const
4247 {
4248  bool result;
4249 
4250  // Preconditions:
4251 
4252  require(xhost != 0);
4253  require(xhost->state_is_read_accessible());
4254  require(host_is_ancestor_of(xhost));
4255 
4256  // Body:
4257 
4258  result = xhost->contains_member(xhub_id, xversion, false);
4259 
4260  // Postconditions:
4261 
4262  // Exit
4263 
4264  return result;
4265 }
4266 
4267 bool
4269 is_valid_index(const poset_state_handle* xhost, const scoped_index& xid, int xversion) const
4270 {
4271  bool result = false;
4272 
4273  // Preconditions:
4274 
4275  require(xhost != 0);
4276  require(xhost->state_is_read_accessible());
4277  require(host_is_ancestor_of(xhost));
4278 
4279  // Body:
4280 
4281  return is_valid_index(xhost, xid.hub_pod(), xversion);
4282 }
4283 
4286 id_spaces() const
4287 {
4288  // Precondtions:
4289 
4290  require(state_is_read_accessible());
4291 
4292  // Body:
4293 
4294  const index_space_family& result = _host->member_id_spaces(false);
4295 
4296  // Postconditions:
4297 
4298  // Exit:
4299 
4300  return result;
4301 }
4302 
4306 {
4307  // Preconditions:
4308 
4309  require(state_is_read_accessible());
4310 
4311  // Body:
4312 
4313  const hub_index_space_handle& result = _host->member_hub_id_space(false);
4314 
4315  // Postconditions:
4316 
4317  // Exit:
4318 
4319  return result;
4320 }
4321 
4322 const sheaf::scoped_index&
4324 hub_id() const
4325 {
4326  // Preconditions:
4327 
4328  require(state_is_read_accessible());
4329 
4330  // Body:
4331 
4332  const scoped_index& result = _host->member_id(false);
4333 
4334  // Postconditions:
4335 
4336  ensure(result.is_hub_scope());
4337 
4338  // Exit:
4339 
4340  return result;
4341 }
4342 
4346 {
4347  // Preconditions:
4348 
4349  require(state_is_read_accessible());
4350 
4351  // Body:
4352 
4353  scoped_index result = _host->member_id(xid, false);
4354 
4355  // Postconditions:
4356 
4357  ensure(result.is_hub_scope());
4358  ensure(result.pod() == xid);
4359 
4360  // Exit:
4361 
4362  return result;
4363 }
4364 
4367 get_index_from_name(const poset_state_handle* xhost, const std::string& xname) const
4368 {
4369  // Preconditions:
4370 
4371  require(xhost != 0);
4372  require(host_is_ancestor_of(xhost));
4373  require(xhost->state_is_read_accessible());
4374  require(!xname.empty());
4375 
4376  // Body:
4377 
4378  pod_index_type result = xhost->member_id(xname, false);
4379 
4380  // Postconditions:
4381 
4382  ensure(unexecutable(result.is_valid() implies member with index = result has name xname));
4383 
4384  // Exit
4385 
4386  return result;
4387 }
4388 
4389 void
4391 get_index_from_name(const poset_state_handle* xhost, const std::string& xname,
4392  scoped_index& result) const
4393 {
4394  // Preconditions:
4395 
4396  require(xhost != 0);
4397  require(host_is_ancestor_of(xhost));
4398  require(xhost->state_is_read_accessible());
4399  require(!xname.empty());
4400 
4401  // Body:
4402 
4403  xhost->member_id(xname, result, false);
4404 
4405  // Postconditions:
4406 
4407  ensure(unexecutable(result.is_valid() implies member with index = result has name xname));
4408 
4409  // Exit
4410 
4411  return;
4412 }
4413 
4414 // PROTECTED MEMBER FUNCTIONS
4415 
4416 // PRIVATE MEMBER FUNCTIONS
4417 
4418 
4419 // ===========================================================
4420 // COMPONENT NAME FACET
4421 // ===========================================================
4422 
4423 // PUBLIC MEMBER FUNCTIONS
4424 
4425 std::string
4427 name(bool xauto_access) const
4428 {
4429  string result;
4430 
4431  // Preconditions:
4432 
4433  require(xauto_access || state_is_read_accessible());
4434 
4435  // Body:
4436 
4437  result = host()->member_name(index(), xauto_access);
4438 
4439  // Postconditions:
4440 
4441  ensure(unexecutable(result.empty() implies this has no name));
4442 
4443  // Exit:
4444 
4445  return result;
4446 }
4447 
4448 void
4450 all_names(block<std::string>& xresult, bool xauto_access) const
4451 {
4452  // Preconditions:
4453 
4454  require(xauto_access || state_is_read_accessible());
4455 
4456  // Body:
4457 
4458  host()->all_member_names(_index.pod(), xresult, xauto_access);
4459 
4460  // Postconditions:
4461 
4462  ensure(xresult.ct() == name_ct(xauto_access));
4463  ensure_for_all(i, 0, xresult.ct(), !xresult[i].empty());
4464 
4465  // Exit:
4466 
4467  return;
4468 }
4469 
4472 name_ct(bool xauto_access) const
4473 {
4474  size_type result;
4475 
4476  // Preconditions:
4477 
4478  require(xauto_access || state_is_read_accessible());
4479 
4480  // Body:
4481 
4482  result = host()->member_name_ct(index(), xauto_access);
4483 
4484  // Postconditions:
4485 
4486  // Exit:
4487 
4488  return result;
4489 }
4490 
4491 bool
4493 has_name(const std::string& xname, bool xauto_access) const
4494 {
4495  // Preconditions:
4496 
4497  require(xauto_access || state_is_read_accessible());
4498  require(!xname.empty());
4499 
4500  // Body:
4501 
4502  bool result = host()->member_has_name(_index.pod(), xname, xauto_access);
4503 
4504  // Postconditions:
4505 
4506  // Exit
4507 
4508  return result;
4509 }
4510 
4511 void
4513 put_name(const std::string& xname, bool xunique, bool xauto_access)
4514 {
4515  // Preconditions:
4516 
4517  require(is_attached());
4518  require(xauto_access || state_is_read_write_accessible());
4519  require(poset_path::is_valid_name(xname));
4520 
4521  // Body:
4522 
4523  host()->put_member_name(index(), xname, xunique, xauto_access);
4524 
4525  // Postconditions:
4526 
4527  // ensure(invariant()); // requires access.
4528  ensure(xunique ? (name(xauto_access) == xname) : has_name(xname, xauto_access));
4529 
4530  // Exit
4531 
4532  return;
4533 }
4534 
4535 void
4537 delete_name(const std::string& xname, bool xauto_access)
4538 {
4539  // Preconditions:
4540 
4541  require(xauto_access || state_is_read_write_accessible());
4542  require(!xname.empty());
4543 
4544  // Body:
4545 
4546  // poset_state_handle::delete_member_name will delete the name
4547  // whatever member it belongs to. Not what we want here.
4548  // Only delete the name is it belongs to this.
4549 
4550  if(xauto_access)
4551  {
4552  get_read_write_access(true);
4553  }
4554 
4555  if(has_name(xname, false))
4556  {
4557  host()->delete_member_name(xname, false);
4558  }
4559 
4560  if(xauto_access)
4561  {
4562  release_access();
4563  }
4564 
4565  // Postconditions:
4566 
4567  ensure(!has_name(xname, xauto_access));
4568 
4569  // Exit:
4570 
4571  return;
4572 }
4573 
4574 void
4576 delete_all_names(bool xauto_access)
4577 {
4578  // Preconditions:
4579 
4580  require(xauto_access || state_is_read_write_accessible());
4581 
4582  // Body:
4583 
4584  host()->delete_all_member_names(_index.pod(), xauto_access);
4585 
4586  // Postconditions:
4587 
4588  ensure(name_ct(xauto_access) == 0);
4589 
4590  // Exit:
4591 
4592  return;
4593 }
4594 
4595 // PROTECTED MEMBER FUNCTIONS
4596 
4597 // PRIVATE MEMBER FUNCTIONS
4598 
4599 
4600 // ===========================================================
4601 // STATE FACET
4602 // ===========================================================
4603 
4604 // PUBLIC MEMBER FUNCTIONS
4605 
4606 void
4609  const poset_path& xpath,
4610  bool xauto_access)
4611 {
4612 
4613  // Preconditions:
4614 
4615  require(xns != 0);
4616  require(xauto_access || xns->state_is_read_accessible());
4617  require(xpath.full());
4618  require(xauto_access || xns->member_poset(xpath).state_is_read_accessible());
4619  require(xns->contains_poset_member(xpath));
4620 
4622 
4623  // Body:
4624 
4625  if(xauto_access)
4626  {
4627  xns->get_read_access();
4628  }
4629 
4630  poset_state_handle& lposet = xns->member_poset(xpath, false);
4631 
4632  if(xauto_access)
4633  {
4634  lposet.get_read_access();
4635  }
4636 
4637  attach_to_state(&lposet, xpath.member_name());
4638 
4639  // Postconditions:
4640 
4641  ensure(invariant());
4642  ensure(name_space()->is_same_state(xns));
4643  ensure(has_path(xpath, xauto_access));
4644  ensure(postcondition_of(attach_handle_data_members()));
4645 
4646  if(xauto_access)
4647  {
4648  lposet.release_access();
4649  xns->release_access();
4650  }
4651 
4652  // Exit:
4653 
4654  return;
4655 }
4656 
4657 void
4660  pod_index_type xposet_index,
4661  pod_index_type xmember_index,
4662  bool xauto_access)
4663 {
4664 
4665  // Preconditions:
4666 
4667  require(xnamespace != 0);
4668  require(!xauto_access ? xnamespace->state_is_read_accessible() : true);
4669 
4670  if(xauto_access)
4671  {
4672  xnamespace->get_read_access();
4673  }
4674 
4675  require(xnamespace->contains_poset_member(xposet_index, xmember_index));
4676 
4678 
4679  // Body:
4680 
4681  poset_state_handle& lposet = xnamespace->member_poset(xposet_index);
4682 
4683  lposet.get_read_access();
4684 
4685  attach_to_state(&lposet, xmember_index);
4686 
4687  // Postconditions:
4688 
4689  ensure(invariant());
4690  ensure(name_space()->is_same_state(xnamespace));
4691  ensure(host()->index() == xposet_index);
4692  ensure(index() == xmember_index);
4693  ensure(postcondition_of(attach_handle_data_members()));
4694 
4695  lposet.release_access();
4696 
4697  if(xauto_access)
4698  {
4699  xnamespace->release_access();
4700  }
4701 
4702  // Exit:
4703 
4704  return;
4705 }
4706 
4707 void
4710  const scoped_index& xposet_index,
4711  const scoped_index& xmember_index,
4712  bool xauto_access)
4713 {
4714 
4715  // Preconditions:
4716 
4717  require(xnamespace != 0);
4718  require(!xauto_access ? xnamespace->state_is_read_accessible() : true);
4719  require(xnamespace->contains_poset_member(xposet_index, xmember_index, xauto_access));
4720 
4721  // Body:
4722 
4723  attach_to_state(xnamespace,
4724  xposet_index.hub_pod(),
4725  xmember_index.hub_pod(),
4726  xauto_access);
4727 
4728  // Postconditions:
4729 
4730  ensure(invariant());
4731  ensure(name_space()->is_same_state(xnamespace));
4732  ensure(host()->index() ==~ xposet_index);
4733  ensure(index() ==~ xmember_index);
4734  ensure(postcondition_of(attach_handle_data_members()));
4735 
4736  // Exit:
4737 
4738  return;
4739 }
4740 
4741 void
4743 delete_state(bool xauto_access)
4744 {
4745  // Preconditions:
4746 
4747  require(is_attached());
4748  require(xauto_access ||
4749  (is_jim() ? host()->in_jim_edit_mode() : state_is_read_write_accessible()));
4750 
4753 
4754  // Body:
4755 
4756  bool lis_jim = is_jim();
4757  poset_state_handle* lhost = _host;
4758 
4759  if(xauto_access)
4760  {
4761  if(lis_jim)
4762  {
4763  lhost->begin_jim_edit_mode(true);
4764  }
4765  else
4766  {
4767  get_read_write_access(true);
4768  }
4769  }
4770 
4771  // Note: deleting a jim redefines the order relation. It is up to
4772  // the client to relink the remaining jims as desired. Deleting a
4773  // jrm however should leave the order relation for the remaining
4774  // members invariant. Hence, for a jim we just remove its links,
4775  // while for a jrm, we patch things up to maintain the order relation.
4776 
4777  // Whether it's a jim or a jrm, we remove the links to the member.
4778 
4779  index_space_iterator& lc_itr = lhost->get_cover_id_space_iterator(LOWER, _index.pod());
4780  index_space_iterator& uc_itr = lhost->get_cover_id_space_iterator(UPPER, _index.pod());
4781 
4782  // Remove this from the lower cover of its upper cover.
4783 
4784  while(!uc_itr.is_done())
4785  {
4786  lhost->remove_cover_member(_index.pod(), LOWER, uc_itr.hub_pod());
4787  uc_itr.next();
4788  }
4789 
4790  // Remove this from the upper cover of its lower cover.
4791 
4792  while(!lc_itr.is_done())
4793  {
4794  lhost->remove_cover_member(_index.pod(), UPPER, lc_itr.hub_pod());
4795  lc_itr.next();
4796  }
4797 
4798  if(!is_jim())
4799  {
4800  // Deleting a jrm;
4801  // ensure the order relation will remain invariant
4802  // after deleting state.
4803 
4804  // Link the the upper cover of this to the lower cover of this.
4805 
4806  uc_itr.reset();
4807  while(!uc_itr.is_done())
4808  {
4809  lc_itr.reset();
4810  while(!lc_itr.is_done())
4811  {
4812  if(!lhost->le(uc_itr.hub_pod(), lc_itr.hub_pod()) &&
4813  !lhost->le(lc_itr.hub_pod(), uc_itr.hub_pod()))
4814  {
4815  lhost->new_link(uc_itr.hub_pod(), lc_itr.hub_pod());
4816  }
4817  lc_itr.next();
4818  }
4819  uc_itr.next();
4820  }
4821  }
4822 
4823  // Release the cover iterators.
4824 
4825  _host->release_cover_id_space_iterator(lc_itr);
4826  _host->release_cover_id_space_iterator(uc_itr);
4827 
4828  // Clear the upper and lower cover of this.
4829 
4830  lhost->clear_cover(LOWER, _index.pod());
4831  lhost->clear_cover(UPPER, _index.pod());
4832 
4833  // Now just detach and delete the state.
4834 
4835  pod_index_type lindex = _index.pod();
4836  detach_from_state();
4837  lhost->delete_member(lindex);
4838 
4839  if(xauto_access)
4840  {
4841  if(lis_jim)
4842  {
4843  lhost->end_jim_edit_mode(true, true);
4844  }
4845  else
4846  {
4847  lhost->release_access();
4848  }
4849  }
4850 
4851  // Postconditions:
4852 
4853  ensure(!is_attached());
4854  ensure(unexecutable("!old host()->contains_member(old index())"));
4855 
4856  // Exit:
4857 
4858  return;
4859 }
4860 
4861 // PROTECTED MEMBER FUNCTIONS
4862 
4863 // PRIVATE MEMBER FUNCTIONS
4864 
4865 
4866 // ===========================================================
4867 // ANY FACET
4868 // ===========================================================
4869 
4870 // PUBLIC MEMBER FUNCTIONS
4871 
4872 bool
4874 is_ancestor_of(const any* xother) const
4875 {
4876  bool result;
4877 
4878  // Preconditions:
4879 
4880  // Body:
4881 
4882  result = dynamic_cast<const abstract_poset_member*>(xother) != 0;
4883 
4884  // Postconditions:
4885 
4886  // Exit
4887 
4888  return result;
4889 }
4890 
4891 bool
4893 invariant() const
4894 {
4895  // Preconditions:
4896 
4897  // Body:
4898 
4899  // Must satisfy base class invariant
4900 
4901  invariance(poset_component::invariant());
4902 
4903  if(invariant_check())
4904  {
4905  // Prevent recursive calls to invariant
4906 
4907  disable_invariant_check();
4908 
4909  // Invariants for this class:
4910 
4911  // Actual dof map conforms to type needed by this class.
4915 
4916  invariance(state_is_read_accessible() && is_jim(false) ? dof_map_is_ancestor_of(&(dof_map())) : true);
4917 
4920 
4921  // Finished, turn invariant checking back on.
4922 
4923  enable_invariant_check();
4924  }
4925 
4926  // Postconditions:
4927 
4928  // Exit
4929 
4930  return true;
4931 }
4932 
4933 // PROTECTED MEMBER FUNCTIONS
4934 
4935 // PRIVATE MEMBER FUNCTIONS
4936 
4937 
4938 // ===========================================================
4939 // DEBUGGING FACET
4940 // ===========================================================
4941 
4942 // PUBLIC MEMBER FUNCTIONS
4943 
4944 void
4946 to_stream(std::ostream& xos) const
4947 {
4948  // Preconditions:
4949 
4950  // Body:
4951 
4952  xos << *this;
4953 
4954  // Postconditions:
4955 
4956  // Exit:
4957 
4958  return;
4959 }
4960 
4961 // PROTECTED MEMBER FUNCTIONS
4962 
4963 // PRIVATE MEMBER FUNCTIONS
4964 
4965 
4966 // ===========================================================
4967 // NON-MEMBER FUNCTIONS FACET
4968 // ===========================================================
4969 
4970 std::ostream &
4971 sheaf::
4972 operator<<(std::ostream &os, const abstract_poset_member& p)
4973 {
4974 
4975  // Preconditions:
4976 
4977  // Body:
4978 
4979  if (p.is_attached())
4980  {
4981  p.get_read_access();
4983  os << "member:"
4984  << " host = \'" << p.host()->name() << "\'"
4985  << " index = " << p.index().hub_pod()
4986  << " name = \'" << p.name() << '\''
4987  << " version= " << p.version(false)
4988  << " unaliased version= " << p.version()
4989  << endl;
4990  p.release_access();
4992 
4993  }
4994  else
4995  {
4996  os << "member: host = \'\'' index = -1 name = \'\''"
4997  << endl;
4998  }
4999 
5000  // Exit:
5001 
5002  return os;
5003 }
5004 
5005 std::ostream &
5006 sheaf::
5007 operator<<(std::ostream &os, const abstract_poset_member* p)
5008 {
5009  // Preconditions:
5010 
5011  require(p != 0);
5012 
5013  // Body:
5014 
5016 
5017  post_fatal_error_message("change this call to use operator<<(ostream& abstract_poset_member&)");
5018 
5019  // os << *p;
5020 
5021  // Exit:
5022 
5023  return os;
5024 }
void find_pa(abstract_poset_member *xanchor, subposet *xlayer, bool xdown, subposet *result, slice_mode xmode=ALL)
Finds the intersection of the down set (up set) of xanchor with xlayer if xdown (!xdown), pre-allocated.
virtual void get_read_write_access(bool xrelease_read_only_access=false)
Get read write access to the state associated with this. If release_read_only_access is requested...
poset_state_handle * host() const
The poset which this is a handle to a component of.
bool geqv(pod_index_type xother_index) const
True if this is greater than or equivalent to the member with index xother_index. ...
bool state_is_auto_read_write_accessible(bool xauto_access) const
True if state is auto accessible for read and write, that is, if the state is already accessible for ...
virtual subposet * up() const
The up set of this member, auto- and pre-allocated versions.
virtual bool is_jim(bool xin_current_version=true) const
True if this member is join irreducible in the current version of the host (xin_current_version == tr...
A client handle for a subposet.
Definition: subposet.h:86
virtual bool is_restricted() const
True if handle is a restriction of the state, that is, if schema() is not the same as host()->schema(...
virtual pod_index_type get_index_from_name(const poset_state_handle *xhost, const std::string &xname) const
Gets the index of the component in xhost with name xname.
bool is_valid() const
True if this is a valid id.
Definition: scoped_index.h:832
pod_index_type dof_tuple_id(bool xauto_access) const
The dof tuple index of this member.
bool is_done() const
True if iteration finished.
int down_ct() const
The number of members in the down set of this member.
virtual void new_link(pod_index_type xgreater, pod_index_type xlesser)
Insert a cover link from greater to lesser (that is, hub id xgreater covers hub id xlesser)...
bool cover_contains_member(bool xlower, pod_index_type xother_mbr_index) const
True if and only if the lower (xlower true) or upper (xlower false) cover set of this contains xother...
void l_join_jims_pa(abstract_poset_member *result, bool xnew_jem=true)
Lattice join of the members of this, pre-allocated Requires this is a down set of jims...
Definition: subposet.cc:2420
virtual void create_cover_link(abstract_poset_member *xlesser)
Insert a link from this to lesser; make lesser <= this.
bool full() const
True if both poset name and member name are not empty.
Definition: poset_path.cc:311
virtual void p_meet_pa(abstract_poset_member *other, abstract_poset_member *result)
poset meet of this with other, pre-allocated the poset meet is the greatest lower bound in the pose...
virtual void all_names(block< std::string > &xresult, bool xauto_access=false) const
All the names for this.
int version(bool xunalias=true) const
The (possibly aliased) version of this component. The version of the host used when evaluating proper...
size_type ct() const
The number of items currently in use.
virtual size_type name_ct(bool xauto_access) const
The number of names for this.
virtual void new_jim_state(poset_dof_map *xdof_map=0, bool xcopy_dof_map=false, bool xauto_access=true)
Creates a new jim (join-irreducible member) state in host() and attaches this to it. If xdof_map == 0 a new dof map is created. If xdof_map != 0 and xcopy_dof_map == false, xdof_map is used as the dof map. If xdof_map != 0 and xcopy_dof_map is true, a copy of xdof_map is used.
abstract_poset_member * p_join(abstract_poset_member *other) const
poset join of this with other, auto-allocated the poset join is the least upper bound in the poset ...
const pod_type & pod() const
The "plain old data" storage of this; the value in the external id space.
Definition: scoped_index.h:672
bool covers(const abstract_poset_member *xother) const
True if this covers other.
abstract_poset_member * greatest_jem() const
The largest member which is join-equivalent to this.
An abstract iterator over the ids of an id space.
index_space_iterator & get_cover_id_space_iterator(bool xlower, pod_index_type xmbr_hub_id) const
Allocates an iterator for the lower (xlower true) or upper (xlower false) cover id space of the membe...
virtual void attach_handle_data_members()
Initializes handle data members when attaching to a different member of the same host; intended to be...
virtual size_type cover_ct(bool lower) const
The number of members in the lower cover (xlower true) or upper cover (xlower false) of this...
subposet_member_iterator * member_iterator() const
An iterator for members of this poset; handle version.
Definition: subposet.cc:912
void release_cover_id_space_iterator(index_space_iterator &xcover_itr) const
Returns xcover_itr to the pool of id spaces.
void p_join_sa(abstract_poset_member *other)
poset join of this with other, self-allocated the poset join is the least upper bound in the poset ...
virtual ~abstract_poset_member()
Destructor; deletes a poset member and its attached state, if any.
bool lt(pod_index_type xother_index) const
True if this is strictly less than the member with index xother_index.
pod_type pod() const
The current id in the iteration.
static host_type & new_host(namespace_type &xns, const poset_path &xhost_path, const poset_path &xschema_path, bool xauto_access)
Creates a new host table for members of this type. The poset is created in namespace xns with path xh...
The default name space; a poset which contains other posets as members.
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
bool contains_members(const scoped_index *xmbrs, int xmbrs_ct, bool xauto_access=true) const
True if this poset contains poset member(s) with indices in xmbrs.
bool path_is_auto_read_accessible(const poset_path &xpath, bool xauto_access) const
True if the state referred to xpath exists and is auto read accessible.
void clear_cover(bool xlower, pod_index_type xmbr_hub_id)
Clears the lower (xlower true) or upper (xlower false) cover set of the member with hub id xmbr_hub_i...
virtual void maximal_jims_pa(subposet *result) const
The maximal members of the set of jims contained in this member, pre-allocated.
void maximals_pa(subposet *result)
The subposet containing the maximal members of this, pre-allocated.
Definition: subposet.cc:1895
virtual schema_poset_member & schema()
The schema on which this is allocated (mutable version).
bool contains_poset_member(pod_index_type xposet_hub_id, pod_index_type xmember_hub_id, bool xauto_access=true) const
True if this contains a poset with hub id xposet_hub_id which contains a member with hub id xmember_h...
A three state "bool". Does not provide the operations of ternary logic and is intended for use mostly...
Definition: tern.h:45
A client handle for a general, abstract partially order set.
void insert_cover_member(pod_index_type xother_mbr_index, bool xlower)
Inserts xother_mbr_index in the lower (xlower true) or upper (xlower false) cover set of this...
void greatest_jem_pa(abstract_poset_member *result) const
The largest member which is join-equivalent to this.
virtual int atom_ct() const
The number of members in the set of atoms contained in the down set of this member.
virtual abstract_poset_member * clone() const =0
Virtual constructor; makes a new unattached handle of the same type as this.
A path defined by a poset name and a member name separated by a forward slash (&#39;/&#39;). For example: "cell_definitions/triangle".
Definition: poset_path.h:48
bool is_done() const
True if iteration finished.
int ct(bool xreset=false)
The number of members of the iteration set, from the current member to the end, inclusive. If xreset, reset before computing the count.
int up_ct() const
The number of members in the up set of this member.
virtual bool contains_member(pod_index_type xmbr_hub_id) const
True if this poset contains poset member with hub id xmbr_hub_id.
Definition: subposet.cc:955
virtual void jims_pa(subposet *result)
The set of jims contained in the down set of this member, pre-allocated.
STL namespace.
void dof_tuple(const void *xbuf, size_t xbuflen) const
Copies the entire dof tuple between xbuf and internal storage.
virtual abstract_poset_member & operator=(const abstract_poset_member &xother)
Assignment operator; attaches this to the same state as xother.
Specialization of the filtered depth-first iterator which exposes the POSTVISIT_ACTION to the client...
Definition: postorder_itr.h:40
An abstract handle to a space of alternate integer identifiers (aliases) for a subset of a hub set of...
virtual bool le(pod_index_type xgreater, pod_index_type xlesser) const
True if hub id xlesser is less than or equal to hub id xgreater.
virtual bool row_dof_map_conforms(const poset_dof_map *xdof_map) const
True if xdof_map conforms to (is derived from) the type of row dof map required by this poset state a...
virtual void get_read_access() const
Get read access to the state associated with this.
poset_state_handle & member_poset(pod_index_type xhub_id, bool xauto_access=true) const
The poset_state_handle object referred to by hub id xhub_id.
void l_join_sa(abstract_poset_member *other, bool xnew_jem=true)
lattice join of this with other, self-allocated the lattice join is the least upper bound in the la...
const scoped_index & index() const
The index of the component state this handle is attached to.
virtual void next()=0
Makes id() the next id in the iteration.
void clear_cover(bool xlower)
Clears the lower (xlower true) or upper (xlower false) cover set of this.
void l_not_sa(bool xnew_jem=true) const
lattice pseudo-complement of this, self-allocated The lattice pseudo-complement is the largest latt...
std::string name() const
A name for this.
The general, abstract map from dof ids to dof values.
Definition: poset_dof_map.h:59
abstract_poset_member & bottom()
The bottom member of the poset (mutable version)
void p_meet_sa(abstract_poset_member *other)
poset meet of this with other, self-allocated the poset meet is the greatest lower bound in the pos...
bool cover_is_equal(bool xlower, pod_index_type xother_mbr_index) const
True if and only if the lower (xlower true) or upper (xlower false) cover of this contains the same m...
An implementation of class sum_index_space_handle that has a primary sum id space state...
void copy_cover(bool xlower, pod_index_type xother_mbr_index)
Copies the lower (xlower true) or upper (xlower false) cover of this to the member with index xother_...
void least_jem_pa(abstract_poset_member *result) const
The smallest member which is join-equivalent to this.
T::row_dofs_type & row_dofs(T &x0)
The row dofs pod type for x0 (mutable version).
bool gt(pod_index_type xother_index) const
True if this is strictly greater than the member with index xother_index.
virtual void atoms_pa(subposet *result) const
The set of atomss contained in the down set of this member, pre-allocated.
bool is_jem(const abstract_poset_member *xother) const
True if xother is join equivalent to this.
virtual pod_index_type new_member(bool xis_jim, pod_index_type xtuple_hub_id)
Create a disconnected member with is_jim == xis_jim and the dof tuple identified by hub id xtuple_hub...
void put_dof_tuple(const void *xbuf, size_t xbuflen)
Copies the entire dof tuple between xbuf and internal storage.
SHEAF_DLL_SPEC vd_value_type length(const ed &x0, bool xauto_access)
The Euclidean length (magnitude) of x0 (version for persistent types).
Definition: ed.cc:906
dof_type & operator[](size_type xi)
Xi-th byte (mutable version).
const scoped_index & index() const
The index of the current member of the iteration.
void find_jims_pa(abstract_poset_member *xanchor, subposet *result, slice_mode xmode=ALL)
Find jims in the down set of the poset member xanchor, pre-allocated.
virtual void reset()=0
Restarts the iteration.
bool is_hub_scope() const
True if and only if the id space of this is the hub id space.
Definition: scoped_index.h:575
virtual void delete_state(bool xauto_access=false)
Detachs this from its state and then deletes the state.
virtual void release_access(bool xall=false) const
Release access. If xall is true, release all levels of access. Otherwise, release one level of access...
void next()
Makes this the next member of the subset.
virtual bool invariant() const
Class invariant.
Abstract base class with useful features for all objects.
Definition: any.h:39
virtual subposet * atoms() const
The set of atomss contained in the down set of this member, auto-allocated.
A map from Zn (the integers mod n) to bools. A characteristic function used to represent subsets of Z...
Definition: zn_to_bool.h:52
virtual schema_poset_member & unrestricted_schema()
The unrestricted schema for this poset member (mutable version).
const bool NOT_STRICT
Iteration strictness control.
Definition: sheaf.h:102
const bool DOWN
Iteration directions.
Definition: sheaf.h:77
dof_type & operator[](size_type xi)
Xi-th byte (mutable version).
virtual schema_poset_member & schema()
The schema for this poset (mutable version).
bool is_done() const
True if iteration is finished.
void make_empty()
Make this subposet the empty subposet.
Definition: subposet.cc:1361
abstract_poset_member()
Default constructor; creates a new, unattached abstract_poset_member handle.
Specialization of the filtered depth-first iterator which exposes all three actions to the client; th...
Definition: triorder_itr.h:42
virtual bool has_name(const std::string &xname, bool xauto_access=false) const
True if xname is a name for this.
bool state_is_read_write_accessible() const
True if this is attached and if the state is accessible for read and write or access control is disab...
A client handle for a mutable partially ordered set.
Definition: poset.h:40
bool leqv(pod_index_type xother_index) const
True if this is less than or equivalent to the member with index xother_index.
virtual bool invariant() const
Class invariant.
Definition: subposet.cc:2963
void remove_cover_member(pod_index_type xother_mbr_hub_id, bool xlower, pod_index_type xmbr_hub_id)
Removes hub id xother_mbr_hub_id from the lower (xlower true) or upper (xlower false) cover set of th...
bool owns(const poset_state_handle &xposet, bool xauto_access) const
True if and only if this contains the poset xposet. synonym for contains_poset(xposet.poset_path(true), xauto_access)
const index_space_family & id_spaces() const
The id space family for this member.
virtual void to_stream(std::ostream &xos=std::cout) const
Virtual stream insertion.
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
virtual const hub_index_space_handle & hub_id_space() const
The hub id space; const version.
unsigned char dof_type
The type of the dofs.
virtual bool is_attached() const
True if this handle is attached to a non-void state.
bool cover_is_singleton(bool xlower) const
True if and only if the lower (xlower true) or upper (xlower false) cover set of this contains exactl...
virtual void get_read_access() const
Get read access to the state associated with this.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
virtual int jim_ct() const
The number of members in the set of jims contained in the down set of this member.
void l_join_pa(abstract_poset_member *other, abstract_poset_member *result, bool xnew_jem=true)
lattice join of this with other, pre-allocated the lattice join is the least upper bound in the lat...
void * row_dofs()
The row dofs for this instance (mutable version).
virtual void insert_member(pod_index_type xmbr_hub_id)
Inserts the member of host() with hub id xmbr_hub_id.
Definition: subposet.cc:1091
bool cover_contains_iterator(bool xlower, const index_space_iterator &xitr) const
True if and only if the lower (xlower true) or upper (xlower false) cover id space of this is the dom...
virtual subposet * jims()
The set of jims contained in the down set of this member, auto-allocated.
bool contains_path(const poset_path &xpath, bool xauto_access=true) const
True if this contains the poset or poset member specified by xpath.
bool cover_is_empty(bool xlower, pod_index_type xmbr_hub_id) const
True if and only if the lower (xlower true) or upper (xlower false) cover set of the member with hub ...
virtual int maximal_jim_ct() const
The number of maximal members in the set of jims contained in the down set of this member...
abstract_poset_member * l_not(bool xnew_jem=true) const
lattice pseudo-complement of this, auto-allocated The lattice pseudo-complement is the largest latt...
void link_least_jem(pod_index_type xjem1, pod_index_type xjem2)
Makes hub id xjem1 the least jem of hub id xjem2, unless the current least jem of xjem2 is bottom...
virtual bool contains_member(pod_index_type xmbr_hub_id, bool xauto_access=true) const
True if some version of this poset contains poset member with hub id xmbr_hub_id. ...
virtual void up_pa(subposet *result) const
The up set of this member, auto- and pre-allocated versions.
abstract_poset_member * least_jem() const
The smallest member which is join-equivalent to this.
const bool UPPER
Selector for upper cover.
Definition: sheaf.h:72
pod_index_type first_cover_member(bool xlower) const
The first member of the lower (xlower true) or upper (xlower false) cover of this.
bool le(pod_index_type xother_index) const
True if this is less than or equal to the member with index xother_index.
Row dofs type for class abstract_poset_member.
virtual bool is_valid_index(const poset_state_handle *xhost, pod_index_type xhub_id, int xversion=CURRENT_HOST_VERSION) const
True if there exists a component of the same type as this with hub id xhub_id in version xversion of ...
virtual bool is_ancestor_of(const any *other) const
True if other conforms to this.
virtual void put_name(const std::string &xname, bool xunique, bool xauto_access)
Make xname a name for this; if xunique, make xname the only name.
void put(const index_space_handle &xid_space, pod_type xpod)
Set the scope to id space, xid_space and pod() to xpod.
Definition: scoped_index.h:332
char * row_dof_ptr(bool xrequire_write_access=false)
Pointer to the row dofs.
void down_set_pa(abstract_poset_member *xanchor, subposet *result, slice_mode xmode=ALL)
find the down set of the poset member xanchor, pre-allocated
virtual void begin_jim_edit_mode(bool xauto_access=true)
Allow editing of jims and jim order relation.
primitive_value dof(pod_index_type xdof_id) const
The dof referred to by xdof_id.
virtual std::string name() const
The name of this poset.
bool empty() const
True if both poset name and member name are empty.
Definition: poset_path.cc:291
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
Definition: any.h:97
virtual void release_access(bool xall=false) const
Release access. If xall is true, release all levels of access. Otherwise, release one level of access...
int member_ct() const
The number of members of this subposet.
Definition: subposet.cc:887
const bool UP
Iteration directions.
Definition: sheaf.h:82
index_space_handle & get_cover_id_space(bool xlower) const
Allocates a handle for the lower (xlower true) or upper (xlower false) cover id space of this member ...
SHEAF_DLL_SPEC void max(const vd &x0, vd_value_type &xresult, bool xauto_access)
Maximum component of x0, pre-allocated version.
Definition: vd.cc:2097
void put_dof(pod_index_type xdof_id, const primitive_value &xdof)
Sets the dof referred to by xdof_id to xdof.
virtual const scoped_index & hub_id() const
A id in the hub id space for components of this type; intended for copying to initialize ids to the h...
abstract_poset_member * l_meet(abstract_poset_member *other, bool xnew_jem=true)
lattice meet of this with other, auto-allocated the lattice meet is the greatest lower bound in the...
index_space_iterator & get_cover_id_space_iterator(bool xlower) const
Allocates an iterator for the lower (xlower true) or upper (xlower false) cover id space of this memb...
void delete_down(bool xdelete_exterior=false, bool xenter_jim_edit_mode=true)
Delete the strict down set of this, except for the external boundary. If xdelete_exterior, delete the external boundary as well.
virtual schema_poset_member & schema()
The schema for this poset member (mutable version).
virtual bool is_atom() const
True if this member covers the bottom.
bool cover_is_empty(bool xlower) const
True if and only if the lower (xlower true) or upper (xlower false) cover this is empty...
const bool LOWER
Selector for lower cover.
Definition: sheaf.h:67
void get_dof(pod_index_type xdof_id, void *xdof, size_type xdof_size) const
Copies the dof referred to by xdof_id into xdof.
void p_intersection_sa(const subposet *other)
Intersection of this with other, self-allocated.
Definition: subposet.cc:1585
virtual void detach_from_state()
Detach this handle from its state, if any.
bool ge(pod_index_type xother_index) const
True if this is greater than or equal to the member with index xother_index.
void next()
Makes this the next member of the subset.
virtual subposet * maximal_jims()
The maximal members of the set of jims contained in this member, auto-allocated.
virtual void delete_all_names(bool xauto_access=false)
Delete all the names for this.
void link_greatest_jem(pod_index_type xjem1, pod_index_type xjem2)
Makes hub id xjem1 the greatest jem of hub id xjem2, unless the current greatest jem of xjem2 is top...
virtual poset_state_handle * host() const
The poset which owns this.
primitive_type & id()
Type id of the primitive type.
virtual void merge_jem(const abstract_poset_member *xjem)
Merge the join-equivalence class of xjem under the join equivalence class of this.
bool schema_is(const std::string &xschema_name) const
True if the schema of this has name xname.
T::table_dofs_type & table_dofs(T &x0)
The table dofs pod type for x0 (mutable version).
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
void l_not_pa(abstract_poset_member *result, bool xnew_jem=true) const
lattice pseudo-complement of this, pre-allocated The lattice pseudo-complement is the largest latti...
std::string member_name() const
The member name part of the path.
Definition: poset_path.cc:511
virtual scoped_index member_index_ub() const
The upper bound on the member_index;.
void * table_dofs()
The table dofs for this instance (mutable version).
SHEAF_DLL_SPEC std::ostream & operator<<(std::ostream &os, const dof_descriptor_array &p)
Insert dof_descriptor_array& p into ostream& os.
char * table_dof_ptr(bool xrequire_write_access=false) const
Pointer to the table dofs.
void put_dof_tuple_id(pod_index_type xtuple_index, bool xauto_access)
Sets dof tuple index to xtuple_index.
void l_meet_pa(abstract_poset_member *other, abstract_poset_member *result, bool xnew_jem=true)
lattice meet of this with other, pre-allocated the lattice meet is the greatest lower bound in the ...
virtual subposet & jims()
The subset of all jims (mutable version)
virtual void end_jim_edit_mode(bool xensure_lattice_invariant=true, bool xauto_access=true)
Prevent editing of jims and jim order relation.
virtual void delete_name(const std::string &xname, bool xauto_access=false)
Delete all names for this.
unsigned char dof_type
The type of the dofs.
virtual void delete_member(pod_index_type xmbr_hub_id)
Delete the member with hub id xmbr_hub_id. Warning: this routine does not delete links; it will leave...
virtual void down_pa(subposet *result) const
The down set of this, pre-allocated version.
void tuple(pod_index_type x, size_type xj_ub, pod_index_type &xi, pod_index_type &xj)
Ordinal to 2-tuple conversion.
void attach_to_state(const namespace_poset *xns, const poset_path &xpath, bool xauto_access=true)
Attach to the state specified by path xpath in the namespace xns.
Abstract object wrapper for an instance of a primitive type.
pod_index_type first_cover_member(bool xlower, pod_index_type xmbr_hub_id) const
Hub id of the first member of the lower (xlower true) or upper (xlower false) cover of the member wit...
virtual bool dof_map_is_ancestor_of(const poset_dof_map *xdof_map) const
True if xdof_map conforms to (is derived from) the type of dof map required by this handle...
void release_cover_id_space(index_space_handle &xcover_id_space) const
Returns xcover_id_space to the pool of id spaces.
virtual void get_read_access() const
Get read access to the state associated with this.
An abstract client handle for a member of a poset.
virtual poset_dof_map & dof_map(bool xrequire_write_access=false)
The map from schema member ids or client ids to dof values for this poset member (mutable version) ...
Factory and container for a family of id spaces.
virtual void new_jem_state(abstract_poset_member *xother, bool xgreatest, bool xauto_access)
Creates a new jrm state in host() which is the greatest jem (xgreatest true) or least jem (xgreatest ...
bool row_conforms_to(const schema_poset_member &xother) const
True if the row dofs defined by this agree in type and in order with the dofs defined by xother...
abstract_poset_member * p_meet(abstract_poset_member *other)
poset meet of this with other, auto-allocated the poset meet is the greatest lower bound in the pos...
bool in_jim_edit_mode() const
True if editing jims and jim order relation is allowed.
virtual void p_join_pa(abstract_poset_member *other, abstract_poset_member *result) const
poset join of this with other, pre-allocated the poset join is the least upper bound in the poset ...
void minimals_pa(subposet *result)
The subposet containing the minimal members of this, pre-allocated.
Definition: subposet.cc:1939
row_dofs_type * clone() const
Creates a new instance of the same type as this.
virtual schema_poset_member & schema()
The schema for this member (mutable version).
void remove_cover_member(pod_index_type xother_mbr_index, bool xlower)
Removes xother_mbr_index from the lower (xlower true) or upper (xlower false) cover set of this...
virtual void delete_cover_link(abstract_poset_member *lesser)
Delete the link from this to lesser; make lesser incomparable to this.
SHEAF_DLL_SPEC bool is_valid(pod_index_type xpod_index)
True if an only if xpod_index is valid.
Definition: pod_types.cc:37
void truncate()
Makes this the next member of the subset which is not less than old this, i.e. the depth-first descen...
Computes the join of given poset members.
Definition: poset_joiner.h:43
virtual bool is_same_restriction(const abstract_poset_member *xother) const
True if this is the same restriction as xother, that is, if schema().is_same_state(xother.schema()).
bool is_same_type(const any *other) const
True if other is the same type as this.
Definition: any.cc:79
Traverser to compute intersection of the down set (up set) of the anchor with a given subposet...
Definition: poset_slicer.h:45
void enable_invariant_check() const
Enable invariant checking.
Definition: any.h:87
void l_meet_sa(abstract_poset_member *other, bool xnew_jem=true)
lattice meet of this with other, self-allocated the lattice meet is the greatest lower bound in the...
bool contains_row_dof_tuple(pod_index_type xtuple_hub_id) const
True if this contains a tuple with hub id xtuple_hub_id.
Specialization of the filtered depth-first iterator which exposes the PREVISIT_ACTION to the client...
Definition: preorder_itr.h:41
bool same_schema(const abstract_poset_member *xother) const
True if xother has the same schema (column poset) as this.
A client handle for a poset member which has been prepared for use as a schema.
virtual void release_access(bool xall=false) const
Release access. If xall is true, release all levels of access. Otherwise, release one level of access...
Table dofs type for class abstract_poset_member.
virtual void new_jrm_state(bool xauto_access=true)
Creates a new jrm (join-reducible member) state in host() and attaches this to it.
virtual subposet * down() const
The down set of this, auto-allocated version.
pod_type hub_pod() const
The current unglued hub id in the iteration. synonym for unglued_hub_pod().
A client handle for an unrestricted member of a poset. A total_poset_member is guaranteed not to be r...
abstract_poset_member * l_join(abstract_poset_member *other, bool xnew_jem=true)
lattice join of this with other, auto-allocated the lattice join is the least upper bound in the la...
table_dofs_type * clone() const
Creates a new instance of the same type as this.
virtual const scoped_index & member_id(bool xauto_access) const
An id in the member hub id space; intended for copying to initialize ids to the member id space...
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
Definition: scoped_index.h:710