SheafSystem  0.0.0.0
subposet.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/subposet.h"
22 
23 #include "SheafSystem/assert_contract.h"
24 #include "SheafSystem/array_index_space_handle.h"
25 #include "SheafSystem/array_index_space_state.h"
26 #include "SheafSystem/block.h"
27 #include "SheafSystem/hash_index_space_handle.h"
28 #include "SheafSystem/hash_index_space_state.h"
29 #include "SheafSystem/interval_index_space_handle.h"
30 #include "SheafSystem/interval_index_space_state.h"
31 #include "SheafSystem/list_index_space_handle.h"
32 #include "SheafSystem/list_index_space_state.h"
33 #include "SheafSystem/namespace_poset.h"
34 #include "SheafSystem/pool.h"
35 #include "SheafSystem/poset.h"
36 #include "SheafSystem/poset_member.h"
37 #include "SheafSystem/poset_powerset_state.h"
38 #include "SheafSystem/poset_slicer.h"
39 #include "SheafSystem/preorder_iterator.h"
40 #include "SheafSystem/std_sstream.h"
41 #include "SheafSystem/std_iomanip.h"
42 #include "SheafSystem/poset_joiner.h"
43 #include "SheafSystem/subposet_member_iterator.h"
44 #include "SheafSystem/subposet_state.h"
45 #include "SheafSystem/tern.h"
46 
47 using namespace std;
48 
49 // ===========================================================
50 // SUBPOSET FACET
51 // ===========================================================
52 
53 // PUBLIC MEMBER FUNCTIONS
54 
57 {
58 
59  // Preconditions
60 
61  // Body:
62 
63  // Nothing to do, data members already
64  // initialized in poset_component::poset_component
65 
66  // Postconditions:
67 
68  ensure(invariant());
69  ensure( !is_attached() );
70 
71  // Exit
72 
73  return;
74 }
75 
76 
78 subposet(const subposet& xother, bool xdeep_copy)
79 {
80 
81  // Preconditions
82 
83  require(xdeep_copy ? xother.state_is_read_write_accessible() : true);
84 
85  // Body:
86 
87  subposet& lother = const_cast<subposet&>(xother);
88 
89  if(xdeep_copy)
90  {
91  // Create a new state with the same membership
92  // as xother and attach to it.
93 
94  new_state(lother.host(), false);
95  lother.members()->equal_pa(members());
96  }
97  else
98  {
99  // Just attach to the same state as xother.
100 
101  attach_to_state(&lother);
102  }
103 
104  // Postconditions:
105 
106  ensure( invariant() );
107  ensure( has_same_host(&xother) );
108  ensure( xdeep_copy ? is_equal_to(&xother) : is_same_state(&xother) );
109  ensure( xdeep_copy ? name().empty() : true);
110 
111  // Exit
112 
113  return;
114 }
115 
118 {
119  // Preconditions:
120 
121  // Body:
122 
123  // Postconditions:
124 
125  // Exit
126 
127  return;
128 }
129 
130 // NEW HANDLE, NEW STATE CONSTRUCTORS
131 
134  const block<pod_index_type>* xmembers,
135  bool xauto_access)
136 {
137 
138  // Preconditions
139 
140  require(xhost != 0);
141  require(xhost->state_is_auto_read_write_accessible(xauto_access));
142  require(xmembers != 0 ? xhost->contains_members(*xmembers, xauto_access) : true);
143 
144  // Body:
145 
146  if(xmembers != 0)
147  {
148  new_state(xhost, *xmembers, xauto_access);
149  }
150  else
151  {
152  new_state(xhost, true, xauto_access);
153  }
154 
155  // Postconditions:
156 
157  if(xauto_access)
158  {
159  get_read_access();
160  }
161 
162  ensure(invariant());
163  ensure(host() == xhost);
164  ensure(xmembers != 0 ? contains_members(*xmembers) : is_empty());
165  ensure(is_persistent());
166 
167  if(xauto_access)
168  {
169  release_access();
170  }
171 
172  // Exit
173 
174  return;
175 }
176 
179  const block<scoped_index>& xmembers,
180  bool xauto_access)
181 {
182 
183  // Preconditions
184 
185  require(precondition_of(new_state(same args)));
186 
187  // Body:
188 
189  new_state(xhost, xmembers, xauto_access);
190 
191 
192  // Postconditions:
193 
194  ensure(postcondition_of(new_state(same args)));
195 
196  // Exit
197 
198  return;
199 }
200 
201 // NEW HANDLE, EXISTING STATE CONSTRUCTORS
202 
205 {
206  // Preconditions:
207 
208  require(xhost->state_is_read_accessible());
209  require(xhost->includes_subposet(xhub_id));
210 
211  // Body:
212 
213  attach_to_state(xhost, xhub_id);
214 
215  // Postconditions:
216 
217  ensure(invariant());
218  ensure(host() == xhost);
219  ensure(index().is_hub_scope());
220  ensure(index() == xhub_id);
221  ensure(is_attached());
222 }
223 
225 subposet(const poset_state_handle* xhost, const scoped_index& xid)
226 {
227  // Preconditions:
228 
229  require(xhost->state_is_read_accessible());
230  require(xhost->includes_subposet(xid));
231 
232  // Body:
233 
234  attach_to_state(xhost, xid);
235 
236  // Postconditions:
237 
238  ensure(invariant());
239  ensure(host() == xhost);
240  ensure(index().is_hub_scope());
241  ensure(index() ==~ xid);
242  ensure(is_attached());
243 }
244 
246 subposet(const poset_state_handle* xhost, const std::string& xname)
247 {
248 
249  // Preconditions
250 
251  require(xhost != 0);
252  require(xhost->state_is_read_accessible());
253  require(!xname.empty());
254  require(xhost->includes_subposet(xname));
255 
256  // Body:
257 
258  attach_to_state(xhost, xname);
259 
260  // Postconditions:
261 
262  ensure( invariant() );
263  ensure( is_attached() );
264  ensure( host() == xhost );
265  ensure( name() == xname );
266 
267  // Exit
268 
269  return;
270 }
271 
274 operator=(const subposet& xother)
275 {
276  // Preconditions:
277 
278  // Body:
279 
280  attach_to_state(&xother);
281 
282  // Postconditions:
283 
284  ensure(is_same_state(&xother));
285 
286  // Exit
287 
288  return *this;
289 }
290 
291 // EXISTING HANDLE, NEW STATE "CONSTRUCTORS"
292 
293 void
295 new_state(bool xinitialize, bool xauto_access)
296 {
297  // Preconditions:
298 
299  require(precondition_of(new_state(host(), xinitialize, xauto_access)));
300 
301  // Body:
302 
303  new_state(host(), xinitialize, xauto_access);
304 
305  // Postconditions:
306 
307  ensure(postcondition_of(new_state(host(), xinitialize, xauto_access)));
308 
309  // Exit:
310 
311  return;
312 }
313 
314 void
316 new_state(const block<pod_index_type>& xmembers, bool xauto_access)
317 {
318  // Preconditions:
319 
320  require(precondition_of(new_state(host(), xmembers, xauto_access)));
321 
322  // Body:
323 
324  new_state(host(), xmembers, xauto_access);
325 
326  // Postconditions:
327 
328  ensure(postcondition_of(new_state(host(), xmembers, xauto_access)));
329 
330  // Exit:
331 
332  return;
333 }
334 
335 void
337 new_state(const block<scoped_index>& xmembers, bool xauto_access)
338 {
339  // Preconditions:
340 
341  require(precondition_of(new_state(host(), xmembers, xauto_access)));
342 
343  // Body:
344 
345  new_state(host(), xmembers, xauto_access);
346 
347  // Postconditions:
348 
349  ensure(postcondition_of(new_state(host(), xmembers, xauto_access)));
350 
351  // Exit:
352 
353  return;
354 }
355 
356 void
359  bool xinitialize,
360  bool xauto_access)
361 {
362 
363  // Preconditions:
364 
365  require(xhost != 0);
366  require(xhost->state_is_auto_read_write_accessible(xauto_access));
367 
368  // Get access if auto access is requested. Need to do it here so the
369  // remaining preconditions can be executed.
370 
371  if(xauto_access)
372  {
373  xhost->get_read_write_access(true);
374  }
375 
376  // Body:
377 
378  _host = xhost;
379  _host->new_subposet(xinitialize, _index);
380  _version = CURRENT_HOST_VERSION;
381 
382  // Postconditions:
383 
384  ensure(invariant());
385  ensure(host() == xhost);
386  ensure(is_persistent());
387  ensure(xinitialize ? is_empty() : true);
388 
389  // Release access if auto access was requested.
390 
391  if(xauto_access)
392  {
393  xhost->release_access();
394  }
395 
396  // Exit
397 
398  return;
399 }
400 
401 void
404  const block<pod_index_type>& xmembers,
405  bool xauto_access)
406 {
407 
408  // Preconditions:
409 
410  require(xhost != 0);
411  require(xhost->state_is_auto_read_write_accessible(xauto_access));
412 
413  // Get access if auto access is requested. Need to do it here so the
414  // remaining preconditions can be executed.
415 
416  if(xauto_access)
417  {
418  xhost->get_read_write_access(true);
419  }
420 
421  require(xhost->contains_members(xmembers));
422 
423  // Body:
424 
425  _host = xhost;
426  _index.put(host()->subposet_hub_id_space(false), _host->new_subposet(xmembers));
427  _version = CURRENT_HOST_VERSION;
428 
429  // Postconditions:
430 
431  ensure(invariant());
432  ensure(host() == xhost);
433  ensure(contains_members(xmembers));
434  ensure(is_persistent());
435 
436  // Release access if auto access was requested.
437 
438  if(xauto_access)
439  {
440  xhost->release_access();
441  }
442 
443  // Exit
444 
445  return;
446 }
447 
448 void
451  const block<scoped_index>& xmembers,
452  bool xauto_access)
453 {
454 
455  // Preconditions:
456 
457  require(xhost != 0);
458  require(xhost->state_is_auto_read_write_accessible(xauto_access));
459 
460  // Get access if auto access is requested. Need to do it here so the
461  // remaining preconditions can be executed.
462 
463  if(xauto_access)
464  {
465  xhost->get_read_write_access(true);
466  }
467 
468  require(xhost->contains_members(xmembers));
469 
470  // Body:
471 
472  _host = xhost;
473  _host->new_subposet(xmembers, _index);
474  _version = CURRENT_HOST_VERSION;
475 
476  // Postconditions:
477 
478  ensure(invariant());
479  ensure(host() == xhost);
480  ensure(contains_members(xmembers));
481  ensure(is_persistent());
482 
483  // Release access if auto access was requested.
484 
485  if(xauto_access)
486  {
487  xhost->release_access();
488  }
489 
490  // Exit
491 
492  return;
493 }
494 
495 // PROTECTED MEMBER FUNCTIONS
496 
497 // PRIVATE MEMBER FUNCTIONS
498 
499 
500 // ===========================================================
501 // ID SPACE FACET
502 // ===========================================================
503 
504 // PUBLIC MEMBER FUNCTIONS
505 
508 id_space() const
509 {
510  // Preconditions:
511 
512  require(state_is_read_accessible());
513  require(has_id_space());
514 
515  // Body:
516 
518  powerset_member(index())->id_space();
519 
520  // Postconditions:
521 
522  ensure(result.is_attached());
523 
524  // Exit:
525 
526  return result;
527 }
528 
532 {
533  // Preconditions:
534 
535  require(state_is_read_accessible());
536  require(has_id_space());
537 
538  // Body:
539 
541  powerset_member(index())->id_space();
542 
543  // Postconditions:
544 
545  ensure(result.is_attached());
546 
547  // Exit:
548 
549  return result;
550 }
551 
554 new_id_space(const std::string& xstate_class_name)
555 {
556  // Preconditions:
557 
558  require(state_is_read_write_accessible());
559  require(!name().empty());
560  require(!has_id_space());
561  require(!host()->member_id_spaces(false).contains(id_space_name()));
562  require(!xstate_class_name.empty());
563  require(unexecutable("xstate_class_name is a descendant of scattered_insertion_index_space_state"));
564 
565  // Body:
566 
569 
570  pod_index_type lid;
571 
572  if(xstate_class_name == "array_index_space_state")
573  {
574  lid = array_index_space_state::new_space(host()->member_id_spaces(false),
575  id_space_name(),
576  is_persistent(),
577  member_ct()).index();
578  }
579  else if(xstate_class_name == "hash_index_space_state")
580  {
581  lid = hash_index_space_state::new_space(host()->member_id_spaces(false),
582  id_space_name(),
583  is_persistent(),
584  member_ct()).index();
585  }
586  else if(xstate_class_name == "interval_index_space_state")
587  {
588  lid = interval_index_space_state::new_space(host()->member_id_spaces(false),
589  id_space_name(),
590  is_persistent(),
591  true).index();
592  }
593  else if(xstate_class_name == "list_index_space_state")
594  {
595  lid = list_index_space_state::new_space(host()->member_id_spaces(false),
596  id_space_name(),
597  is_persistent()).index();
598  }
599  else
600  {
601  post_fatal_error_message("The id space type '" + xstate_class_name + "' is not supported.");
602  }
603 
604  powerset_member(index())->put_id_space(host()->member_id_spaces(false), lid);
605 
606  scattered_insertion_index_space_handle& result = id_space();
607 
608  // Postconditions:
609 
610  ensure(invariant());
611  ensure(has_id_space());
612  ensure(id_space() == result);
613  ensure(id_space().is_persistent() == is_persistent());
614 
615  // Exit:
616 
617  return result;
618 }
619 
620 bool
623 {
624  bool result;
625 
626  // Preconditions:
627 
628  require(state_is_read_accessible());
629 
630  // Body:
631 
632  result = powerset_member(index())->has_id_space();
633 
634  // Postconditions:
635 
636  ensure(is_basic_query);
637 
638  // Exit:
639 
640  return result;
641 }
642 
643 bool
646 {
647  bool result;
648 
649  // Preconditions:
650 
651  require(state_is_read_accessible());
652 
653  // Body:
654 
655  result = powerset_member(index())->is_persistent();
656 
657  // Postconditions:
658 
659  // Exit:
660 
661  return result;
662 }
663 
664 void
666 put_is_persistent(bool xis_persistent)
667 {
668  // Preconditions:
669 
670  require(state_is_read_write_accessible());
671 
672  // Body:
673 
674  powerset_member(index())->put_is_persistent(xis_persistent);
675 
676  // Postconditions:
677 
678  ensure(is_persistent() == xis_persistent);
679  ensure(has_id_space() ? id_space().is_persistent() == xis_persistent : true);
680 
681  // Exit:
682 
683  return;
684 }
685 
686 // PROTECTED MEMBER FUNCTIONS
687 
688 std::string
691 {
692  string result;
693 
694  // Preconditions:
695 
696  require(state_is_read_accessible());
697  require(!name().empty());
698 
699  // Body:
700 
701  result = name();
702 
703  // Postconditions:
704 
705  ensure(!result.empty());
706 
707  // Exit:
708 
709  return result;
710 }
711 
712 void
715 {
716  // Preconditions:
717 
718  require(state_is_read_write_accessible());
719  require(!has_id_space());
720  require(host()->member_id_spaces(false).contains(id_space_name()));
721 
722  // Body:
723 
724  powerset_member(index())->put_id_space(host()->member_id_spaces(false),
725  id_space_name());
726 
727  // Postconditions:
728 
729  ensure(has_id_space());
730 
731  // Exit:
732 
733  return;
734 }
735 
736 // PRIVATE MEMBER FUNCTIONS
737 
738 
739 // ===========================================================
740 // DOF SUBPOSET FACET
741 // ===========================================================
742 
743 // PUBLIC MEMBER FUNCTIONS
744 
745 bool
748 {
749  bool result;
750 
751  // Preconditions:
752 
753  require(state_is_read_accessible());
754 
755  // Body:
756 
757  result = powerset_member(index())->is_dof_subposet();
758 
759  // Postconditions:
760 
761  // Exit:
762 
763  return result;
764 }
765 
766 void
768 put_is_dof_subposet(bool xis_dof_subposet)
769 {
770  // Preconditions:
771 
772  require(state_is_read_write_accessible());
773 
774  // Body:
775 
776  powerset_member(index())->put_is_dof_subposet(xis_dof_subposet);
777 
778  // Postconditions:
779 
780  ensure(is_dof_subposet() == xis_dof_subposet);
781 
782  // Exit:
783 
784  return;
785 }
786 
787 int
789 dof_ct() const
790 {
791  int result;
792 
793  // Preconditions:
794 
795  require(state_is_read_accessible());
796 
797  // Body:
798 
799  result = powerset_member(index())->dof_ct();
800 
801  // Postconditions:
802 
803  ensure(result >= 0);
804 
805  // Exit:
806 
807  return result;
808 }
809 
810 void
812 put_dof_ct(int xct)
813 {
814  // Preconditions:
815 
816  require(state_is_read_write_accessible());
817  require(xct >= 0);
818 
819  // Body:
820 
821  powerset_member(index())->put_dof_ct(xct);
822 
823  // Postconditions:
824 
825  ensure(dof_ct() == xct);
826 
827  // Exit:
828 
829  return;
830 }
831 
835 {
836  dof_descriptor_array* result;
837 
838  // Preconditions:
839 
840  require(state_is_read_accessible());
841 
842  // Body:
843 
844  result = powerset_member(index())->dof_descriptors();
845 
846  // Postconditions:
847 
848  // Exit:
849 
850  return result;
851 }
852 
853 void
856 {
857  // Preconditions:
858 
859  require(state_is_read_write_accessible());
860 
861  // Body:
862 
863  powerset_member(index())->put_dof_descriptors(xoffsets);
864 
865  // Postconditions:
866 
867  ensure(dof_descriptors() == xoffsets);
868 
869  // Exit:
870 
871  return;
872 }
873 
874 // PROTECTED MEMBER FUNCTIONS
875 
876 // PRIVATE MEMBER FUNCTIONS
877 
878 
879 // ===========================================================
880 // MEMBERSHIP FACET
881 // ===========================================================
882 
883 // PUBLIC MEMBER FUNCTIONS
884 
885 int
887 member_ct() const
888 {
889  // Preconditions:
890 
891  require(state_is_read_accessible());
892 
893  // Body:
894 
900 
901  int result = members()->true_ct();
902 
903  // Postconditions:
904 
905  ensure(result >= 0);
906 
907  return result;
908 }
909 
913 {
914  subposet_member_iterator* result;
915 
916  // Preconditions:
917 
918  require(state_is_read_accessible());
919 
920  // Body:
921 
922  subposet* cthis = const_cast<subposet*>(this);
923  result = new subposet_member_iterator(*cthis);
924 
925  // Postconditions:
926 
927  // Exit
928 
929  return result;
930 }
931 
935 {
936  // Preconditions:
937 
938  require(state_is_read_accessible());
939 
940  // Body:
941 
942  index_iterator result(members(), _host->member_hub_id_space(false));
943 
944  // Postconditions:
945 
946  ensure(!result.is_done() ? result.index().same_scope(host()->member_id(false)) : true);
947 
948  // Exit
949 
950  return result;
951 }
952 
953 bool
955 contains_member(pod_index_type xmbr_hub_id) const
956 {
957  // Preconditions:
958 
959  require(state_is_read_accessible());
960 
961  // Body:
962 
963  zn_to_bool* lmembers = members();
964 
965  // Now query the bit vector.
966  // We could incorporate the bounds check into the query
967  // but it would be more expensive to evaluate.
968 
969  bool result = lmembers->index_in_bounds(xmbr_hub_id) ? (*lmembers)[xmbr_hub_id] : false;
970 
971  // Postconditions:
972 
973  // Exit:
974 
975  return result;
976 }
977 
978 bool
980 contains_member(const scoped_index& xmbr_id) const
981 {
982  // Preconditions:
983 
984  require(state_is_read_accessible());
985 
986  // Body:
987 
988  return contains_member(xmbr_id.hub_pod());
989 }
990 
991 bool
993 contains_member(const std::string& xname) const
994 {
995  bool result;
996 
997  // Preconditions:
998 
999  require(state_is_read_accessible());
1000  require(!xname.empty());
1001 
1002  // Body:
1003 
1004  pod_index_type lindex = host()->member_id(xname, false);
1005  result = is_valid(lindex) ? contains_member(lindex) : false;
1006 
1007  // Postconditions:
1008 
1009  // Exit:
1010 
1011  return result;
1012 }
1013 
1014 bool
1016 contains_members(const block<pod_index_type>& xmbr_hub_ids) const
1017 {
1018  // Preconditions:
1019 
1020  require(state_is_read_accessible());
1021 
1022  // Body:
1023 
1024  bool result = true;
1025  int i = 0;
1026 
1027  while(result && i < xmbr_hub_ids.ct())
1028  {
1029  result = contains_member(xmbr_hub_ids[i]);
1030  i++;
1031  };
1032 
1033  // Postconditions:
1034 
1035  ensure(unexecutable("for all i in xmbr_hub_ids: contains_member(i)")) ;
1036 
1037  // Exit
1038 
1039  return result;
1040 }
1041 
1042 bool
1045 {
1046  // Preconditions:
1047 
1048  require(state_is_read_accessible());
1049 
1050  // Body:
1051 
1052  bool result = true;
1053  int i = 0;
1054 
1055  while(result && i < xmbr_ids.ct())
1056  {
1057  result = contains_member(xmbr_ids[i]);
1058  i++;
1059  };
1060 
1061  // Postconditions:
1062 
1063  ensure(unexecutable("for all i in xmbr_ids: contains_member(i)")) ;
1064 
1065  // Exit
1066 
1067  return result;
1068 }
1069 
1070 bool
1073 {
1074  // Preconditions:
1075 
1076  require(xmbr != 0);
1077 
1078  // Body:
1079 
1080  bool result = contains_member(xmbr->index());
1081 
1082  // Postconditions:
1083 
1084  // Exit:
1085 
1086  return result;
1087 }
1088 
1089 void
1092 {
1093 
1094  // Preconditions:
1095 
1096  require(state_is_read_write_accessible());
1097 
1098  // Body:
1099 
1100  members()->put(xmbr_hub_id, true);
1101 
1102  // Postconditions:
1103 
1104  ensure(invariant());
1105  ensure(contains_member(xmbr_hub_id));
1106 
1107  // Exit:
1108 
1109  return;
1110 }
1111 
1112 void
1115 {
1116 
1117  // Preconditions:
1118 
1119  require(state_is_read_write_accessible());
1120 
1121  // Body:
1122 
1123  insert_member(xmbr_id.hub_pod());
1124 
1125  // Postconditions:
1126 
1127  ensure(invariant());
1128  ensure(contains_member(xmbr_id));
1129 
1130  // Exit:
1131 
1132  return;
1133 }
1134 
1135 void
1138 {
1139  // Preconditions:
1140 
1141  require(state_is_read_write_accessible());
1142 
1143  // Body:
1144 
1145  for(int i=0; i<xmbr_hub_ids.ct(); i++)
1146  {
1147  members()->put(xmbr_hub_ids[i], true);
1148  }
1149 
1150  // Postconditions:
1151 
1152  ensure(invariant());
1153  ensure(contains_members(xmbr_hub_ids));
1154 
1155  // Exit:
1156 
1157  return;
1158 }
1159 
1160 void
1163 {
1164  // Preconditions:
1165 
1166  require(state_is_read_write_accessible());
1167 
1168  // Body:
1169 
1170  for(int i=0; i<xmbr_ids.ct(); i++)
1171  {
1172  members()->put(xmbr_ids[i].hub_pod(), true);
1173  }
1174 
1175  // Postconditions:
1176 
1177  ensure(invariant());
1178  ensure(contains_members(xmbr_ids));
1179 
1180  // Exit:
1181 
1182  return;
1183 }
1184 
1185 void
1188 {
1189  // Preconditions:
1190 
1191  require(state_is_read_write_accessible());
1192 
1193  // Body:
1194 
1195  members()->put(xmbr->index().hub_pod(), true);
1196 
1197  // Postconditions:
1198 
1199  ensure(invariant());
1200  ensure(contains_member(xmbr));
1201 
1202  // Exit:
1203 
1204  return;
1205 }
1206 
1207 void
1210 {
1211  // Preconditions:
1212 
1213  require(state_is_read_write_accessible());
1214 
1215  // Body:
1216 
1217  members()->put(xmbr_hub_id, false);
1218 
1219  // Postconditions:
1220 
1221  ensure(invariant());
1222  ensure(!contains_member(xmbr_hub_id));
1223 
1224  // Exit:
1225 
1226  return;
1227 }
1228 
1229 void
1232 {
1233  // Preconditions:
1234 
1235  require(state_is_read_write_accessible());
1236 
1237  // Body:
1238 
1239  remove_member(xmbr_id.hub_pod());
1240 
1241  // Postconditions:
1242 
1243  ensure(invariant());
1244  ensure(!contains_member(xmbr_id));
1245 
1246  // Exit:
1247 
1248  return;
1249 }
1250 
1251 void
1254 {
1255  // Preconditions:
1256 
1257  require(state_is_read_write_accessible());
1258 
1259  // Body:
1260 
1261  members()->put(xmbr->index().hub_pod(), false);
1262 
1263  // Postconditions:
1264 
1265  ensure(invariant());
1266  ensure(!contains_member(xmbr));
1267 
1268  // Exit:
1269 
1270  return;
1271 }
1272 
1273 // PROTECTED MEMBER FUNCTIONS
1274 
1277 members() const
1278 {
1279  zn_to_bool* result;
1280 
1281  // Preconditions:
1282 
1283  require(is_attached());
1284  require(state_is_read_accessible());
1285 
1286  // Body:
1287 
1291 
1292  result = powerset_member(index())->members();
1293 
1294  // Postconditions:
1295 
1296  ensure(invariant());
1297  ensure(result != 0);
1298 
1299  // Exit
1300 
1301  return result;
1302 }
1303 
1306 membership() const
1307 {
1308  zn_to_bool::word_t* result;
1309 
1310  // Preconditions:
1311 
1312  require(is_attached());
1313  require(state_is_read_accessible());
1314 
1315  // Body:
1316 
1317  result = members()->values();
1318 
1319  // Postconditions:
1320 
1321  ensure(invariant());
1322  ensure(result != 0);
1323 
1324  // Exit:
1325 
1326  return result;
1327 }
1328 
1329 // PRIVATE MEMBER FUNCTIONS
1330 
1331 
1332 // ===========================================================
1333 // SET ALGEBRA FACET
1334 // ===========================================================
1335 
1336 // PUBLIC MEMBER FUNCTIONS
1337 
1338 bool
1340 is_empty() const
1341 {
1342  bool result;
1343 
1344  // Preconditions:
1345 
1346  require(state_is_read_accessible());
1347 
1348  // Body:
1349 
1350  result = members()->is_false();
1351 
1352  // Postconditions:
1353 
1354  // Exit
1355 
1356  return result;
1357 }
1358 
1359 void
1362 {
1363 
1364  // Preconditions:
1365 
1366  require(state_is_read_write_accessible());
1367 
1368  // Body:
1369 
1370  members()->make_false_sa();
1371 
1372  // Postconditions:
1373 
1374  // Exit
1375 
1376  return;
1377 }
1378 
1379 bool
1381 is_equal_to(const subposet* other) const
1382 {
1383  bool result;
1384 
1385  // Preconditions:
1386 
1387  require(state_is_read_accessible());
1388  require(other != 0);
1389  require(host()->is_same_state(other->host()));
1390 
1391  // Body:
1392 
1393  result = members()->is_equal_to(other->members());
1394 
1395  // Postconditions:
1396 
1397  ensure(unexecutable(other has same mebrs as this));
1398 
1399  // Exit
1400 
1401  return result;
1402 }
1403 
1404 void
1407 {
1408  // Preconditions:
1409 
1410  require(state_is_read_write_accessible());
1411  require(other != 0);
1412  require(host()->is_same_state(other->host()));
1413 
1414  // Body:
1415 
1416  other->members()->equal_pa(members());
1417 
1418  // Postconditions:
1419 
1420  // Exit
1421 
1422  return;
1423 }
1424 
1425 bool
1427 includes(const subposet* other) const
1428 {
1429  bool result;
1430 
1431  // Preconditions:
1432 
1433  require(other != 0);
1434 
1435  // Body:
1436 
1437  result = members()->includes(other->members());
1438 
1439  // Postconditions:
1440 
1441  // Exit
1442 
1443  return result;
1444 }
1445 
1448 p_union(const subposet* other)
1449 {
1450  subposet* result;
1451 
1452  // Preconditions:
1453 
1454  require( state_is_read_write_accessible() );
1455  require( other != 0);
1456  require( host() == other->host());
1457 
1458  // Body:
1459 
1460  result = new subposet( host() );
1461  p_union_pa(other, result);
1462 
1463  // Postconditions:
1464 
1465  ensure(result != 0);
1466 
1467  // for all i: result->contains_member(i) == contains_member(i) || other->contains_member(i)
1468 
1469  ensure(invariant());
1470 
1471  // Exit
1472 
1473  return result;
1474 }
1475 
1476 void
1478 p_union_pa(const subposet* other, subposet* result)
1479 {
1480  // Preconditions:
1481 
1482  require( state_is_read_write_accessible() );
1483  require( other != 0 );
1484  require( host() == other->host());
1485  require( result != 0 );
1486  require( host() == result->host());
1487 
1488  // Body:
1489 
1490  members()->b_or_pa(other->members(), result->members());
1491 
1492  // Postconditions:
1493 
1494  // for all i: result->contains_member(i) == contains_member(i) || other->contains_member(i)
1495 
1496  ensure(invariant());
1497 
1498  // Exit:
1499 
1500  return;
1501 }
1502 
1503 void
1505 p_union_sa(const subposet* other)
1506 {
1507  // Preconditions:
1508 
1509  require( state_is_read_write_accessible() );
1510  require( other != 0 );
1511  require( host() == other->host());
1512 
1513  // Body:
1514 
1515  p_union_pa(other, this);
1516 
1517  // Postconditions:
1518 
1519  ensure(unexecutable("for all i: contains_member(i) == old contains_member(i) || other->contains_member(i)"));
1520  ensure(invariant());
1521 
1522  // Exit:
1523 
1524  return;
1525 }
1526 
1530 {
1531  subposet* result;
1532 
1533  // Preconditions:
1534 
1535  require( state_is_read_write_accessible() );
1536  require( other != 0);
1537  require( host() == other->host());
1538 
1539  // Body:
1540 
1541  result = new subposet( host() );
1542 
1543  p_intersection_pa(other, result);
1544 
1545  // Postconditions:
1546 
1547  ensure(invariant());
1548  ensure(result != 0);
1549  ensure(postcondition_of(p_intersection_pa));
1550 
1551  // Exit
1552 
1553  return result;
1554 }
1555 
1556 void
1558 p_intersection_pa(const subposet* other, subposet* result)
1559 {
1560  // Preconditions:
1561 
1562  require( state_is_read_write_accessible() );
1563  require( other != 0 );
1564  require( host() == other->host());
1565  require( result != 0 );
1566  require( host() == result->host());
1567 
1568  // Body:
1569 
1570  members()->b_and_pa(other->members(), result->members());
1571 
1572  // Postconditions:
1573 
1574  ensure(invariant());
1575  ensure(unexecutable(forall i: result->contains_member(i) ==
1576  old contains_member(i) && other->contains_member(i)));
1577 
1578  // Exit
1579 
1580  return;
1581 }
1582 
1583 void
1586 {
1587  // Preconditions:
1588 
1589  require( state_is_read_write_accessible() );
1590  require( other != 0 );
1591  require( host() == other->host());
1592 
1593  // Body:
1594 
1595  p_intersection_pa(other, this);
1596 
1597  // Postconditions:
1598 
1599  ensure(postcondition_of(p_intersection_pa));
1600 
1601  // Exit
1602 
1603  return;
1604 }
1605 
1608 p_minus(const subposet* other)
1609 {
1610  subposet* result;
1611 
1612  // Preconditions:
1613 
1614  require( state_is_read_write_accessible() );
1615  require( other != 0);
1616  require( host() == other->host());
1617 
1618  // Body:
1619 
1620  result = new subposet( host());
1621 
1622  p_minus_pa(other, result);
1623 
1624  // Postconditions:
1625 
1626  ensure(invariant());
1627  ensure(result != 0);
1628  ensure(postcondition_of(p_minus_pa));
1629 
1630  // Exit
1631 
1632  return result;
1633 }
1634 
1635 void
1637 p_minus_pa(const subposet* other, subposet * result)
1638 {
1639  // Preconditions:
1640 
1641  require( state_is_read_write_accessible() );
1642  require( other != 0 );
1643  require( host() == other->host());
1644  require( result != 0 );
1645  require( host() == result->host());
1646 
1647  // Body:
1648 
1649  members()->b_and_not_pa(other->members(), result->members());
1650 
1651  // Postconditions:
1652 
1653  ensure(invariant());
1654  ensure(unexecutable("forall i: result->contains_member(i) == old contains_member(i) && !other->contains_member(i)"));
1655 
1656  // Exit
1657 
1658  return;
1659 }
1660 
1661 void
1663 p_minus_sa(const subposet* other)
1664 {
1665  // Preconditions:
1666 
1667  require( state_is_read_write_accessible() );
1668  require( other != 0 );
1669  require( host() == other->host());
1670 
1671  // Body:
1672 
1673  p_minus_pa(other, this);
1674 
1675  // Postconditions:
1676 
1677  ensure(invariant());
1678  ensure(postcondition_of(p_minus_pa));
1679 
1680  // Exit
1681 
1682  return;
1683 }
1684 
1688 {
1689  subposet* result = 0; // initialize just to keep compiler from complaining
1690 
1691  // Preconditions:
1692 
1693  require(state_is_read_write_accessible());
1694 
1695  // Body:
1696 
1697  result = new subposet( host());
1698 
1699  p_not_pa(result);
1700 
1701  // Postconditions:
1702 
1703  ensure(invariant());
1704 
1705  // Exit
1706 
1707  return result;
1708 }
1709 
1710 void
1713 {
1714  // Preconditions:
1715 
1716  require(state_is_read_write_accessible());
1717  require(result != 0);
1718 
1719  // Body:
1720 
1721  members()->b_not_pa(result->members());
1722 
1723  // Postconditions:
1724 
1725  ensure(invariant());
1726 
1727  // Exit
1728 
1729  return;
1730 }
1731 
1732 void
1735 {
1736  // Preconditions:
1737 
1738  require(state_is_read_write_accessible());
1739 
1740  // Body:
1741 
1742  members()->b_not_sa();
1743 
1744  // Postconditions:
1745 
1746  ensure(invariant());
1747 
1748  // Exit
1749 
1750  return;
1751 }
1752 
1753 // PROTECTED MEMBER FUNCTIONS
1754 
1755 // PRIVATE MEMBER FUNCTIONS
1756 
1757 
1758 // ===========================================================
1759 // POSET ALGEBRA FACET
1760 // ===========================================================
1761 
1762 // PUBLIC MEMBER FUNCTIONS
1763 
1766 extremals(bool xmaximals)
1767 {
1768  subposet* result;
1769 
1770  // Preconditions:
1771 
1772  require(state_is_read_write_accessible());
1773 
1774  // Body:
1775 
1776  result = new subposet(host());
1777  extremals_pa(xmaximals, result);
1778 
1779  // Postconditions:
1780 
1781  ensure(invariant());
1782  ensure(postcondition_of(extremals_pa));
1783 
1784  // Exit
1785 
1786  return result;
1787 }
1788 
1789 void
1791 extremals_pa(bool xmaximals, subposet* result)
1792 {
1793  // Preconditions:
1794 
1795  require( state_is_read_write_accessible() );
1796  require( result != 0 );
1797  require( result->host() == host() );
1798  require( result->is_empty() );
1799  require( !is_same_state(result) );
1800 
1801  // Body:
1802 
1803  // Prepare an down/up set iterator
1804  // down for maximals, up for minimals
1805 
1806  preorder_iterator itr(host()->top(), "", xmaximals);
1807 
1808  // We want iteration in the loop below to be strict.
1809  // Since we don't reference itr again until we reset it,
1810  // can set strict now to keep it out of the loop.
1811 
1813 
1814  itr.put_strict(true);
1815 
1816  // Iterate over the directional-set of each member of this
1817 
1818  // Must intialize itr outside
1819  // the loop below and can not
1820  // avoid marking some member visited when
1821  // we do. So insert first member in result
1822  // whether itr has visited it or not.
1823 
1824  bool first = true;
1825 
1826  index_iterator sp_itr = indexed_member_iterator();
1827  while(!sp_itr.is_done())
1828  {
1829  scoped_index lsp_mbr_id = sp_itr.index();
1830 
1831  if(first || !itr.has_visited(lsp_mbr_id))
1832  {
1833  first = false;
1834 
1835  // Current member is not bounded by some
1836  // member that has already been visited so
1837  // assume it is extremal
1838 
1839  result->insert_member(lsp_mbr_id);
1840 
1841  // Members of the strict down/up-set of current
1842  // can not be extremal, remove them from result.
1843  // (Removing non-members doesn't hurt.)
1844  // By not reseting the visited markers, we ensure
1845  // that we only traverse the down/up-set of each member
1846  // once and we don't reinsert some member that has
1847  // already been removed from the result.
1848 
1849  itr.put_anchor(lsp_mbr_id);
1850  itr.reset(sheaf::NO_RESET);
1851  while(!itr.is_done())
1852  {
1853  result->remove_member(itr.index());
1854  itr.next();
1855  }
1856  }
1857  sp_itr.next();
1858  }
1859 
1860  // Postconditions:
1861 
1862  ensure(invariant());
1863  ensure(unexecutable(result contains extremal members of this));
1864 
1865  // Exit
1866 
1867  return;
1868 }
1869 
1873 {
1874  subposet* result;
1875 
1876  // Preconditions:
1877 
1878  require(precondition_of(extremals(true)));
1879 
1880  // Body:
1881 
1882  result = extremals(true);
1883 
1884  // Postconditions:
1885 
1886  ensure(postcondition_of(extremals(true)));
1887 
1888  // Exit:
1889 
1890  return result;
1891 }
1892 
1893 void
1896 {
1897  // Preconditions:
1898 
1899  require(precondition_of(extremals_pa(true, result)));
1900 
1901  // Body:
1902 
1903  extremals_pa(true, result);
1904 
1905  // Postconditions:
1906 
1907  ensure(postcondition_of(extremals_pa(true, result)));
1908 
1909  // Exit:
1910 
1911  return;
1912 }
1913 
1917 {
1918  subposet* result;
1919 
1920  // Preconditions:
1921 
1922  require(precondition_of(extremals(false)));
1923 
1924  // Body:
1925 
1926  result = extremals(false);
1927 
1928  // Postconditions:
1929 
1930  ensure(postcondition_of(extremals(false)));
1931 
1932  // Exit:
1933 
1934  return result;
1935 }
1936 
1937 void
1940 {
1941  // Preconditions:
1942 
1943  require(precondition_of(extremals_pa(false, result)));
1944 
1945  // Body:
1946 
1947  extremals_pa(false, result);
1948 
1949  // Postconditions:
1950 
1951  ensure(postcondition_of(extremals_pa(false, result)));
1952 
1953  // Exit:
1954 
1955  return;
1956 }
1957 
1960 down() const
1961 {
1962  subposet* result;
1963 
1964  // Preconditions:
1965 
1966  require(state_is_read_write_accessible());
1967 
1968  // Body:
1969 
1970  result = new subposet(host());
1971  down_pa(result);
1972 
1973  // Postconditions:
1974 
1975  ensure(invariant());
1976  ensure(postcondition_of(down_pa));
1977 
1978  // Exit
1979 
1980  return result;
1981 }
1982 
1983 void
1985 down_pa(subposet* result) const
1986 {
1987  // Preconditions:
1988 
1989  require( state_is_read_write_accessible() );
1990  require( result != 0 );
1991  require( result->host() == host() );
1992  require( result->is_empty());
1993 
1994  // Body:
1995 
1996  poset_slicer slicer(host());
1997  slicer.down_set_pa(this, result);
1998 
1999  // Postconditions:
2000 
2001  ensure(invariant());
2002 
2003  // Exit
2004 
2005  return;
2006 }
2007 
2010 up() const
2011 {
2012  subposet* result;
2013 
2014  // Preconditions:
2015 
2016  require(state_is_read_write_accessible());
2017 
2018  // Body:
2019 
2020  result = new subposet(host());
2021  up_pa(result);
2022 
2023  // Postconditions:
2024 
2025  ensure(invariant());
2026  ensure(postcondition_of(up_pa));
2027 
2028  // Exit
2029 
2030  return result;
2031 }
2032 
2033 void
2035 up_pa(subposet* result) const
2036 {
2037  // Preconditions:
2038 
2039  require( state_is_read_write_accessible() );
2040  require( result != 0 );
2041  require( result->host() == host() );
2042  require( result->is_empty() );
2043 
2044  // Body:
2045 
2046  poset_slicer slicer(host());
2047  slicer.up_set_pa(this, result);
2048 
2049  // Postconditions:
2050 
2051  ensure(invariant());
2052 
2053  // Exit
2054 
2055  return;
2056 }
2057 
2061 {
2062  subposet* result;
2063 
2064  // Preconditions:
2065 
2066  require(state_is_read_write_accessible());
2067 
2068  // Body:
2069 
2070  result = new subposet(host());
2071  jims_pa(result);
2072 
2073  // Postconditions:
2074 
2075  ensure(invariant());
2076  ensure(unexecutable(result contains jims in down set
2077  of this));
2078 
2079  // Exit
2080 
2081  return result;
2082 }
2083 
2084 void
2087 {
2088  // Preconditions:
2089 
2090  require( state_is_read_write_accessible() );
2091  require( result != 0 );
2092  require( result->host() == host());
2093  require( result->is_empty() );
2094 
2095  // Body:
2096 
2097  poset_slicer slicer(host());
2098  slicer.find_jims_pa(this, result);
2099 
2100  // Postconditions:
2101 
2102  ensure(invariant());
2103  ensure(unexecutable(result contains jims in down set
2104  of this));
2105 
2106  // Exit
2107 
2108  return;
2109 }
2110 
2114 {
2115  subposet* result;
2116 
2117  // Preconditions:
2118 
2119  require(state_is_read_write_accessible());
2120 
2121  // Body:
2122 
2123  result = new subposet(host());
2124  maximal_jims_pa(result);
2125 
2126  // Postconditions:
2127 
2128  ensure(invariant());
2129  ensure(postcondition_of(maximal_jims_pa));
2130 
2131  // Exit
2132 
2133  return result;
2134 }
2135 
2136 void
2139 {
2140  // Preconditions:
2141 
2142  require( state_is_read_write_accessible() );
2143  require( result != 0 );
2144  require( result->host() == host() );
2145  require( result->is_empty() );
2146 
2147  // Body:
2148 
2149  poset_slicer slicer(host());
2150  slicer.find_jims_pa(this, result, poset_slicer::MAXIMAL);
2151 
2152  // Postconditions:
2153 
2154  ensure(invariant());
2155 
2156  // Exit
2157 
2158  return;
2159 }
2160 
2164 {
2165  subposet* result;
2166 
2167  // Preconditions:
2168 
2169  require(state_is_read_write_accessible());
2170 
2171  // Body:
2172 
2173  result = new subposet(host());
2174  minimal_jims_pa(result);
2175 
2176  // Postconditions:
2177 
2178  ensure(invariant());
2179  ensure(postcondition_of(minimal_jims_pa));
2180 
2181  // Exit
2182 
2183  return result;
2184 }
2185 
2186 void
2189 {
2190  // Preconditions:
2191 
2192  require( state_is_read_write_accessible() );
2193  require( result != 0 );
2194  require( result->host() == host() );
2195  require( result->is_empty() );
2196 
2197  // Body:
2198 
2199  poset_slicer slicer(host());
2200  slicer.find_jims_pa(this, result, poset_slicer::MINIMAL);
2201 
2202  // Postconditions:
2203 
2204  ensure(invariant());
2205 
2206  // Exit
2207 
2208  return;
2209 }
2210 
2214 {
2215  poset_member* result;
2216 
2217  // Preconditions:
2218 
2219  require(state_is_read_write_accessible());
2220 
2221  // Body:
2222 
2223  result = new poset_member();
2224  p_join_pa(result);
2225 
2226  // Postconditions:
2227 
2228  require(invariant());
2229  require(postcondition_of(p_join_pa));
2230 
2231  // Exit
2232 
2233  return result;
2234 }
2235 
2236 void
2239 {
2240  // Preconditions:
2241 
2242  require( state_is_read_write_accessible() );
2243  require( result != 0 );
2244 
2245  // Body:
2246 
2248 
2249  not_implemented();
2250 
2251  // Postconditions:
2252 
2253  ensure(invariant());
2254 
2255  // Exit
2256 
2257  return;
2258 }
2259 
2260 
2264 {
2265  poset_member* result;
2266 
2267  // Preconditions:
2268 
2269  require(state_is_read_write_accessible());
2270 
2271  // Body:
2272 
2273  result = new poset_member();
2274  p_meet_pa(result);
2275 
2276  // Postconditions:
2277 
2278  ensure(invariant());
2279  ensure(postcondition_of(p_meet_pa));
2280 
2281  // Exit
2282 
2283  return result;
2284 }
2285 
2286 void
2289 {
2290  // Preconditions:
2291 
2292  require( state_is_read_write_accessible() );
2293  require( result != 0 );
2294 
2295  // Body:
2296 
2298 
2299  not_implemented();
2300 
2301  // Postconditions:
2302 
2303  ensure(invariant());
2304 
2305  // Exit
2306 
2307  return;
2308 }
2309 
2310 // PROTECTED MEMBER FUNCTIONS
2311 
2312 // PRIVATE MEMBER FUNCTIONS
2313 
2314 
2315 // ===========================================================
2316 // LATTICE ALGEBRA FACET
2317 // ===========================================================
2318 
2319 // PUBLIC MEMBER FUNCTIONS
2320 
2323 l_join(bool xnew_jem)
2324 {
2325  poset_member* result;
2326 
2327  // Preconditions:
2328 
2329  require(state_is_read_write_accessible());
2332  require(!is_empty());
2333 
2334  // Body:
2335 
2336  result = new poset_member();
2337  l_join_pa(result);
2338 
2339  // Postconditions:
2340 
2341  ensure(invariant());
2342  ensure(postcondition_of(l_join_pa));
2343 
2344  // Exit
2345 
2346  return result;
2347 }
2348 
2349 void
2351 l_join_pa(abstract_poset_member* result, bool xnew_jem)
2352 {
2353  // Preconditions:
2354 
2355  require( state_is_read_write_accessible() );
2356  require( result != 0 );
2357 
2358  // Body:
2359 
2360  if(is_empty())
2361  {
2362  // The join of the empty set is the bottom.
2363 
2364  if(xnew_jem)
2365  {
2366  result->new_jem_state(&host()->bottom(), true, false);
2367  }
2368  else
2369  {
2370  result->attach_to_state(&host()->bottom());
2371  }
2372  }
2373  else
2374  {
2375  // Join the members.
2376 
2377  poset_joiner joiner(host());
2378  joiner.join(this, (xnew_jem ? tern::TRUE : tern::NEITHER), *result);
2379  }
2380 
2381  // Postconditions:
2382 
2383  ensure(invariant());
2384 
2385  // Exit
2386 
2387  return;
2388 }
2389 
2392 l_join_jims(bool xnew_jem)
2393 {
2394  poset_member* result;
2395 
2396  // Preconditions:
2397 
2398  require(state_is_read_write_accessible());
2399  require(unexecutable(this is a down set
2400  containing only jims));
2401 
2402 
2403  // Body:
2404 
2405  result = new poset_member();
2406  l_join_jims_pa(result, xnew_jem);
2407 
2408  // Postconditions:
2409 
2410  ensure(invariant());
2411  ensure(postcondition_of(l_join_jims_pa));
2412 
2413  // Exit
2414 
2415  return result;
2416 }
2417 
2418 void
2420 l_join_jims_pa(abstract_poset_member* result, bool xnew_jem)
2421 {
2422  // Preconditions:
2423 
2424  require( state_is_read_write_accessible() );
2425  require(unexecutable(this is a down set
2426  containing only jims));
2427  require( result != 0 );
2428 
2429  // Body:
2430 
2431  poset_joiner joiner(host());
2432  joiner.join(this, (xnew_jem ? tern::TRUE : tern::NEITHER), *result);
2433 
2434  // Postconditions:
2435 
2436  ensure(invariant());
2437 
2438  // This routine adds members to this
2439 
2440  ensure(unexecutable(this->includes(old this)));
2441 
2442  // Includes the strict down set but may not contain result itself
2443 
2444  ensure(unexecutable("this includes the strict down set of result"));
2445 
2446  // Exit
2447 
2448  return;
2449 }
2450 
2453 l_meet(bool xnew_jem)
2454 {
2455  poset_member* result;
2456 
2457  // Preconditions:
2458 
2459  require(state_is_read_write_accessible());
2460 
2461  // Body:
2462 
2463  result = new poset_member();
2464  l_meet_pa(result, xnew_jem);
2465 
2466  // Postconditions:
2467 
2468  ensure(invariant());
2469  ensure(postcondition_of(l_meet_pa));
2470 
2471  // Exit
2472 
2473  return result;
2474 }
2475 
2476 void
2478 l_meet_pa(abstract_poset_member* result, bool xnew_jem)
2479 {
2480  // Preconditions:
2481 
2482  require( state_is_read_write_accessible() );
2483  require( result != 0 );
2484 
2485  // Body:
2486 
2490 
2491  subposet ljims0(host());
2492  subposet ljims1(host());
2493 
2494  subposet_member_iterator* itr = member_iterator();
2495  itr->jims_pa(&ljims0);
2496  itr->next();
2497 
2498  while(!itr->is_done())
2499  {
2500  itr->jims_pa(&ljims1);
2501  ljims0.p_intersection_sa(&ljims1);
2502  ljims1.make_empty();
2503  itr->next();
2504  }
2505 
2506  delete itr;
2507 
2508  ljims0.l_join_jims_pa(result, xnew_jem);
2509 
2510  // Postconditions:
2511 
2512  ensure(invariant());
2513 
2514  // Exit
2515 
2516  return;
2517 }
2518 
2519 // PROTECTED MEMBER FUNCTIONS
2520 
2521 // PRIVATE MEMBER FUNCTIONS
2522 
2523 
2524 // ===========================================================
2525 // COMPONENT INDEX FACET
2526 // ===========================================================
2527 
2528 // PUBLIC MEMBER FUNCTIONS
2529 
2530 bool
2532 is_valid_index(const poset_state_handle* xhost, pod_index_type xhub_id, int xversion) const
2533 {
2534  bool result;
2535 
2536  // Preconditions:
2537 
2538  require(xhost != 0);
2539  require(host_is_ancestor_of(xhost));
2540  require(xhost->state_is_read_accessible());
2541 
2542  // Body:
2543 
2544  // Subposets are the same for all versions; ignore xversion.
2545 
2546  result = xhost->includes_subposet(xhub_id, false);
2547 
2548  // Postconditions:
2549 
2550  // Exit
2551 
2552  return result;
2553 }
2554 
2555 bool
2557 is_valid_index(const poset_state_handle* xhost, const scoped_index& xid, int xversion) const
2558 {
2559  bool result = false;
2560 
2561  // Preconditions:
2562 
2563  require(xhost != 0);
2564  require(xhost->state_is_read_accessible());
2565  require(host_is_ancestor_of(xhost));
2566 
2567  // Body:
2568 
2569  return is_valid_index(xhost, xid.hub_pod(), xversion);
2570 }
2571 
2575 {
2576  // Preconditions:
2577 
2578  require(state_is_read_accessible());
2579 
2580  // Body:
2581 
2582  const hub_index_space_handle& result = _host->subposet_hub_id_space(false);
2583 
2584  // Postconditions:
2585 
2586  // Exit:
2587 
2588  return result;
2589 }
2590 
2591 const sheaf::scoped_index&
2593 hub_id() const
2594 {
2595  // Preconditions:
2596 
2597  require(state_is_read_accessible());
2598 
2599  // Body:
2600 
2601  const scoped_index& result = _host->subposet_id(false);
2602 
2603  // Postconditions:
2604 
2605  ensure(result.is_hub_scope());
2606 
2607  // Exit:
2608 
2609  return result;
2610 }
2611 
2615 {
2616  // Preconditions:
2617 
2618  require(state_is_read_accessible());
2619 
2620  // Body:
2621 
2622  scoped_index result = _host->subposet_id(xid, false);
2623 
2624  // Postconditions:
2625 
2626  ensure(result.is_hub_scope());
2627  ensure(result.pod() == xid);
2628 
2629  // Exit:
2630 
2631  return result;
2632 }
2633 
2636 get_index_from_name(const poset_state_handle* xhost, const std::string& xname) const
2637 {
2638  // Preconditions:
2639 
2640  require(xhost != 0);
2641  require(host_is_ancestor_of(xhost));
2642  require(xhost->state_is_read_accessible());
2643  require(!xname.empty());
2644 
2645  // Body:
2646 
2647  pod_index_type result = xhost->subposet_id(xname);
2648 
2649  // Postconditions:
2650 
2651  ensure(unexecutable(result.is_valid() implies subposet with index = result has name xname));
2652 
2653  // Exit
2654 
2655  return result;
2656 }
2657 
2658 void
2660 get_index_from_name(const poset_state_handle* xhost, const std::string& xname,
2661  scoped_index& result) const
2662 {
2663  // Preconditions:
2664 
2665  require(xhost != 0);
2666  require(host_is_ancestor_of(xhost));
2667  require(xhost->state_is_read_accessible());
2668  require(!xname.empty());
2669 
2670  // Body:
2671 
2672  xhost->subposet_id(xname, result);
2673 
2674  // Postconditions:
2675 
2676  ensure(unexecutable(result.is_valid() implies subposet with index = result has name xname));
2677 
2678  // Exit
2679 
2680  return;
2681 }
2682 
2683 // PROTECTED MEMBER FUNCTIONS
2684 
2685 // PRIVATE MEMBER FUNCTIONS
2686 
2687 
2688 // ===========================================================
2689 // COMPONENT NAME FACET
2690 // ===========================================================
2691 
2692 // PUBLIC MEMBER FUNCTIONS
2693 
2694 std::string
2696 name(bool xauto_access) const
2697 {
2698  string result;
2699 
2700  // Preconditions:
2701 
2702  require(xauto_access || state_is_read_accessible());
2703 
2704  // Body:
2705 
2706  result = host()->subposet_name(index(), xauto_access);
2707 
2708  // Postconditions:
2709 
2710  ensure(unexecutable(result.empty() implies this has no name));
2711 
2712  // Exit:
2713 
2714  return result;
2715 }
2716 
2717 void
2719 all_names(block<std::string>& xresult, bool xauto_access) const
2720 {
2721  // Preconditions:
2722 
2723  require(xauto_access || state_is_read_accessible());
2724 
2725  // Body:
2726 
2727  host()->all_subposet_names(_index, xresult, xauto_access);
2728 
2729  // Postconditions:
2730 
2731  ensure(xresult.ct() == name_ct(xauto_access));
2732  ensure_for_all(i, 0, xresult.ct(), !xresult[i].empty());
2733 
2734  // Exit:
2735 
2736  return;
2737 }
2738 
2741 name_ct(bool xauto_access) const
2742 {
2743  size_type result;
2744 
2745  // Preconditions:
2746 
2747  require(xauto_access || state_is_read_accessible());
2748 
2749  // Body:
2750 
2751  result = host()->subposet_name_ct(index(), xauto_access);
2752 
2753  // Postconditions:
2754 
2755  // Exit:
2756 
2757  return result;
2758 }
2759 
2760 bool
2762 has_name(const std::string& xname, bool xauto_access) const
2763 {
2764  // Preconditions:
2765 
2766  require(xauto_access || state_is_read_accessible());
2767  require(!xname.empty());
2768 
2769  // Body:
2770 
2771  bool result = host()->subposet_has_name(_index, xname, xauto_access);
2772 
2773  // Postconditions:
2774 
2775  // Exit
2776 
2777  return result;
2778 }
2779 
2780 void
2782 put_name(const std::string& xname, bool xunique, bool xauto_access)
2783 {
2784  // Preconditions:
2785 
2786  require(is_attached());
2787  require(xauto_access || state_is_read_write_accessible());
2788  require(poset_path::is_valid_name(xname));
2789 
2790  // Body:
2791 
2792  host()->put_subposet_name(index(), xname, xunique, xauto_access);
2793 
2794  // Postconditions:
2795 
2796  ensure(xunique ? (name(xauto_access) == xname) : has_name(xname, xauto_access));
2797 
2798  // Exit
2799 
2800  return;
2801 }
2802 
2803 void
2805 delete_name(const std::string& xname, bool xauto_access)
2806 {
2807  // Preconditions:
2808 
2809  require(xauto_access || state_is_read_write_accessible());
2810  require(!xname.empty());
2811 
2812  // Body:
2813 
2814  // poset_state_handle::delete_subposet_name will delete the name
2815  // whatever subposet it belongs to. Not what we want here.
2816  // Only delete the name is it belongs to this.
2817 
2818  if(xauto_access)
2819  {
2820  get_read_write_access(true);
2821  }
2822 
2823  if(has_name(xname, false))
2824  {
2825  host()->delete_subposet_name(xname, false);
2826  }
2827 
2828  if(xauto_access)
2829  {
2830  release_access();
2831  }
2832 
2833  // Postconditions:
2834 
2835  ensure(!has_name(xname, xauto_access));
2836 
2837  // Exit:
2838 
2839  return;
2840 }
2841 
2842 void
2844 delete_all_names(bool xauto_access)
2845 {
2846  // Preconditions:
2847 
2848  require(xauto_access || state_is_read_write_accessible());
2849 
2850  // Body:
2851 
2852  host()->delete_all_subposet_names(_index, xauto_access);
2853 
2854  // Postconditions:
2855 
2856  ensure(name_ct(xauto_access) == 0);
2857 
2858  // Exit:
2859 
2860  return;
2861 }
2862 
2863 // PROTECTED MEMBER FUNCTIONS
2864 
2865 // PRIVATE MEMBER FUNCTIONS
2866 
2867 
2868 // ===========================================================
2869 // STATE FACET
2870 // ===========================================================
2871 
2872 // PUBLIC MEMBER FUNCTIONS
2873 
2874 void
2876 delete_state(bool xauto_access)
2877 {
2878  // Preconditions:
2879 
2880  require(is_attached());
2881  require(xauto_access || state_is_read_write_accessible());
2882 
2883  // Body:
2884 
2885  if(xauto_access)
2886  {
2887  get_read_write_access(true);
2888  }
2889 
2890  poset_state_handle* lhost = _host;
2891  scoped_index lindex = _index;
2892  detach_from_state();
2893  lhost->delete_subposet(lindex);
2894 
2895  if(xauto_access)
2896  {
2897  release_access();
2898  }
2899 
2900  // Postconditions:
2901 
2902  ensure(!is_attached());
2903  ensure(unexecutable(!old host()->includes_subposet(old index())));
2904 
2905  // Exit:
2906 
2907  return;
2908 }
2909 
2910 // PROTECTED MEMBER FUNCTIONS
2911 
2912 // PRIVATE MEMBER FUNCTIONS
2913 
2914 
2915 // ===========================================================
2916 // ANY FACET
2917 // ===========================================================
2918 
2919 // PUBLIC MEMBER FUNCTIONS
2920 
2921 bool
2923 is_ancestor_of(const any* xother) const
2924 {
2925  bool result;
2926 
2927  // Preconditions:
2928 
2929  // Body:
2930 
2931  result = dynamic_cast<const subposet*>(xother) != 0;
2932 
2933  // Postconditions:
2934 
2935  // Exit
2936 
2937  return result;
2938 }
2939 
2942 clone() const
2943 {
2944  subposet* result;
2945 
2946  // Preconditions:
2947 
2948  // Body:
2949 
2950  result = new subposet;
2951 
2952  // Postconditions:
2953 
2954  ensure(result != 0);
2955 
2956  // Exit
2957 
2958  return result;
2959 }
2960 
2961 bool
2963 invariant() const
2964 {
2965  // class invariant
2966 
2967  bool result = true;
2968 
2969  // Base class invariant
2970 
2971  result = result && poset_component::invariant();
2972 
2973  if(invariant_check())
2974  {
2975  // prevent recursion in called queries
2976 
2977  disable_invariant_check();
2978 
2979  // Nothing to do
2980 
2981  // restore invariant checking
2982 
2983  enable_invariant_check();
2984  };
2985 
2986  return result;
2987 }
2988 
2989 // PROTECTED MEMBER FUNCTIONS
2990 
2991 // PRIVATE MEMBER FUNCTIONS
2992 
2993 
2994 // ===========================================================
2995 // DEBUGGING FACET
2996 // ===========================================================
2997 
2998 // PUBLIC MEMBER FUNCTIONS
2999 
3000 void
3002 to_stream(std::ostream& os)
3003 {
3004  cout << *this;
3005 }
3006 
3007 std::string
3010 {
3011  ostringstream oss;
3012  oss << *this;
3013  return oss.str();
3014 }
3015 
3016 // PROTECTED MEMBER FUNCTIONS
3017 
3018 // PRIVATE MEMBER FUNCTIONS
3019 
3020 
3021 // ===========================================================
3022 // NON-MEMBER FUNCTIONS
3023 // ===========================================================
3024 
3025 
3026 std::ostream&
3027 sheaf::
3028 operator<<(std::ostream& xos, const subposet& xs)
3029 {
3030  // Preconditions:
3031 
3032  require(xs.is_attached() ? xs.state_is_read_accessible() : true);
3033 
3034  // Body:
3035 
3036  if(xs.is_attached())
3037  {
3038  if(!(xs.name().empty()))
3039  {
3040  xos << setw(20) << xs.name();
3041  }
3042  else
3043  {
3044  xos << "<void>";
3045  }
3046 
3047  xos << " " << xs.host() << " " << xs.index() << " " << *xs.members() << endl;
3048  }
3049  else
3050  {
3051  xos << "<void> 0x0 " << scoped_index::INVALID() << endl;
3052  }
3053 
3054  // Postconditions:
3055 
3056  // Exit:
3057 
3058  return xos;
3059 }
3060 
3061 size_t
3062 sheaf::
3063 deep_size(const subposet& xsp, bool xinclude_shallow)
3064 {
3065  size_t result;
3066 
3067  // Preconditions:
3068 
3069  // Body:
3070 
3073 
3074  result = 0;
3075 
3076  // Postconditions:
3077 
3078  ensure(result == 0);
3079  //ensure(result >= 0);
3080 
3081  // Exit
3082 
3083  return result;
3084 }
3085 
virtual bool has_name(const std::string &xname, bool xauto_access=false) const
True if xname is a name for this.
Definition: subposet.cc:2762
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.
std::string name() const
Definition: subposet.h:796
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 ...
A client handle for a subposet.
Definition: subposet.h:86
bool is_equal_to(const subposet *other) const
True if this subposet has the same members as other.
Definition: subposet.cc:1381
bool is_valid() const
True if this is a valid id.
Definition: scoped_index.h:832
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
size_type ct() const
The number of items currently in use.
void to_stream(std::ostream &os=std::cout)
Prints out useful information for debugging.
Definition: subposet.cc:3002
const pod_type & pod() const
The "plain old data" storage of this; the value in the external id space.
Definition: scoped_index.h:672
poset_member * p_join()
Poset join of the members of this this, auto-allocated The poset join is the least upper bound in t...
Definition: subposet.cc:2213
void make_equal_to(const subposet *other)
Make this subposet have the same members as other.
Definition: subposet.cc:1406
poset_member * p_meet()
Poset meet of the members of this, auto-allocated The poset meet is the greatest lower bound in the...
Definition: subposet.cc:2263
subposet * p_intersection(const subposet *other)
Intersection of this with other, auto-allocated.
Definition: subposet.cc:1529
subposet_member_iterator * member_iterator() const
An iterator for members of this poset; handle version.
Definition: subposet.cc:912
subposet()
Default constructor, creates a new, unattached subposet.
Definition: subposet.cc:56
bool is_persistent() const
True if this id space should be written to disk.
Definition: subposet.cc:645
virtual bool has_id_space() const
True if this already has an id space.
Definition: subposet.cc:622
void maximal_jims_pa(subposet *result)
The maximal members of the set of jims contained in the down set of this subposet, pre-allocated.
Definition: subposet.cc:2138
poset_member * l_meet(bool xnew_jem=true)
Lattice meet of the members of this, auto-allocated The lattice meet is the greatest lower bound in...
Definition: subposet.cc:2453
void p_join_pa(abstract_poset_member *result)
Poset join of the members of this this, pre-allocated The poset join is the least upper bound in th...
Definition: subposet.cc:2238
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
virtual bool is_dof_subposet() const
True if this is a dofs subposet.
Definition: subposet.cc:747
void minimal_jims_pa(subposet *result)
The minimal members of the set of jims contained in the down set of this subposet, pre-allocated.
Definition: subposet.cc:2188
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.
void maximals_pa(subposet *result)
The subposet containing the maximal members of this, pre-allocated.
Definition: subposet.cc:1895
void up_pa(subposet *result) const
The up set of this subposet, pre-allocatd.
Definition: subposet.cc:2035
void l_join_pa(abstract_poset_member *result, bool xnew_jem=true)
Lattice join of the members of this, pre-allocated The lattice join is the least upper bound in the...
Definition: subposet.cc:2351
A client handle for a general, abstract partially order set.
virtual bool includes_subposet(pod_index_type xsubposet_hub_id, bool xauto_access=true) const
True if this poset includes subposet with hub id xsubposet_hub_id.
void p_union_pa(const subposet *other, subposet *result)
Union of this with other, pre-allocated.
Definition: subposet.cc:1478
const scoped_index & index() const
The current item in the subset.
subposet * minimals()
The subposet containing the minimal members of this, auto-allocated.
Definition: subposet.cc:1916
bool is_done() const
True if iteration finished.
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.
bool contains_members(const block< pod_index_type > &xmbr_hub_ids) const
True if this poset contains poset members with hub ids in xmbr_hub_ids.
Definition: subposet.cc:1016
~subposet()
Deletes this subposet and the state it is attached to, if any.
Definition: subposet.cc:117
void p_meet_pa(abstract_poset_member *result)
Poset meet of the members of this, pre-allocated The poset meet is the greatest lower bound in the ...
Definition: subposet.cc:2288
unsigned int word_t
The type of the private, internal representation used for bits; Unsigned int is the type used in the ...
Definition: zn_to_bool.h:160
virtual subposet & operator=(const subposet &xother)
Assignment operator; attaches this to the same state as xother.
Definition: subposet.cc:274
void p_intersection_pa(const subposet *other, subposet *result)
Intersection of this with other, pre-allocated.
Definition: subposet.cc:1558
const scoped_index & index() const
The index of the component state this handle is attached to.
An implementation of class sum_index_space_handle that has a primary sum id space state...
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...
Definition: subposet.cc:2593
virtual void delete_name(const std::string &xname, bool xauto_access=false)
Delete all names for this.
Definition: subposet.cc:2805
void down_pa(subposet *result) const
The down set of this subposet, pre-allocated.
Definition: subposet.cc:1985
subposet * up() const
The up set of this subposet, auto-allocated.
Definition: subposet.cc:2010
void next()
Makes item the next member of the subset.
subposet * down() const
The down set of this subposet, auto-allocated.
Definition: subposet.cc:1960
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 all_names(block< std::string > &xresult, bool xauto_access=false) const
All the names for this.
Definition: subposet.cc:2719
subposet * jims()
The set of jims contained in the down set of this subposet, auto-allocated.
Definition: subposet.cc:2060
subposet * minimal_jims()
The minimal members of the set of jims contained in the down set of this subposet, auto-allocated.
Definition: subposet.cc:2163
void next()
Makes this the next member of the subset.
Abstract base class with useful features for all objects.
Definition: any.h:39
bool has_visited(pod_index_type xhub_id) const
True if this has already visited member with hub id xhub_id.
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
void p_minus_pa(const subposet *other, subposet *result)
Difference of this and other (this minus other), pre-allocated.
Definition: subposet.cc:1637
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.
Definition: subposet.cc:2782
void put_is_persistent(bool xvalue)
Sets is_persistent() to xvalue.
Definition: subposet.cc:666
virtual dof_descriptor_array * dof_descriptors() const
The offset from beginning of the dof tuple of each dof.
Definition: subposet.cc:834
void make_empty()
Make this subposet the empty subposet.
Definition: subposet.cc:1361
poset_member * l_join_jims(bool xnew_jem=true)
Lattice join of the members of this, auto-allocated Requires this is a down set of jims...
Definition: subposet.cc:2392
A client handle for a restrictable member of a poset. A poset_member is a poset_member which can ...
Definition: poset_member.h:59
void l_meet_pa(abstract_poset_member *result, bool xnew_jem=true)
Lattice meet of the members of this, pre-allocated The lattice meet is the greatest lower bound in ...
Definition: subposet.cc:2478
virtual void delete_subposet(pod_index_type xsubposet_hub_id)
Deletes the subposet with hub id xsubposet_hub_id.
void jims_pa(subposet *result)
The set of jims contained in the down set of this subposet, pre-allocated.
Definition: subposet.cc:2086
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...
virtual pod_index_type new_subposet(bool xinitialize=true)
Creates a new subposet. If xinitialize, make the subposet empty,.
virtual bool invariant() const
Class invariant.
Definition: subposet.cc:2963
subposet * p_not()
Poset complement of this, auto-allocated.
Definition: subposet.cc:1687
bool includes(const subposet *other) const
True if all the members of other are also members of this.
Definition: subposet.cc:1427
subposet * maximals()
The subposet containing the maximal members of this, auto-allocated.
Definition: subposet.cc:1872
virtual scattered_insertion_index_space_handle & new_id_space(const std::string &xstate_class_name)
Creates an id space for the members of this.
Definition: subposet.cc:554
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
virtual bool is_attached() const
True if this handle is attached to a state.
bool index_in_bounds(int i) const
True if index i is in bounds for this vector.
Definition: zn_to_bool.cc:233
subposet * p_union(const subposet *other)
Union of this with other, auto-allocated.
Definition: subposet.cc:1448
virtual bool is_attached() const
True if this handle is attached to a non-void state.
SHEAF_DLL_SPEC size_t deep_size(const dof_descriptor_array &xp, bool xinclude_shallow=true)
The deep size of the referenced object of type dof_descriptor_array.
subposet * p_minus(const subposet *other)
Difference of this and other (this minus other), auto-allocated.
Definition: subposet.cc:1608
void equal_pa(const zn_to_bool *result)
OBSOLETE; use assignment operator.
Definition: zn_to_bool.cc:1005
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
void p_not_sa()
Poset complement of this, self-allocated.
Definition: subposet.cc:1734
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
void join(const scoped_index *xexpansion, int xexpansion_ct, const tern &xgreatest, abstract_poset_member &xresult)
The join of the members of xexpansion.
virtual void insert_members(const block< pod_index_type > &xmbr_hub_ids)
Inserts the members of host() with hub ids in xmbr_hub_ids.
Definition: subposet.cc:1137
bool is_empty() const
True if this poset is empty.
Definition: subposet.cc:1340
zn_to_bool::word_t * membership() const
The membership bit vector.
Definition: subposet.cc:1306
virtual size_type name_ct(bool xauto_access) const
The number of names for this.
Definition: subposet.cc:2741
virtual void put_dof_ct(int xct)
Set the number of dofs defined this, considered as a dof_subposet, to xct; Note: dof_ct() == member_c...
Definition: subposet.cc:812
void next()
Makes this the next member of the subset.
An array for storing structs which describe the size, alignment, and offset of dofs within a dof tupl...
void extremals_pa(bool xmaximals, subposet *result)
The subposet containing the extremal members of this, pre-allocated.
Definition: subposet.cc:1791
virtual std::string id_space_name() const
The name of the id space associated with this.
Definition: subposet.cc:690
std::string to_string()
Get useful information for debugging as a string.
Definition: subposet.cc:3009
virtual const hub_index_space_handle & hub_id_space() const
The hub id space; const version.
Definition: subposet.cc:2574
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
virtual void put_dof_descriptors(const dof_descriptor_array *xoffsets)
Set the offset from beginning of the dof tuple of each dof to xoffsets.
Definition: subposet.cc:855
subposet * maximal_jims()
The maximal members of the set of jims contained in the down set of this subposet, auto-allocated.
Definition: subposet.cc:2113
zn_to_bool * members() const
The characteristic function for the members of this.
Definition: subposet.cc:1277
virtual subposet * clone() const
Virtual constructor; makes a new instance of the same type as this.
Definition: subposet.cc:2942
virtual int dof_ct() const
Get the number of dofs defined this, considered as a dof_subposet; Note: dof_ct() == member_ct()...
Definition: subposet.cc:789
const bool NO_RESET
Iteration marker reset control.
Definition: sheaf.h:92
virtual bool is_ancestor_of(const any *other) const
True if other conforms to this.
Definition: subposet.cc:2923
bool is_done() const
True if iteration finished.
Iterates over the subset of Zn defined by the characteristic function host().
virtual void put_is_dof_subposet(bool xis_dof_subposet)
True if this is a dofs subposet.
Definition: subposet.cc:768
const scattered_insertion_index_space_handle & id_space() const
The id space for the members of with this (const version).
Definition: subposet.cc:508
void p_intersection_sa(const subposet *other)
Intersection of this with other, self-allocated.
Definition: subposet.cc:1585
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.
Definition: subposet.cc:2636
virtual void reset(bool xreset_markers=true)
Restarts the iteration over the down set of anchor().
void p_minus_sa(const subposet *other)
Difference of this and other (this minus other), self-allocated.
Definition: subposet.cc:1663
subposet * extremals(bool xmaximals)
The subposet containing the extremal members of this, auto-allocated.
Definition: subposet.cc:1766
virtual void remove_member(pod_index_type xmbr_hub_id)
Removes the member of host() with hub id xmbr_hub_id.
Definition: subposet.cc:1209
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
bool is_done() const
True if iteration finished.
void attach_id_space()
Attach the id space to the id_space_name().
Definition: subposet.cc:714
SHEAF_DLL_SPEC std::ostream & operator<<(std::ostream &os, const dof_descriptor_array &p)
Insert dof_descriptor_array& p into ostream& os.
A handle for a scattered_insertion_index_space_state.
virtual void put_anchor(const abstract_poset_member *xanchor)
Set anchor() to xanchor.
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.
An abstract client handle for a member of a poset.
virtual pod_index_type subposet_id(const std::string &xname) const
The hub id of the subposet with name xname.
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 ...
void minimals_pa(subposet *result)
The subposet containing the minimal members of this, pre-allocated.
Definition: subposet.cc:1939
void p_union_sa(const subposet *other)
Union of this with other, self-allocated.
Definition: subposet.cc:1505
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
Computes the join of given poset members.
Definition: poset_joiner.h:43
virtual void new_state(bool xinitialize=true, bool xauto_access=true)
Creates a new subposet state in host() and attaches this object to it. If xinitialize, initialize the membership to xmembers, If !xinitialize, leave the membership uninitialized.
Definition: subposet.cc:295
virtual void delete_state(bool xauto_access=false)
Detach this from its state and delete the state.
Definition: subposet.cc:2876
Traverser to compute intersection of the down set (up set) of the anchor with a given subposet...
Definition: poset_slicer.h:45
void put_strict(bool xstrict)
Set strict() to xstrict.
poset_member * l_join(bool xnew_jem=true)
Lattice join of the members of this, auto-allocated The lattice join is the least upper bound in th...
Definition: subposet.cc:2323
virtual void delete_all_names(bool xauto_access=false)
Delete all the names for this.
Definition: subposet.cc:2844
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 ...
Definition: subposet.cc:2532
void p_not_pa(subposet *result)
Poset complement of this, pre-allocated.
Definition: subposet.cc:1712
virtual index_iterator indexed_member_iterator() const
An iterator for members of this poset; index version.
Definition: subposet.cc:934
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
Definition: scoped_index.h:710
const scoped_index & index() const
The index of the current member of the iteration.