SheafSystem  0.0.0.0
schema_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/schema_poset_member.h"
22 
23 #include "SheafSystem/array_index_space_handle.h"
24 #include "SheafSystem/array_index_space_state.h"
25 #include "SheafSystem/assert_contract.h"
26 #include "SheafSystem/namespace_poset.h"
27 #include "SheafSystem/poset_bounds.h"
28 #include "SheafSystem/poset_dof_iterator.h"
29 #include "SheafSystem/postorder_iterator.h"
30 #include "SheafSystem/schema_descriptor.h"
31 #include "SheafSystem/index_space_iterator.h"
32 #include "SheafSystem/tern.h"
33 #include "SheafSystem/wsv_block.h"
34 
35 using namespace std;
36 
37 //#define DIAGNOSTIC_OUTPUT
38 
39 // ===========================================================
40 // SCHEMA_POSET_MEMBER FACET
41 // ===========================================================
42 
43 // PUBLIC MEMBER FUNCTIONS
44 
45 const sheaf::poset_path&
48 {
49  // Preconditions:
50 
51 
52  // Body:
53 
54  static const poset_path result(namespace_poset::primitives_schema_path());
55 
56  // Postconditions:
57 
58  ensure(result.full());
59 
60  // Exit:
61 
62  return result;
63 }
64 
67 new_host(namespace_type& xns, const poset_path& xhost_path, const poset_path& xschema_path, bool xauto_access)
68 {
69  // cout << endl << "Entering schema_poset_member::new_host." << endl;
70 
71  // Preconditions:
72 
73  require(xns.state_is_auto_read_write_accessible(xauto_access));
74 
75  require(!xhost_path.empty());
76  require(!xns.contains_poset(xhost_path, xauto_access));
77 
78  require(xschema_path.full());
79  require(xns.path_is_auto_read_accessible(xschema_path, xauto_access));
80  require(schema_poset_member::conforms_to(xns, xschema_path, standard_schema_path()));
81 
82  // Body:
83 
84  host_type& result = host_type::new_table(xns, xhost_path, xschema_path, xauto_access);
85  result.get_read_write_access();
86 
87  // Create the schema subposets of the top.
88 
89  subposet ltable_dofs(&result, 0, false);
90  subposet lrow_dofs(&result, 0, false);
91 
92  // Schematize the result.
93 
94  result.schematize(&ltable_dofs, &lrow_dofs, true);
95 
96  // Clean up.
97 
98  ltable_dofs.detach_from_state();
99  lrow_dofs.detach_from_state();
100 
101  result.release_access();
102 
103  // Postconditions:
104 
105  ensure(xns.owns(result, xauto_access));
106  ensure(result.path(true).poset_name() == xhost_path.poset_name());
107  ensure(result.state_is_not_read_accessible());
108  ensure(result.schema(true).path(xauto_access) == xschema_path);
109 
110  ensure(result.is_schematized(true));
111 
112  // Exit:
113 
114  // cout << "Leaving schema_poset_member::new_host." << endl;
115  return result;
116 }
117 
120 standard_host(namespace_type& xns, const poset_path& xhost_path, bool xauto_access)
121 {
122  // cout << endl << "Entering schema_poset_member::new_host." << endl;
123 
124  // Preconditions:
125 
126  require(xns.state_is_auto_read_write_accessible(xauto_access));
127 
128  require(!xhost_path.empty());
129  require(xns.path_is_available<host_type>(xhost_path, xauto_access));
130 
131  require(xns.path_is_auto_read_accessible(standard_schema_path(), xauto_access));
132 
133  // Body:
134 
135  host_type* result_ptr;
136  if(xns.contains_path(xhost_path, xauto_access))
137  {
138  result_ptr = &xns.member_poset<host_type>(xhost_path, xauto_access);
139  }
140  else
141  {
142  result_ptr = &new_host(xns, xhost_path, standard_schema_path(), xauto_access);
143  }
144 
145  host_type& result = *result_ptr;
146 
147  // Postconditions:
148 
149  ensure(xns.owns(result, xauto_access));
150  ensure(result.path(true).poset_name() == xhost_path.poset_name());
151  ensure(result.state_is_not_read_accessible());
152  ensure(result.schema(true).path(xauto_access) == standard_schema_path());
153 
154  ensure(result.is_schematized(true));
155 
156  // Exit:
157 
158  // cout << "Leaving schema_poset_member::new_host." << endl;
159  return result;
160 }
161 
162 // PROTECTED MEMBER FUNCTIONS
163 
164 // PRIVATE MEMBER FUNCTIONS
165 
166 
167 // ===========================================================
168 // ABSTRACT_POSET_MEMBER FACET
169 // ===========================================================
170 
171 // PUBLIC MEMBER FUNCTIONS
172 
175  : _table_dof_descriptors(0),
176  _row_dof_descriptors(0),
177  _table_cache_version(NOT_A_STANDARD_VERSION_INDEX),
178  _row_cache_version(NOT_A_STANDARD_VERSION_INDEX),
179  _table_dof_id_space(0),
180  _row_dof_id_space(0)
181 {
182  // Preconditions:
183 
184  // Body:
185 
186  // Postconditions:
187 
188  ensure(invariant());
189  ensure(!is_attached());
190 }
191 
194  bool xnew_jem,
195  bool xauto_access)
198  _table_cache_version(NOT_A_STANDARD_VERSION_INDEX),
199  _row_cache_version(NOT_A_STANDARD_VERSION_INDEX),
202 {
203 
204  // Preconditions:
205 
206  require(xnew_jem ? xother.state_is_auto_read_write_accessible(xauto_access) : true);
207 
208  // new_Jem auto_Access requires
209  // f f read access
210  // f t
211  // t f read_write_access
212  // t t is_attached()
213 
214  // Body:
215 
216  if(xnew_jem)
217  {
218  new_jem_state(const_cast<abstract_poset_member*>(&xother), true, xauto_access);
219  }
220  else
221  {
222  attach_to_state(&xother);
223  }
224 
225  // Postconditions:
226 
227  ensure(invariant());
228  ensure(is_attached() == xother.is_attached() );
229 }
230 
234 {
235  // Preconditions:
236 
237  // Body:
238 
239  attach_to_state(&xother);
240 
241  // Postconditions:
242 
243  ensure(is_same_state(&xother));
244 
245  // Exit
246 
247  return *this;
248 }
249 
253 {
254 
255  // Preconditions:
256 
257  require(is_ancestor_of(&xother));
258 
259  //Body:
260 
261  not_implemented();
262 
263  //Postconditions:
264 
265  ensure(invariant());
266 
267  // Exit:
268 
269  return *this;
270 }
271 
274 {
275  // Preconditions:
276 
277  // Body:
278 
279  if(_table_dof_descriptors != 0)
280  {
282  }
283 
284  if(_row_dof_descriptors != 0)
285  {
287  }
288 
289  // Postconditions:
290 
291  // Exit
292 
293  return;
294 }
295 
296 // NEW HANDLE, NEW STATE CONSTRUCTORS
297 
300  primitive_type xprimitive_type,
301  bool xauto_access)
304  _table_cache_version(NOT_A_STANDARD_VERSION_INDEX),
305  _row_cache_version(NOT_A_STANDARD_VERSION_INDEX),
308 {
309 
310  // Preconditions:
311 
312  require(precondition_of(schema_poset_member::new_jim_state(same args)));
313 
314  // Body:
315 
316  new_jim_state(xhost, xprimitive_type, xauto_access);
317 
318  // Postconditions:
319 
320  ensure(invariant());
321  ensure(postcondition_of(schema_poset_member::new_jim_state(same args)));
322 
323  // Exit
324 
325  return;
326 }
327 
330  primitives_poset_dof_map* xdof_map,
331  bool xcopy_dof_map,
332  bool xauto_access)
335  _table_cache_version(NOT_A_STANDARD_VERSION_INDEX),
336  _row_cache_version(NOT_A_STANDARD_VERSION_INDEX),
339 {
340 
341  // Preconditions:
342 
343  require(precondition_of(schema_poset_member::new_jim_state(same args)));
344 
345  // Body:
346 
347  new_jim_state(xhost, xdof_map, xcopy_dof_map, xauto_access);
348 
349  // Postconditions:
350 
351  ensure(postcondition_of(schema_poset_member::new_jim_state(same args)));
352 }
353 
356  const scoped_index* xexpansion,
357  int xexpansion_ct,
358  const tern& xnew_jem,
359  bool xauto_access)
362  _table_cache_version(NOT_A_STANDARD_VERSION_INDEX),
363  _row_cache_version(NOT_A_STANDARD_VERSION_INDEX),
366 {
367 
368  // Preconditions:
369 
370  require(precondition_of(schema_poset_member::new_jrm_state(same args)));
371 
372  // Body:
373 
374  new_jrm_state(xhost, xexpansion, xexpansion_ct, xnew_jem, xauto_access);
375 
376  // Postconditions:
377 
378  ensure(invariant());
379  ensure(postcondition_of(schema_poset_member::new_jrm_state(same args)));
380 }
381 
384  const std::string& xname,
385  const poset_path& xparent_path,
386  const wsv_block<schema_descriptor>& xdof_specs,
387  bool xauto_access)
390  _table_cache_version(NOT_A_STANDARD_VERSION_INDEX),
391  _row_cache_version(NOT_A_STANDARD_VERSION_INDEX),
394 {
395 
396  // Preconditions:
397 
398  require(precondition_of(new_jrm_state(same args)));
399 
400  // Body:
401 
402  new_jim_state(xns, xname, xparent_path, xdof_specs, xauto_access);
403 
404  // Postconditions:
405 
406  ensure(postcondition_of(new_jrm_state(same args)));
407 
408 }
409 
410 // NEW HANDLE, EXISTING STATE CONSTRUCTORS
411 
416  _table_cache_version(NOT_A_STANDARD_VERSION_INDEX),
417  _row_cache_version(NOT_A_STANDARD_VERSION_INDEX),
420 {
421 
422  // Preconditions:
423 
424  require(xhost->state_is_read_accessible());
425  require(xhost->contains_member(xhub_id));
426 
427  // Body:
428 
429  attach_to_state(xhost, xhub_id);
430 
431  // Postconditions:
432 
433  ensure(invariant());
434  ensure(host() == xhost);
435  ensure(index() == xhub_id);
436  ensure(is_attached());
437 }
438 
443  _table_cache_version(NOT_A_STANDARD_VERSION_INDEX),
444  _row_cache_version(NOT_A_STANDARD_VERSION_INDEX),
447 {
448 
449  // Preconditions:
450 
451  require(xhost->state_is_read_accessible());
452  require(xhost->contains_member(xid));
453 
454  // Body:
455 
456  attach_to_state(xhost, xid.hub_pod());
457 
458  // Postconditions:
459 
460  ensure(invariant());
461  ensure(host() == xhost);
462  ensure(index() ==~ xid);
463  ensure(is_attached());
464 }
465 
467 schema_poset_member(const poset_state_handle* xhost, const std::string& xname)
470  _table_cache_version(NOT_A_STANDARD_VERSION_INDEX),
471  _row_cache_version(NOT_A_STANDARD_VERSION_INDEX),
474 {
475 
476  // Preconditions:
477 
478  require(xhost != 0);
479  require(xhost->state_is_read_accessible());
480  require(!xname.empty());
481  require(xhost->contains_member(xname));
482 
483  // Body:
484 
485  attach_to_state(xhost, xname);
486 
487  // Postconditions:
488 
489  ensure(invariant());
490  ensure(host() == xhost);
491  ensure(name() == xname);
492  ensure(is_attached());
493 }
494 
497  const poset_path& xpath,
498  bool xauto_access)
501  _table_cache_version(NOT_A_STANDARD_VERSION_INDEX),
502  _row_cache_version(NOT_A_STANDARD_VERSION_INDEX),
505 {
506 
507  // Preconditions:
508 
509  require(precondition_of(attach_to_state(same args)));
510 
511  // Body:
512 
513  attach_to_state(xnamespace, xpath, xauto_access);
514 
515  // Postconditions:
516 
517  ensure(postcondition_of(attach_to_state(same args)));
518 
519  // Exit:
520 
521  return;
522 }
523 
524 // EXISTING HANDLE, NEW STATE "CONSTRUCTORS"
525 
526 void
528 new_jim_state(primitive_type xprimitive_type, bool xauto_access)
529 {
530  // Preconditions:
531 
532  require(!xauto_access ? host()->in_jim_edit_mode() : true);
533 
534  // If xauto_access == true we must get read access to the schema before
535  // testing to the host's schema.
536 
537  if(xauto_access)
539 
540  require(host()->schema().conforms_to("primitives_schema/top"));
541 
542  // Body:
543 
544  // Create new jim with a primitive dof map of the proper type.
545 
546  poset_dof_map* ldof_map = new primitives_poset_dof_map(_host, xprimitive_type);
547 
548  pod_index_type lindex = _host->new_member(true, ldof_map, false);
549 
550  // Attach_to_state(xindex) attaches but does not reinitialize handle data members.
551 
552  attach_to_state(lindex);
553 
554  // Postconditions:
555 
556  ensure(invariant());
557  ensure(is_attached());
558  ensure(!is_restricted());
559  ensure(type() == xprimitive_type);
560 
561  // Clean-up auto access.
562 
563  if(xauto_access)
564  host()->end_jim_edit_mode();
565 
566  // Exit:
567 
568  return;
569 }
570 
571 void
574  primitive_type xprimitive_type,
575  bool xauto_access)
576 {
577  // Preconditions:
578 
579  require(xhost != 0);
580  require(!xauto_access ? xhost->in_jim_edit_mode() : true);
581 
582  // If xauto_access == true we must get read access to the schema before
583  // testing to the host and dof_map.
584 
585  if(xauto_access)
586  xhost->begin_jim_edit_mode();
587 
588  require(xhost->schema().conforms_to("primitives_schema/top"));
589 
590  // Body:
591 
592  // Create new jim with a primitive dof map of the proper type.
593 
594  poset_dof_map* ldof_map = new primitives_poset_dof_map(xhost, xprimitive_type);
595 
596  pod_index_type lindex = xhost->new_member(true, ldof_map, false);
597 
598  // Attach_to_state(xindex) attaches but does not reinitialize handle data members.
599 
600  attach_to_state(xhost, lindex);
601 
602  // Postconditions:
603 
604  ensure(invariant());
605  ensure(is_attached());
606  ensure(!is_restricted());
607  ensure(type() == xprimitive_type);
608 
609  // Clean-up auto access.
610 
611  if(xauto_access)
612  xhost->end_jim_edit_mode();
613 
614  // Exit:
615 
616  return;
617 }
618 
619 void
622  const std::string& xname,
623  const poset_path& xparent_path,
624  const wsv_block<schema_descriptor>& xdof_specs,
625  bool xauto_access)
626 {
627  // Preconditions:
628 
629  require(xauto_access || xns.state_is_read_accessible());
630 
631  if(xauto_access)
632  {
633  xns.get_read_access();
634  }
635 
636  require(!xname.empty());
637  require(!xparent_path.poset_name().empty());
638  require(!xns.contains_poset_member(xparent_path.poset_name()+"/"+xname));
639 
640  require(xns.contains_poset(xparent_path));
641  require(xauto_access ||
642  xns.member_poset(xparent_path).state_is_read_write_accessible());
643 
644  if(xauto_access)
645  {
646  xns.member_poset(xparent_path).get_read_write_access();
647  }
648 
649  require(xns.member_poset(xparent_path).is_schematized(false));
650  require(xns.contains_poset_member(xparent_path));
651  require_for_all(i, 0, xdof_specs.ct(), !xdof_specs[i].name.empty());
652 
653  // Body:
654 
655  // Get handles for the schema poset and the dof subposets.
656 
657  poset_state_handle& lschema_poset = xns.member_poset(xparent_path);
658  subposet ltable_dof_sp(&lschema_poset, table_dof_subposet_name("top"));
659  subposet lrow_dof_sp(&lschema_poset, row_dof_subposet_name("top"));
660 
661  // Make sure the dof subposets have an id space that is opened for editing.
662 
663  if(!ltable_dof_sp.has_id_space())
664  {
665  ltable_dof_sp.new_id_space("array_index_space_state");
666  }
667 
668  if(!lrow_dof_sp.has_id_space())
669  {
670  lrow_dof_sp.new_id_space("array_index_space_state");
671  }
672 
673  // Create the result.
674 
675  lschema_poset.begin_jim_edit_mode();
676 
679 
680  poset_dof_map* ldof_map =
681  new primitives_poset_dof_map(&lschema_poset, SIZE_TYPE);
682  new_jim_state(&lschema_poset, ldof_map, false, false);
683  size_t lsize = 0;
684  int ldof_ct = xdof_specs.ct();
685 
686  // Cover the the parent.
687 
688  schema_poset_member lschema_mbr;
689  lschema_mbr.attach_to_state(&lschema_poset, xparent_path.member_name());
690 
691  if(lschema_poset.top().covers(&lschema_mbr))
692  {
693  // The parent is already covered by top; delete the link.
694 
695  lschema_poset.top().delete_cover_link(&lschema_mbr);
696  }
697 
698  // Cover the parent if it is not the bottom or if
699  // it is the bottom and there's nothing else to cover.
700 
701  if((lschema_mbr.index() != BOTTOM_INDEX) || (ldof_ct == 0))
702  {
703  create_cover_link(&lschema_mbr);
704  }
705 
706  // Cover each dof.
707 
708  for(int i=0; i<ldof_ct; ++i)
709  {
710  const string& ldof_name = xdof_specs[i].name;
711  if(lschema_poset.contains_member(ldof_name))
712  {
713  // The dof already exists, just attach to it.
714 
715  lschema_mbr.attach_to_state(ldof_name);
716  }
717  else
718  {
719  // Create the dof.
720 
721  lschema_mbr.new_jim_state(xdof_specs[i].type, false);
722  lschema_mbr.put_name(ldof_name, true, false);
723 
724  // Insert it in the appropriate dof subposet and give
725  // it a creation-order sequence id.
726 
727  subposet& ldof_sp = xdof_specs[i].is_table_dof ? ltable_dof_sp : lrow_dof_sp;
728  ldof_sp.insert_member(lschema_mbr.index());
729  ldof_sp.id_space().push_back(lschema_mbr.index());
730  }
731 
732  // Cover it.
733 
734  create_cover_link(&lschema_mbr);
735  }
736 
737  lschema_poset.end_jim_edit_mode();
738 
739  put_name(xname, true, false);
740 
741  // This member is a jim, but it is not a primitive type.
742  // Size and alignment will be set in update_cache().
743 
744  dof_map(true).put_type(NOT_A_PRIMITIVE_TYPE);
745 
746  // Clean up.
747 
748  lschema_mbr.detach_from_state();
749  lrow_dof_sp.detach_from_state();
750  ltable_dof_sp.detach_from_state();
751 
752  // Postconditions:
753 
754  ensure(name() == xname);
755  ensure(host()->name() == (xparent_path.poset_name()));
756 
757  if(xauto_access)
758  {
759  lschema_poset.release_access();
760  xns.release_access();
761  }
762 
763  // Exit:
764 
765  return;
766 }
767 
768 int
771  const poset_path& xpath,
772  bool xis_table_dof,
773  bool xauto_access)
774 {
775  int result;
776 
777  // Preconditions:
778 
779  require(!xauto_access ? xns.state_is_read_accessible() : true);
780 
781  if(xauto_access)
782  {
783  xns.get_read_access();
784  }
785 
786  require(xpath.full());
787  require(!xauto_access ?
789  true);
790 
791  // Body:
792 
793  poset_state_handle& lschema_poset = xns.member_poset(xpath);
794 
795  if(xauto_access)
796  {
797  lschema_poset.get_read_access();
798  }
799 
800  schema_poset_member lschema_mbr(&lschema_poset, xpath.member_name());
801 
802  result = lschema_mbr.dof_ct(xis_table_dof);
803 
804  lschema_mbr.detach_from_state();
805 
806  if(xauto_access)
807  {
808  lschema_poset.release_access();
809  xns.release_access();
810  }
811 
812  // Postconditions:
813 
814  ensure(result >= 0);
815 
816  // Exit
817 
818  return result;
819 }
820 
821 
822 int
825  const poset_path& xpath,
826  bool xauto_access)
827 {
828  int result;
829 
830  // Preconditions:
831 
832  require(precondition_of(dof_ct(xns, xpath, true, xauto_access)));
833 
834  // Body:
835 
836  result = dof_ct(xns, xpath, true, xauto_access);
837 
838 
839  // Postconditions:
840 
841  ensure(postcondition_of(dof_ct(xns, xpath, true, xauto_access)));
842 
843  // Exit
844 
845  return result;
846 }
847 
848 int
851  const poset_path& xpath,
852  bool xauto_access)
853 {
854  int result;
855 
856  // Preconditions:
857 
858  require(precondition_of(dof_ct(xns, xpath, false, xauto_access)));
859 
860  // Body:
861 
862  result = dof_ct(xns, xpath, false, xauto_access);
863 
864 
865  // Postconditions:
866 
867  ensure(postcondition_of(dof_ct(xns, xpath, false, xauto_access)));
868 
869  // Exit
870 
871  return result;
872 }
873 
874 int
876 dof_ct(bool xis_table_dof) const
877 {
878  int result;
879 
880  // Preconditions:
881 
882  require(state_is_read_accessible());
883 
884  // Body:
885 
886  result = xis_table_dof ? table_dof_ct() : row_dof_ct();
887 
888  // Postconditions:
889 
890  ensure(result >= 0);
891 
892  // Exit
893 
894  return result;
895 }
896 
897 int
900 {
901  int result;
902 
903  // Preconditions:
904 
905  require(state_is_read_accessible());
906 
907  // Body:
908 
910  {
912  }
913 
914  result = _table_dof_ct;
915 
916  // Postconditions:
917 
918  ensure(result >= 0);
919 
920  // Exit
921 
922  return result;
923 }
924 
925 int
927 row_dof_ct() const
928 {
929  int result;
930 
931  // Preconditions:
932 
933  require(state_is_read_accessible());
934 
935  // Body:
936 
937  if(!row_cache_consistent())
938  {
940  }
941 
942  result = _row_dof_ct;
943 
944  // Postconditions:
945 
946  ensure(result >= 0);
947 
948  // Exit
949 
950  return result;
951 }
952 
953 size_t
955 dof_tuple_ub(bool xis_table_dof) const
956 {
957  size_t result;
958 
959  // Preconditions:
960 
961  require(state_is_read_accessible());
962 
963  // Body:
964 
965  result = xis_table_dof ? table_dof_tuple_ub() : row_dof_tuple_ub();
966 
967  // Postconditions:
968 
969  // Exit
970 
971  return result;
972 }
973 
974 size_t
977 {
978  size_t result;
979 
980  // Preconditions:
981 
982  require(state_is_read_accessible());
983 
984  // Body:
985 
987  {
989  }
990 
991  result = _table_dof_tuple_ub;
992 
993  // Postconditions:
994 
995  // Exit
996 
997  return result;
998 }
999 
1000 size_t
1003 {
1004  size_t result;
1005 
1006  // Preconditions:
1007 
1008  require(state_is_read_accessible());
1009 
1010  // Body:
1011 
1012  if(!row_cache_consistent())
1013  {
1014  update_row_cache();
1015  }
1016 
1017  result = _row_dof_tuple_ub;
1018 
1019  // Postconditions:
1020 
1021  // Exit
1022 
1023  return result;
1024 }
1025 
1028 dof_tuple_type(bool xis_table_dof) const
1029 {
1030  primitive_type result = NOT_A_PRIMITIVE_TYPE;
1031 
1032  // Preconditions:
1033 
1034  require(state_is_read_accessible());
1035 
1036  // Body:
1037 
1038  poset_dof_iterator* itr = dof_iterator(xis_table_dof);
1039  if(!itr->is_done())
1040  {
1041  result = itr->item().type();
1042  itr->next();
1043  }
1044 
1045  while(!itr->is_done() && (result != NOT_A_PRIMITIVE_TYPE))
1046  {
1047  if(result != itr->item().type())
1048  {
1049  result = NOT_A_PRIMITIVE_TYPE;
1050  }
1051  itr->next();
1052  }
1053 
1054  itr->force_is_done();
1055  delete itr;
1056 
1057  // Postconditions:
1058 
1059  // Exit
1060 
1061  return result;
1062 }
1063 
1064 bool
1066 dof_tuple_is_homogeneous(bool xis_table_dof) const
1067 {
1068  bool result;
1069 
1070  // Preconditions:
1071 
1072  require(state_is_read_accessible());
1073 
1074  // Body:
1075 
1076  result = is_primitive_index(dof_tuple_type(xis_table_dof));
1077 
1078  // Postconditions:
1079 
1080  ensure(result == is_primitive_index(dof_tuple_type(xis_table_dof)));
1081 
1082  // Exit
1083 
1084  return result;
1085 }
1086 
1087 std::string
1089 dof_subposet_name(const std::string& xname, bool xis_table_dofs)
1090 {
1091  string result;
1092 
1093  // Preconditions:
1094 
1095  require(!xname.empty());
1096 
1097  // Body:
1098 
1099  result =
1101  xname +
1102  (xis_table_dofs ? "_table_dofs" : "_row_dofs");
1103 
1104  // Postconditions:
1105 
1106  ensure(!result.empty());
1107 
1108  // Exit
1109 
1110  return result;
1111 }
1112 
1113 std::string
1115 dof_subposet_name(bool xis_table_dofs) const
1116 {
1117  // Preconditions:
1118 
1119  require(state_is_read_accessible());
1120 
1121  // Body:
1122 
1123  string result(dof_subposet_name(name(), xis_table_dofs));
1124 
1125  // Postconditions:
1126 
1127  ensure(!result.empty());
1128 
1129  // Exit
1130 
1131  return result;
1132 }
1133 
1134 const sheaf::scoped_index&
1137 {
1138  // Preconditions:
1139 
1141 
1142  require(state_is_read_accessible());
1143 
1144  // Body:
1145 
1146  const scoped_index& result = _table_dof_subposet_index;
1147 
1148  // Postconditions:
1149 
1150  ensure(result.is_valid() == host()->includes_subposet(result));
1151 
1152  // Exit
1153 
1154  return result;
1155 }
1156 
1157 const sheaf::scoped_index&
1160 {
1161  // Preconditions:
1162 
1164 
1165  require(state_is_read_accessible());
1166 
1167  // Body:
1168 
1169  const scoped_index& result = _row_dof_subposet_index;
1170 
1171  // Postconditions:
1172 
1173  ensure(result.is_valid() == host()->includes_subposet(result));
1174 
1175  // Exit
1176 
1177  return result;
1178 }
1179 
1180 bool
1182 contains_dof(const schema_poset_member& xother, bool xin_table_dofs) const
1183 {
1184  bool result;
1185 
1186  // Preconditions:
1187 
1188  require(state_is_read_accessible());
1189  require(xother.state_is_read_accessible());
1190  require(host()->is_schematized(false));
1191 
1192 
1193  // Body:
1194 
1195  result = xother.le(this) && xother.is_dof(xin_table_dofs);
1196 
1197  // Postconditions:
1198 
1199  // Exit
1200 
1201  return result;
1202 }
1203 
1204 bool
1206 contains_dof(pod_index_type xother_id, bool xin_table_dofs) const
1207 {
1208  bool result;
1209 
1210  // Preconditions:
1211 
1212  require(state_is_read_accessible());
1213  require(host()->is_schematized(false));
1214 
1215  // Body:
1216 
1217  // A direct implemetation might be faster,
1218  // but this implementation doesn't need to be
1219  // redefined in section_space_schema_member
1220  // and descendants.
1221 
1222  schema_poset_member* lother = clone();
1223  lother->attach_to_state(host(), xother_id);
1224 
1225  result = contains_dof(*lother, xin_table_dofs);
1226 
1227  lother->detach_from_state();
1228  delete lother;
1229 
1230  // Postconditions:
1231 
1232  // Exit
1233 
1234  return result;
1235 }
1236 
1237 bool
1239 contains_dof(const scoped_index& xother_id, bool xin_table_dofs) const
1240 {
1241  bool result;
1242 
1243  // Preconditions:
1244 
1245  require(state_is_read_accessible());
1246  require(host()->is_schematized(false));
1247 
1248 
1249  // Body:
1250 
1251  return contains_dof(xother_id.hub_pod(), xin_table_dofs);
1252 }
1253 
1254 bool
1256 contains_dof(const std::string& xname, bool xin_table_dofs) const
1257 {
1258  bool result;
1259 
1260  // Preconditions:
1261 
1262  require(state_is_read_accessible());
1263  require(host()->is_schematized(false));
1264  require(!xname.empty());
1265 
1266 
1267  // Body:
1268 
1269  pod_index_type lhub_pod = host()->member_id(xname, false);
1270 
1271 
1272  return is_valid(lhub_pod) && contains_dof(lhub_pod, xin_table_dofs);
1273 }
1274 
1275 bool
1277 is_dof(bool xin_table_dofs) const
1278 {
1279  bool result;
1280 
1281  // Preconditions:
1282 
1283  require(state_is_read_accessible());
1284  require(host()->is_schematized(false));
1285 
1286 
1287  // Body:
1288 
1289  // Category is defined by membership in table or row dof subposets of top,
1290  // which include dof subposets of all other members.
1291 
1292  subposet ltop_dofs(host(), schema_poset_member::dof_subposet_name("top", xin_table_dofs));
1293  result = ltop_dofs.contains_member(index());
1294  ltop_dofs.detach_from_state();
1295 
1296  // Postconditions:
1297 
1298  // Exit
1299 
1300  return result;
1301 }
1302 
1303 bool
1306 {
1307  bool result;
1308 
1309  // Preconditions:
1310 
1311  require(state_is_read_accessible());
1312  require(host()->is_schematized(false));
1313 
1314  // Body:
1315 
1316  // A component of a schema is a row dof which is atomic.
1317 
1318  result = is_row_dof() && is_atom();
1319 
1320  // Postconditions:
1321 
1322  // Exit
1323 
1324  return result;
1325 }
1326 
1327 bool
1330 {
1331  bool result;
1332 
1333  // Preconditions:
1334 
1335  require(state_is_read_accessible());
1336  require(host()->is_schematized(false));
1337  require(is_ancestor_of(&xother));
1338  require(xother.state_is_read_accessible());
1339  require(xother.host()->is_schematized(false));
1340 
1341  // Body:
1342 
1343  // This is a component of xother if it is a component
1344  // and it is inferior to xother.
1345 
1346  result = is_component() && le(&xother);
1347 
1348  // Postconditions:
1349 
1350  // Exit
1351 
1352  return result;
1353 }
1354 
1355 bool
1357 is_factor() const
1358 {
1359  bool result;
1360 
1361  // Preconditions:
1362 
1363  require(state_is_read_accessible());
1364  require(host()->is_schematized(false));
1365 
1366  // Body:
1367 
1368  // Every schema member except the top and bottom are
1369  // factors in some other schema.
1370 
1371  result = (index() != TOP_INDEX) && (index() != BOTTOM_INDEX);
1372 
1373  // Postconditions:
1374 
1375  // Exit
1376 
1377  return result;
1378 }
1379 
1380 bool
1382 is_factor_of(const schema_poset_member& xother) const
1383 {
1384  bool result;
1385 
1386  // Preconditions:
1387 
1388  require(state_is_read_accessible());
1389  require(host()->is_schematized(false));
1390  require(is_ancestor_of(&xother));
1391  require(xother.state_is_read_accessible());
1392  require(xother.host()->is_schematized(false));
1393 
1394  // Body:
1395 
1396  result = (!is_table_dof()) && xother.covers(this);
1397 
1398  // Postconditions:
1399 
1400  // Exit
1401 
1402  return result;
1403 }
1404 
1405 size_t
1407 size() const
1408 {
1409  size_t result;
1410 
1411  // Preconditions:
1412 
1413  require(state_is_read_accessible());
1414  require(is_jim()); // size is a dof of this
1415 
1416  // Body:
1417 
1418  result = dof_map().size();
1419 
1420  // Postconditions:
1421 
1422  // Exit
1423 
1424  return result;
1425 }
1426 
1427 size_t
1429 alignment() const
1430 {
1431  size_t result;
1432 
1433  // Preconditions:
1434 
1435  require(state_is_read_accessible());
1436  require(is_jim());
1437 
1438  // Body:
1439 
1440  result = dof_map().alignment();
1441 
1442  // Postconditions:
1443 
1444  // Exit
1445 
1446  return result;
1447 }
1448 
1451 type() const
1452 {
1453  // Preconditions:
1454 
1455  require(state_is_read_accessible());
1456  require(is_jim());
1457 
1458  // Body:
1459 
1460  primitive_type result = dof_map().type();
1461 
1462  // Postconditions:
1463 
1464  // Exit
1465 
1466  return result;
1467 }
1468 
1471 dof_iterator(bool xis_table_dofs, int xversion) const
1472 {
1473  poset_dof_iterator* result;
1474 
1475  // Preconditions:
1476 
1477  require(state_is_read_accessible());
1478  require(host()->is_schematized(false));
1479  require(has_version(xversion));
1480 
1481 
1482  // Body:
1483 
1484  result = new poset_dof_iterator(*this, xis_table_dofs, xversion);
1485 
1486  // Postconditions:
1487 
1488  ensure(result != 0);
1489 
1490  // Exit
1491 
1492  return result;
1493 }
1494 
1495 bool
1497 conforms_to(const schema_poset_member& xother) const
1498 {
1499  bool result;
1500 
1501  // Preconditions:
1502 
1503  require(state_is_read_accessible());
1504 
1505  // Body:
1506 
1507  // If we are comparing both table and row dofs, the dofs are guaranteed
1508  // to match in type and in order if this is greater than or equal to
1509  // xother.
1510 
1511  result = ge(&xother);
1512 
1513  // Postconditions:
1514 
1515  // Exit
1516 
1517  return result;
1518 }
1519 
1520 bool
1522 conforms_to(const schema_poset_member& xother, bool xis_table_dofs) const
1523 {
1524  bool result;
1525 
1526  // Preconditions:
1527 
1528  require(state_is_read_accessible());
1529  require(is_ancestor_of(&xother));
1530 
1531  // Body:
1532 
1533  // Schema in different hosts don't conform.
1534 
1535  result = has_same_host(&xother);
1536  if(result)
1537  {
1538  // The dofs defined by this must agree in type and in order
1539  // with those defined by xother. So traverse xother, comparing
1540  // dof types. If this runs out of dofs, or if there is a type
1541  // mismatch, result is false.
1542 
1543  poset_dof_iterator* lthis_itr = dof_iterator(xis_table_dofs);
1544  poset_dof_iterator* lother_itr = dof_iterator(xis_table_dofs);
1545  while(result && !lother_itr->is_done())
1546  {
1547  result = !lthis_itr->is_done() &&
1548  (lthis_itr->item().type() == lother_itr->item().type());
1549  lthis_itr->next();
1550  lother_itr->next();
1551  }
1552 
1553  // Clean up.
1554 
1555  lthis_itr->force_is_done();
1556  delete lthis_itr;
1557 
1558  lother_itr->force_is_done();
1559  delete lother_itr;
1560  }
1561 
1568 
1569  // Postconditions:
1570 
1571  // Exit
1572 
1573  return result;
1574 }
1575 
1576 bool
1578 conforms_to(const poset_path& xpath) const
1579 {
1580  bool result;
1581 
1582  // Preconditions:
1583 
1584  require(xpath.full());
1585  require(state_is_read_accessible());
1586 
1587  // Body:
1588 
1589  if(name_space()->contains_poset_member(xpath))
1590  {
1591  // Path is valid, check for conformance.
1592  // lother must conform to this to satisfy precondition
1593  // of conforms_to(schema_poset_member&).
1594 
1595  schema_poset_member* lother = clone();
1596  lother->attach_to_state(name_space(), xpath);
1597  result = conforms_to(*lother);
1598  lother->detach_from_state();
1599  delete lother;
1600  }
1601  else
1602  {
1603  // Path is invalid; can't conform.
1604 
1605  result = false;
1606  }
1607 
1608  // Postconditions:
1609 
1610  // Exit
1611 
1612  return result;
1613 }
1614 
1615 bool
1617 conforms_to(const poset_path& xpath, bool xis_table_dofs) const
1618 {
1619  bool result;
1620 
1621  // Preconditions:
1622 
1623  require(xpath.full());
1624  require(state_is_read_accessible());
1625 
1626  // Body:
1627 
1628  if(name_space()->contains_poset_member(xpath))
1629  {
1630  // Path is valid, check for conformance.
1631  // lother must conform to this to satisfy precondition
1632  // of conforms_to(schema_poset_member&, bool).
1633 
1634  schema_poset_member* lother = clone();
1635  lother->attach_to_state(name_space(), xpath);
1636  result = conforms_to(*lother, xis_table_dofs);
1637  lother->detach_from_state();
1638  delete lother;
1639  }
1640  else
1641  {
1642  // Path is invalid; can't conform.
1643 
1644  result = false;
1645  }
1646 
1647  // Postconditions:
1648 
1649  // Exit
1650 
1651  return result;
1652 }
1653 
1654 bool
1657 {
1658  bool result;
1659 
1660  // Preconditions:
1661 
1662  require(state_is_read_accessible());
1663 
1664  // Body:
1665 
1666  result = conforms_to(xother, true);
1667 
1668  // Postconditions:
1669 
1670  // Exit
1671 
1672  return result;
1673 }
1674 
1675 bool
1677 table_conforms_to(const poset_path& xpath) const
1678 {
1679  bool result;
1680 
1681  // Preconditions:
1682 
1683  require(xpath.full());
1684  require(state_is_read_accessible());
1685 
1686  // Body:
1687 
1688  result = conforms_to(xpath, true);
1689 
1690  // Postconditions:
1691 
1692  // Exit
1693 
1694  return result;
1695 }
1696 
1697 bool
1700 {
1701  bool result;
1702 
1703  // Preconditions:
1704 
1705  require(state_is_read_accessible());
1706 
1707  // Body:
1708 
1709  result = conforms_to(xother, false);
1710 
1711  // Postconditions:
1712 
1713  // Exit
1714 
1715  return result;
1716 }
1717 
1718 bool
1720 row_conforms_to(const poset_path& xpath) const
1721 {
1722  bool result;
1723 
1724  // Preconditions:
1725 
1726  require(xpath.full());
1727  require(state_is_read_accessible());
1728 
1729  // Body:
1730 
1731  result = conforms_to(xpath, false);
1732 
1733  // Postconditions:
1734 
1735  // Exit
1736 
1737  return result;
1738 }
1739 
1740 
1741 bool
1744  const poset_path& xchild_path,
1745  const poset_path& xparent_path,
1746  bool xauto_access)
1747 {
1748  bool result;
1749 
1750  // Preconditions:
1751 
1752  require(xauto_access || xns.state_is_read_accessible());
1753 
1754  if(xauto_access)
1755  {
1756  xns.get_read_access();
1757  }
1758 
1759  require(xchild_path.full());
1760  require(xauto_access ||
1761  xns.member_poset(xchild_path).state_is_read_accessible());
1762 
1763  require(xparent_path.full());
1764  require(xauto_access ||
1765  xns.member_poset(xparent_path).state_is_read_accessible());
1766 
1767  // Body:
1768 
1769  // Can't conform if not in same poset.
1770 
1771  result = (xparent_path.poset_name() == xchild_path.poset_name());
1772 
1773  if(result)
1774  {
1775  // Parent and child are in same poset.
1776  // Get handles and test conformance.
1777 
1778  poset_state_handle& lschema_poset = xns.member_poset(xparent_path);
1779  if(xauto_access)
1780  {
1781  lschema_poset.get_read_access();
1782  }
1783 
1784  schema_poset_member lparent(&lschema_poset, xparent_path.member_name());
1785  schema_poset_member lchild(&lschema_poset, xchild_path.member_name());
1786 
1787  result = lchild.conforms_to(lparent);
1788 
1789  lparent.detach_from_state();
1790  lchild.detach_from_state();
1791 
1792  if(xauto_access)
1793  {
1794  lschema_poset.release_access();
1795  }
1796  }
1797 
1798  if(xauto_access)
1799  {
1800  xns.release_access();
1801  }
1802 
1803  // Postconditions:
1804 
1805  // Exit
1806 
1807  return result;
1808 }
1809 
1810 bool
1813  const poset_path& xchild_path,
1814  const poset_path& xparent_path,
1815  bool xis_table_dofs,
1816  bool xauto_access)
1817 {
1818  bool result;
1819 
1820  // Preconditions:
1821 
1822  require(!xauto_access ? xns.state_is_read_accessible() : true);
1823 
1824  if(xauto_access)
1825  {
1826  xns.get_read_access();
1827  }
1828 
1829  require(xchild_path.full());
1830  require(!xauto_access ?
1831  xns.member_poset(xchild_path).state_is_read_accessible() :
1832  true);
1833 
1834  require(xparent_path.full());
1835  require(!xauto_access ?
1836  xns.member_poset(xparent_path).state_is_read_accessible() :
1837  true);
1838 
1839  // Body:
1840 
1841  // Can't conform if not in same poset.
1842 
1843  result = (xparent_path.poset_name() == xchild_path.poset_name());
1844 
1845  if(result)
1846  {
1847  // Parent and child are in same poset.
1848  // Get handles and test conformance.
1849 
1850  poset_state_handle& lschema_poset = xns.member_poset(xparent_path);
1851  if(xauto_access)
1852  {
1853  lschema_poset.get_read_access();
1854  }
1855 
1856  schema_poset_member lparent(&lschema_poset, xparent_path.member_name());
1857  schema_poset_member lchild(&lschema_poset, xchild_path.member_name());
1858 
1859  result = lchild.conforms_to(lparent, xis_table_dofs);
1860 
1861  lparent.detach_from_state();
1862  lchild.detach_from_state();
1863 
1864  if(xauto_access)
1865  {
1866  lschema_poset.release_access();
1867  }
1868  }
1869 
1870  if(xauto_access)
1871  {
1872  xns.release_access();
1873  }
1874 
1875  // Postconditions:
1876 
1877  // Exit
1878 
1879  return result;
1880 }
1881 
1882 bool
1885  const poset_path& xchild_path,
1886  const poset_path& xparent_path,
1887  bool xauto_access)
1888 {
1889  bool result;
1890 
1891  // Preconditions:
1892 
1893  require(precondition_of(conforms_to(xns, xchild_path, xparent_path, true, xauto_access)));
1894 
1895 
1896  // Body:
1897 
1898  result = conforms_to(xns, xchild_path, xparent_path, true, xauto_access);
1899 
1900  // Postconditions:
1901 
1902  ensure(postcondition_of(conforms_to(xns, xchild_path, xparent_path, true, xauto_access)));
1903 
1904  // Exit
1905 
1906  return result;
1907 }
1908 
1909 bool
1912  const poset_path& xchild_path,
1913  const poset_path& xparent_path,
1914  bool xauto_access)
1915 {
1916  bool result;
1917 
1918  // Preconditions:
1919 
1920  require(precondition_of(conforms_to(xns, xchild_path, xparent_path, false, xauto_access)));
1921 
1922 
1923  // Body:
1924 
1925  result = conforms_to(xns, xchild_path, xparent_path, false, xauto_access);
1926 
1927  // Postconditions:
1928 
1929  ensure(postcondition_of(conforms_to(xns, xchild_path, xparent_path, false, xauto_access)));
1930 
1931  // Exit
1932 
1933  return result;
1934 }
1935 
1939  const poset_path& xparent_path,
1940  const std::string& xname)
1941 {
1942  // Preconditions:
1943 
1944  require(!xname.empty());
1945  require(xns.state_is_read_accessible());
1946  require(xparent_path.full());
1947  require(xns.contains_poset(xparent_path));
1948  require(xns.member_poset(xparent_path).state_is_read_write_accessible());
1949  require(xns.member_poset(xparent_path).is_schematized(false));
1950  require(xns.contains_poset_member(xparent_path));
1951  require(!xns.contains_poset_member(xparent_path.poset_name()+"/"+xname));
1952 
1954 
1955  // Body:
1956 
1957  // Get a handle to the parent.
1958 
1959  schema_poset_member lparent(&xns, xparent_path, false);
1960 
1961  // Create the new schema as a jem of the parent.
1962 
1963  schema_poset_member lmember(lparent, true);
1964  lmember.put_name(xname, true, true);
1965 
1966  poset_path result(lmember.path());
1967 
1968  // Clean up.
1969 
1970  lmember.detach_from_state();
1971  lparent.detach_from_state();
1972 
1973  // Postconditions:
1974 
1975  ensure(xns.contains_poset_member(result));
1976  ensure(result.poset_name() == xparent_path.poset_name());
1977  ensure(result.member_name() == xname);
1978  ensure(unexecutable(new member is join equivalent to parent member));
1979 
1980  // Exit:
1981 
1982  return result;
1983 }
1984 
1985 void
1988  const std::string& xposet_name,
1989  const std::string& xmember_name,
1990  const std::string& xparent_name)
1991 {
1992  // Preconditions:
1993 
1994  // Body:
1995 
1996  poset_path lparent_path(xposet_name, xparent_name);
1997 
1998  make_schema(*xns, lparent_path, xmember_name);
1999 
2000  // Postconditions:
2001 
2002  // Exit:
2003 
2004  return;
2005 }
2006 
2010  const poset_path& xparent_path,
2011  const std::string& xname,
2012  const std::string xdof_names[],
2013  const primitive_type xdof_types[],
2014  const bool xis_table_dof[],
2015  const size_type xdof_ct,
2016  bool xauto_access)
2017 {
2018  // Preconditions:
2019 
2020  require(!xauto_access ? xns.state_is_read_accessible() : true);
2021 
2022  if(xauto_access)
2023  {
2024  xns.get_read_access();
2025  }
2026 
2027  require(xparent_path.full());
2028  require(xns.contains_poset(xparent_path));
2029  require(!xauto_access ?
2030  xns.member_poset(xparent_path).state_is_read_write_accessible() :
2031  true);
2032 
2033  if(xauto_access)
2034  {
2035  xns.member_poset(xparent_path).get_read_write_access();
2036  }
2037 
2038  require(xns.member_poset(xparent_path).is_schematized(false));
2039  require(xns.contains_poset_member(xparent_path));
2040  require(!xname.empty());
2041  require(!xns.member_poset(xparent_path).contains_member(xname));
2042  require_for_all(i, 0, xdof_ct, !xdof_names[i].empty());
2043  require(unexecutable("if xdof_names[i] already exists, must have type xdof_type[i]"));
2044  require(unexecutable("if xdof_names[i] already exists, must have role xis_table_dof[i]"));
2045 
2046  // Body:
2047 
2048  // Get handles for the schema poset and the dof subposets.
2049 
2050  poset_state_handle& lschema_poset = xns.member_poset(xparent_path);
2051  subposet ltable_dof_sp(&lschema_poset, table_dof_subposet_name("top"));
2052  subposet lrow_dof_sp(&lschema_poset, row_dof_subposet_name("top"));
2053 
2054  // Create a temporary member handle.
2055 
2056  schema_poset_member lschema_mbr;
2057 
2058  // Put the parent in the expansion of the new member.
2059 
2060  lschema_mbr.attach_to_state(&lschema_poset, xparent_path.member_name());
2061  block<scoped_index> lexpansion(xdof_ct+1);
2062  lexpansion.push_back(lschema_mbr.index());
2063 
2064  // Put each dof in the expansion.
2065 
2066  if(xdof_ct > 0)
2067  {
2068  lschema_poset.begin_jim_edit_mode();
2069  for(size_type i=0; i<xdof_ct; ++i)
2070  {
2071  const string& ldof_name = xdof_names[i];
2072  if(lschema_poset.contains_member(ldof_name))
2073  {
2074  // The dof already exists, just attach to it.
2075 
2076  lschema_mbr.attach_to_state(ldof_name);
2077 
2078  // Requested role must match existing role.
2079 
2080  assertion(lschema_mbr.is_dof(xis_table_dof[i]));
2081  }
2082  else
2083  {
2084  // Create the dof.
2085 
2086  lschema_mbr.new_jim_state(xdof_types[i], false);
2087  lschema_mbr.put_name(ldof_name, true, false);
2088 
2089  // Insert it in the appropriate dof subposet.
2090 
2091  subposet& ldof_sp = xis_table_dof[i] ? ltable_dof_sp : lrow_dof_sp;
2092  ldof_sp.insert_member(lschema_mbr.index());
2093  }
2094 
2095  // Put it in the expansion.
2096 
2097  lexpansion.push_back(lschema_mbr.index());
2098  }
2099 
2100  lschema_poset.end_jim_edit_mode();
2101  }
2102 
2103  // Create the new member as the join of its expansion.
2104 
2105  lschema_mbr.new_jrm_state(lexpansion.base(), lexpansion.ct(), tern::TRUE, false);
2106  lschema_mbr.put_name(xname, true, false);
2107 
2108  // Make the result
2109 
2110  poset_path result(lschema_mbr.path());
2111 
2112  // Clean up.
2113 
2114  lschema_mbr.detach_from_state();
2115  lrow_dof_sp.detach_from_state();
2116  ltable_dof_sp.detach_from_state();
2117 
2118  // Postconditions:
2119 
2120  ensure(xns.contains_poset_member(xparent_path.poset_name()+"/"+xname));
2121 
2122  if(xauto_access)
2123  {
2124  lschema_poset.release_access();
2125  xns.release_access();
2126  }
2127 
2128  // Exit:
2129 
2130  return result;
2131 }
2132 
2136  const poset_path& xparent_path,
2137  const std::string& xname,
2138  const std::string xdof_names[],
2139  const primitive_type xdof_types[],
2140  const size_type xdof_ct,
2141  bool xauto_access)
2142 {
2143 
2144  // Preconditions:
2145 
2146  require(precondition_of(make_schema(xns, xparent_path, xname, xdof_names, xdof_types, false{}, xdof_ct, xauto_access)));
2147 
2148  // Body:
2149 
2150  bool* ldof_roles = new bool[xdof_ct];
2151  for(int i=0; i< xdof_ct; ++i)
2152  {
2153  ldof_roles[i] = false;
2154  }
2155 
2156  poset_path result =
2157  make_schema(xns,
2158  xparent_path,
2159  xname,
2160  xdof_names,
2161  xdof_types,
2162  ldof_roles,
2163  xdof_ct,
2164  xauto_access);
2165 
2166  delete [] ldof_roles;
2167 
2168  // Postconditions:
2169 
2170  ensure(postcondition_of(make_schema(xns, xparent_path, xname, xdof_names, xdof_types, false[], xdof_ct, xauto_access)));
2171 
2172  // Exit:
2173 
2174  return result;
2175 }
2176 
2180  const poset_path& xparent_path,
2181  const std::string& xname,
2182  const std::string xdof_names[],
2183  const primitive_type xdof_type,
2184  const size_type xdof_ct,
2185  bool xauto_access)
2186 {
2187  // Preconditions:
2188 
2189  require(precondition_of(make_row_schema(xns, xparent_path, xname, xdof_names, xdof_type[], xdof_ct, xauto_access)));
2190 
2191  // Body:
2192 
2193  typedef primitive_type prim_type;
2194  prim_type* ldof_types = new prim_type[xdof_ct];
2195  for(int i=0; i< xdof_ct; ++i)
2196  {
2197  ldof_types[i] = xdof_type;
2198  }
2199 
2200  poset_path result =
2201  make_row_schema(xns,
2202  xparent_path,
2203  xname,
2204  xdof_names,
2205  ldof_types,
2206  xdof_ct,
2207  xauto_access);
2208 
2209  delete [] ldof_types;
2210 
2211  // Postconditions:
2212 
2213  ensure(postcondition_of(make_row_schema(xns, xparent_path, xname, xdof_names, xdof_type[], xdof_ct, xauto_access)));
2214 
2215  // Exit:
2216 
2217  return result;
2218 }
2219 
2220 void
2223  const std::string member_names[],
2224  const int num_members,
2225  const int member_dof_type,
2226  const std::string& schema_poset_name,
2227  const std::string& schema_member_name,
2228  const std::string& schema_inherits_name)
2229 {
2230  // Preconditions:
2231 
2232  // Body:
2233 
2234  typedef primitive_type prim_type;
2235 
2236  prim_type* ltypes = new prim_type[num_members];
2237  for(int i=0; i< num_members; ++i)
2238  {
2239  ltypes[i] = prim_type(member_dof_type);
2240  }
2241 
2242  bool* lroles = new bool[num_members];
2243  for(int i=0; i< num_members; ++i)
2244  {
2245  lroles[i] = false;
2246  }
2247 
2248  poset_path lparent_path(schema_poset_name, schema_inherits_name);
2249 
2250  make_schema(*xns,
2251  lparent_path,
2252  schema_member_name,
2253  member_names,
2254  ltypes,
2255  lroles,
2256  num_members,
2257  true);
2258 
2259  delete [] ltypes;
2260  delete [] lroles;
2261 
2262  // Postconditions:
2263 
2264  // Exit:
2265 
2266  return;
2267 }
2268 
2269 void
2272  const std::string member_names[],
2273  const int num_members,
2274  const int member_dof_type,
2275  const std::string& schema_poset_name,
2276  const std::string& schema_member_name,
2277  const std::string& schema_inherits_name)
2278 {
2279  // Preconditions:
2280 
2281  // Body:
2282 
2283  typedef primitive_type prim_type;
2284 
2285  prim_type* ltypes = new prim_type[num_members];
2286  for(int i=0; i< num_members; ++i)
2287  {
2288  ltypes[i] = prim_type(member_dof_type);
2289  }
2290 
2291  bool* lroles = new bool[num_members];
2292  for(int i=0; i< num_members; ++i)
2293  {
2294  lroles[i] = true;
2295  }
2296 
2297 
2298  poset_path lparent_path(schema_poset_name, schema_inherits_name);
2299 
2300  make_schema(*xns,
2301  lparent_path,
2302  schema_member_name,
2303  member_names,
2304  ltypes,
2305  lroles,
2306  num_members,
2307  true);
2308 
2309  delete [] ltypes;
2310  delete [] lroles;
2311 
2312  // Postconditions:
2313 
2314  // Exit:
2315 
2316  return;
2317 }
2318 
2319 void
2322 {
2323  // Preconditions:
2324 
2325  require(state_is_read_accessible());
2326  require(host()->is_schematized(false));
2327 
2328  // Body:
2329 
2331  update_row_cache(true);
2332 
2333  // Postconditions:
2334 
2335  ensure(table_cache_consistent());
2336  ensure(row_cache_consistent());
2337 
2338  // Exit:
2339 
2340  return;
2341 }
2342 
2345 dof_descriptors(bool xis_table_dof) const
2346 {
2347  dof_descriptor_array* result;
2348 
2349  // Preconditions:
2350 
2351  require(state_is_read_accessible());
2352 
2353  // Body:
2354 
2355  result = xis_table_dof ? table_dof_descriptors() : row_dof_descriptors();
2356 
2357  // Postconditions:
2358 
2359  ensure(unexecutable(result != 0 implies it points to a buffer of length table_dof_ct()+1));
2360 
2361  // Exit
2362 
2363  return result;
2364 }
2365 
2369 {
2370  dof_descriptor_array* result;
2371 
2372  // Preconditions:
2373 
2374  require(state_is_read_accessible());
2375 
2376  // Body:
2377 
2378  if(!table_cache_consistent())
2379  {
2381  }
2382 
2383  result = _table_dof_descriptors;
2384 
2385  // Postconditions:
2386 
2387  ensure(unexecutable(result != 0 implies it points to a buffer of length table_dof_ct()+1));
2388 
2389  // Exit
2390 
2391  return result;
2392 }
2393 
2397 {
2398  dof_descriptor_array* result;
2399 
2400  // Preconditions:
2401 
2402  require(state_is_read_accessible());
2403 
2404  // Body:
2405 
2406  if(!row_cache_consistent())
2407  {
2408  update_row_cache();
2409  }
2410 
2411  result = _row_dof_descriptors;
2412 
2413  // Postconditions:
2414 
2415  ensure(unexecutable(result != 0 implies it points to a buffer of length row_dof_ct()+1));
2416 
2417  // Exit
2418 
2419  return result;
2420 }
2421 
2422 // PROTECTED MEMBER FUNCTIONS
2423 
2426 dof_subposet_state(bool xis_table_dof)
2427 {
2428  return powerset_member(dof_subposet_index(xis_table_dof));
2429 }
2430 
2431 void
2434 {
2435  // Preconditions:
2436 
2437  require(state_is_read_accessible());
2438 
2439  // Body:
2440 
2441  // dof_subposet_name() requires !name().empty().
2442 
2443  // Release the current table dof and row dof id space handles, if any.
2444 
2445  if(_table_dof_id_space != 0)
2446  {
2448  _table_dof_id_space = 0;
2449  }
2450 
2451  if(_row_dof_id_space != 0)
2452  {
2454  _row_dof_id_space = 0;
2455  }
2456 
2457  if(!name().empty())
2458  {
2461 
2462  // Assign the table dof id space.
2463 
2464  const index_space_family& lid_spaces = host()->member_id_spaces(false);
2465 
2466  if(lid_spaces.contains(table_dof_subposet_name()))
2467  {
2469  }
2470 
2471  // Assign the row dof id space.
2472 
2473  if(lid_spaces.contains(row_dof_subposet_name()))
2474  {
2476  }
2477  }
2478  else
2479  {
2482  }
2483 
2484  // Postconditions:
2485 
2486  // Exit
2487 
2488  return;
2489 }
2490 
2491 bool
2494 {
2495  bool result;
2496 
2497  // Preconditions:
2498 
2499  require(state_is_read_accessible());
2500 
2501  // Body:
2502 
2503  result = (_table_cache_index == index()) && (_table_cache_version == version());
2504 
2505  // Postconditions:
2506 
2507  // Exit
2508 
2509  return result;
2510 }
2511 
2512 void
2515 {
2516  // Preconditions:
2517 
2518  require(state_is_read_accessible());
2519 
2520  // Body:
2521 
2523  {
2525  }
2526 
2528 
2530 
2533 
2534  // Postconditions:
2535 
2536  // Exit
2537 
2538  return;
2539 }
2540 
2541 bool
2544 {
2545  // Preconditions:
2546 
2547  require(state_is_read_accessible());
2548 
2549  // Body:
2550 
2551  bool result = initialize_dof_id_space(true);
2552 
2553  // Postconditions:
2554 
2555  // Exit:
2556 
2557  return result;
2558 }
2559 
2560 void
2563 {
2564  // Preconditions:
2565 
2566  require(state_is_read_accessible());
2567 
2568  // Body:
2569 
2570  update_dof_id_space(true);
2571 
2572  // Postconditions:
2573 
2574  // Exit:
2575 
2576  return;
2577 }
2578 
2579 void
2582 {
2583  // Preconditions:
2584 
2585  require(state_is_read_accessible());
2586 
2587  // Body:
2588 
2591  _table_dof_ct,
2593 
2594  // Postconditions:
2595 
2596  // Exit:
2597 
2598  return;
2599 }
2600 
2601 bool
2604 {
2605  bool result;
2606 
2607  // Preconditions:
2608 
2609  require(state_is_read_accessible());
2610 
2611  // Body:
2612 
2613  result = (_row_cache_index == index()) && (_row_cache_version == version());
2614 
2615  // Postconditions:
2616 
2617  // Exit
2618 
2619  return result;
2620 }
2621 
2622 void
2624 update_row_cache(bool xupdate_id_space) const
2625 {
2626  // Preconditions:
2627 
2628  require(state_is_read_accessible());
2629 
2630  // Body:
2631 
2632  if(xupdate_id_space || initialize_row_dof_id_space())
2633  {
2635  }
2636 
2638 
2640 
2641  _row_cache_index = index();
2643 
2644  // Postconditions:
2645 
2646  // Exit
2647 
2648  return;
2649 }
2650 
2651 bool
2654 {
2655  // Preconditions:
2656 
2657  require(state_is_read_accessible());
2658 
2659  // Body:
2660 
2661  bool result = initialize_dof_id_space(false);
2662 
2663  // Postconditions:
2664 
2665  // Exit:
2666 
2667  return result;
2668 }
2669 
2670 void
2673 {
2674  // Preconditions:
2675 
2676  require(state_is_read_accessible());
2677 
2678  // Body:
2679 
2680  update_dof_id_space(false);
2681 
2682  // Postconditions:
2683 
2684  // Exit:
2685 
2686  return;
2687 }
2688 
2689 void
2692 {
2693  // Preconditions:
2694 
2695  require(state_is_read_accessible());
2696 
2697  // Body:
2698 
2699  update_dof_descriptors(false,
2701  _row_dof_ct,
2703 
2704  // Postconditions:
2705 
2706  // Exit:
2707 
2708  return;
2709 }
2710 
2711 bool
2713 initialize_dof_id_space(bool xis_table_dof) const
2714 {
2715  // Preconditions:
2716 
2717  require(state_is_read_accessible());
2718 
2719  // Body:
2720 
2721  bool result = false;
2722 
2723  index_space_handle* ldof_id_space =
2724  xis_table_dof ? _table_dof_id_space : _row_dof_id_space;
2725 
2726  if(ldof_id_space == 0)
2727  {
2728  // Dof id space is not initialized, initialize it.
2729 
2730  string ldof_id_space_name(schema_poset_member::dof_subposet_name(name(), xis_table_dof));
2731  if(!host()->member_id_spaces(false).contains(ldof_id_space_name))
2732  {
2733  // Id space does not exist, create it. Force the update.
2734 
2735  array_index_space_state::new_space(host()->member_id_spaces(false),
2736  ldof_id_space_name,
2737  false, 0);
2738 
2739  result = true;
2740  }
2741 
2742  ldof_id_space = &host()->member_id_spaces(false).get_id_space(ldof_id_space_name);
2743 
2744  // Assign the data member.
2745 
2746  if(xis_table_dof)
2747  {
2748  _table_dof_id_space = ldof_id_space;
2749  }
2750  else
2751  {
2752  _row_dof_id_space = ldof_id_space;
2753  }
2754  }
2755 
2756  // Postconditions:
2757 
2758  // Exit:
2759 
2760  return result;
2761 }
2762 
2763 void
2765 update_dof_id_space(bool xis_table_dof) const
2766 {
2767  // Preconditions:
2768 
2769  require(state_is_read_accessible());
2770 
2771  // Body:
2772 
2773  // Get the dof id space;
2774 
2776  reinterpret_cast<scattered_insertion_index_space_handle*>
2777  (xis_table_dof ? _table_dof_id_space : _row_dof_id_space);
2778 
2779  // Traverse the graph and extract the dof ids.
2780 
2781  string ltop_sp_name(schema_poset_member::dof_subposet_name("top", xis_table_dof));
2782  subposet ltop_sp(host(), ltop_sp_name);
2783  const index_space_handle& ltop_space = ltop_sp.id_space();
2784 
2785  set<pod_index_type> ltop_seq_ids;
2786 
2787  poset_dof_iterator* litr = dof_iterator(xis_table_dof);
2788  while(!litr->is_done())
2789  {
2790  ltop_seq_ids.insert(ltop_space.pod(litr->index()));
2791  litr->next();
2792  }
2793  delete litr;
2794 
2795  ldof_id_space->reserve(ltop_seq_ids.size());
2796 
2797  set<pod_index_type>::iterator lseq_id_itr;
2798  for(lseq_id_itr = ltop_seq_ids.begin();
2799  lseq_id_itr != ltop_seq_ids.end();
2800  ++lseq_id_itr)
2801  {
2802  ldof_id_space->push_back(ltop_space.hub_pod(*lseq_id_itr));
2803  }
2804 
2805  ltop_sp.detach_from_state();
2806 
2807  // Postconditions:
2808 
2809  // Exit:
2810 
2811  return;
2812 }
2813 
2814 void
2816 update_dof_descriptors(bool xis_table_dof,
2817  dof_descriptor_array*& xdof_descriptors,
2818  size_type xdof_ct,
2819  size_type& xdof_tuple_ub) const
2820 {
2821  // Preconditions:
2822 
2823  require(state_is_read_accessible());
2824 
2825  // Body:
2826 
2827  // (Re)allocate the dof descriptors.
2828 
2829  if(xdof_descriptors != 0)
2830  {
2831  xdof_descriptors->remove_reference();
2832  }
2833  xdof_descriptors = new dof_descriptor_array(xdof_ct);
2834  xdof_descriptors->add_reference();
2835 
2836  // Compute the dof descriptors and dof tuple upper bound
2837 
2838  schema_poset_member* lschema_mbr = clone();
2839  xdof_tuple_ub = 0;
2840  index_space_handle* ldof_id_space =
2841  xis_table_dof ? _table_dof_id_space : _row_dof_id_space;
2842 
2843  index_space_iterator& itr = ldof_id_space->get_iterator();
2844  while(!itr.is_done())
2845  {
2846  lschema_mbr->attach_to_state(_host, itr.hub_pod());
2847 
2848  xdof_tuple_ub = align(xdof_tuple_ub, lschema_mbr->alignment());
2849 
2850  dof_descriptor_array::dof_descriptor& ldesc = (*xdof_descriptors)[itr.pod()];
2851 
2852  ldesc.size = lschema_mbr->size();
2853  ldesc.alignment = lschema_mbr->alignment();
2854  ldesc.type = lschema_mbr->type();
2855  ldesc.offset = xdof_tuple_ub;
2856 
2857  xdof_tuple_ub += ldesc.size;
2858 
2859 #ifdef DIAGNOSTIC_OUTPUT
2860  cout << " dof name: " << lschema_mbr->name()
2861  << " seq id: " << itr.pod()
2862  << " dof descriptor: " << ldesc
2863  << endl;
2864 #endif
2865 
2866  itr.next();
2867  }
2868 
2869  ldof_id_space->release_iterator(itr);
2870  lschema_mbr->detach_from_state();
2871  delete lschema_mbr;
2872 
2873  // The last offset is the size of the entire tuple
2874 
2875  dof_descriptor_array::dof_descriptor& ldesc = (*xdof_descriptors)[xdof_ct];
2876  ldesc.size = 0;
2877  ldesc.alignment = 0;
2878  ldesc.type = NOT_A_PRIMITIVE_TYPE;
2879  ldesc.offset = xdof_tuple_ub;
2880 
2881  // Postcconditions:
2882 
2883  ensure((xdof_ct > 0) == (xdof_tuple_ub > 0));
2884 
2885  // Exit:
2886 
2887  return;
2888 }
2889 
2890 // PRIVATE MEMBER FUNCTIONS
2891 
2892 
2893 // ===========================================================
2894 // NEW DOF ACCESS FACET
2895 // ===========================================================
2896 
2897 // PUBLIC MEMBER FUNCTIONS
2898 
2901 dof_id_space(bool xis_table_dofs) const
2902 {
2903  // Preconditions:
2904 
2905  require(state_is_read_accessible());
2906 
2907  // Body:
2908 
2909  if(xis_table_dofs && !table_cache_consistent())
2910  {
2912  }
2913  else if(!xis_table_dofs && !row_cache_consistent())
2914  {
2915  update_row_cache();
2916  }
2917 
2918  const index_space_handle& result =
2919  xis_table_dofs ? *_table_dof_id_space : *_row_dof_id_space;
2920 
2921  // Postconditions:
2922 
2923  ensure(result.is_attached());
2924 
2925  // Exit:
2926 
2927  return result;
2928 }
2929 
2932 dof_id_space(bool xis_table_dofs, bool xauto_access) const
2933 {
2934  // Preconditions:
2935 
2936  require(state_is_auto_read_accessible(xauto_access));
2937 
2938  // Body:
2939 
2940  if(xauto_access)
2941  {
2942  get_read_access();
2943  }
2944 
2945  const index_space_handle& result = dof_id_space(xis_table_dofs);
2946 
2947  if(xauto_access)
2948  {
2949  release_access();
2950  }
2951 
2952  // Postconditions:
2953 
2954  ensure(result.is_attached());
2955 
2956  // Exit:
2957 
2958  return result;
2959 }
2960 
2964 {
2965  // Preconditions:
2966 
2967  require(state_is_read_accessible());
2968 
2969  // Body:
2970 
2971  if(!table_cache_consistent())
2972  {
2974  }
2975 
2976  const index_space_handle& result = *_table_dof_id_space;
2977 
2978  // Postconditions:
2979 
2980  ensure(result.is_attached());
2981 
2982  // Exit:
2983 
2984  return result;
2985 }
2986 
2989 table_dof_id_space(bool xauto_access) const
2990 {
2991  // Preconditions:
2992 
2993  require(state_is_auto_read_accessible(xauto_access));
2994 
2995  // Body:
2996 
2997  if(xauto_access)
2998  {
2999  get_read_access();
3000  }
3001 
3002  const index_space_handle& result = table_dof_id_space();
3003 
3004  if(xauto_access)
3005  {
3006  release_access();
3007  }
3008 
3009  // Postconditions:
3010 
3011  ensure(result.is_attached());
3012 
3013  // Exit:
3014 
3015  return result;
3016 }
3017 
3021 {
3022  // Preconditions:
3023 
3024  require(state_is_read_accessible());
3025 
3026  // Body:
3027 
3028  if(!row_cache_consistent())
3029  {
3030  update_row_cache();
3031  }
3032 
3033  const index_space_handle& result = *_row_dof_id_space;
3034 
3035  // Postconditions:
3036 
3037  ensure(result.is_attached());
3038 
3039  // Exit:
3040 
3041  return result;
3042 }
3043 
3046 row_dof_id_space(bool xauto_access) const
3047 {
3048  // Preconditions:
3049 
3050  require(state_is_auto_read_accessible(xauto_access));
3051 
3052  // Body:
3053 
3054  if(xauto_access)
3055  {
3056  get_read_access();
3057  }
3058 
3059  const index_space_handle& result = row_dof_id_space();
3060 
3061  if(xauto_access)
3062  {
3063  release_access();
3064  }
3065 
3066  // Postconditions:
3067 
3068  ensure(result.is_attached());
3069 
3070  // Exit:
3071 
3072  return result;
3073 }
3074 
3075 std::string
3077 name(pod_index_type xdof_id, bool xis_table_dof) const
3078 {
3079  // Preconditions:
3080 
3081  require(state_is_read_accessible());
3082  require(dof_id_space(xis_table_dof).contains(xdof_id));
3083 
3084  // Body:
3085 
3086  pod_index_type lhub_pod = dof_id_space(xis_table_dof).hub_pod(xdof_id);
3087 
3088  string result(host()->member_name(lhub_pod, false));
3089 
3090  // Postconditions:
3091 
3092  // Exit:
3093 
3094  return result;
3095 }
3096 
3097 std::string
3099 name(const scoped_index& xdof_id, bool xis_table_dof, bool xauto_access) const
3100 {
3101  // Preconditions:
3102 
3103  require(state_is_auto_read_accessible(xauto_access));
3104  require(dof_id_space(xis_table_dof, xauto_access).contains(xdof_id));
3105 
3106  // Body:
3107 
3108  string result(host()->member_name(xdof_id, xauto_access));
3109 
3110  // Postconditions:
3111 
3112  // Exit:
3113 
3114  return result;
3115 }
3116 
3119 size(pod_index_type xdof_id, bool xis_table_dof) const
3120 {
3121  // Preconditions:
3122 
3123  require(state_is_read_accessible());
3124  require(dof_id_space(xis_table_dof).contains(xdof_id));
3125 
3126  // Body:
3127 
3128  size_type result = (*dof_descriptors(xis_table_dof))[xdof_id].size;
3129 
3130  // Postconditions:
3131 
3132  // Exit:
3133 
3134  return result;
3135 }
3136 
3139 size(const scoped_index& xdof_id, bool xis_table_dof, bool xauto_access) const
3140 {
3141  // Preconditions:
3142 
3143  require(state_is_auto_read_accessible(xauto_access));
3144  require(dof_id_space(xis_table_dof, xauto_access).contains(xdof_id));
3145 
3146  // Body:
3147 
3148  if(xauto_access)
3149  {
3150  get_read_access();
3151  }
3152 
3153  pod_index_type lindex = dof_id_space(xis_table_dof).pod(xdof_id);
3154  size_type result = size(lindex, xis_table_dof);
3155 
3156  if(xauto_access)
3157  {
3158  release_access();
3159  }
3160 
3161  // Postconditions:
3162 
3163  // Exit:
3164 
3165  return result;
3166 }
3167 
3170 size(const std::string& xname, bool xis_table_dof, bool xauto_access) const
3171 {
3172  // Preconditions:
3173 
3174  require(state_is_auto_read_accessible(xauto_access));
3175 
3176  if(xauto_access)
3177  {
3178  get_read_access();
3179  }
3180 
3181  require(contains_dof(xname, xis_table_dof));
3182 
3183  // Body:
3184 
3185  pod_index_type lhub_id = host()->member_id(xname, false);
3186 
3187  pod_index_type lindex = dof_id_space(xis_table_dof).pod(lhub_id);
3188  size_type result = size(lindex, xis_table_dof);
3189 
3190  if(xauto_access)
3191  {
3192  release_access();
3193  }
3194 
3195  // Postconditions:
3196 
3197  // Exit:
3198 
3199  return result;
3200 }
3201 
3202 
3205 alignment(pod_index_type xdof_id, bool xis_table_dof) const
3206 {
3207  // Preconditions:
3208 
3209  require(state_is_read_accessible());
3210  require(dof_id_space(xis_table_dof).contains(xdof_id));
3211 
3212  // Body:
3213 
3214  size_type result = (*dof_descriptors(xis_table_dof))[xdof_id].alignment;
3215 
3216  // Postconditions:
3217 
3218  // Exit:
3219 
3220  return result;
3221 }
3222 
3225 alignment(const scoped_index& xdof_id, bool xis_table_dof, bool xauto_access) const
3226 {
3227  // Preconditions:
3228 
3229  require(state_is_auto_read_accessible(xauto_access));
3230  require(dof_id_space(xis_table_dof, xauto_access).contains(xdof_id));
3231 
3232  // Body:
3233 
3234  if(xauto_access)
3235  {
3236  get_read_access();
3237  }
3238 
3239  pod_index_type lindex = dof_id_space(xis_table_dof).pod(xdof_id);
3240  size_type result = alignment(lindex, xis_table_dof);
3241 
3242  if(xauto_access)
3243  {
3244  release_access();
3245  }
3246 
3247  // Postconditions:
3248 
3249  // Exit:
3250 
3251  return result;
3252 }
3253 
3256 alignment(const std::string& xname, bool xis_table_dof, bool xauto_access) const
3257 {
3258  // Preconditions:
3259 
3260  require(state_is_auto_read_accessible(xauto_access));
3261 
3262  if(xauto_access)
3263  {
3264  get_read_access();
3265  }
3266 
3267  require(contains_dof(xname, xis_table_dof));
3268 
3269  // Body:
3270 
3271  pod_index_type lhub_id = host()->member_id(xname, false);
3272 
3273  pod_index_type lindex = dof_id_space(xis_table_dof).pod(lhub_id);
3274  size_type result = alignment(lindex, xis_table_dof);
3275 
3276  if(xauto_access)
3277  {
3278  release_access();
3279  }
3280 
3281  // Postconditions:
3282 
3283  // Exit:
3284 
3285  return result;
3286 }
3287 
3290 type(pod_index_type xdof_id, bool xis_table_dof) const
3291 {
3292  // Preconditions:
3293 
3294  require(state_is_read_accessible());
3295  require(dof_id_space(xis_table_dof).contains(xdof_id));
3296 
3297  // Body:
3298 
3299  primitive_type result =
3300  primitive_attributes::id((*dof_descriptors(xis_table_dof))[xdof_id].type);
3301 
3302  // Postconditions:
3303 
3304  // Exit:
3305 
3306  return result;
3307 }
3308 
3311 type(const scoped_index& xdof_id, bool xis_table_dof, bool xauto_access) const
3312 {
3313  // Preconditions:
3314 
3315  require(state_is_auto_read_accessible(xauto_access));
3316  require(dof_id_space(xis_table_dof, xauto_access).contains(xdof_id));
3317 
3318  // Body:
3319 
3320  if(xauto_access)
3321  {
3322  get_read_access();
3323  }
3324 
3325  pod_index_type lindex = dof_id_space(xis_table_dof).pod(xdof_id);
3326  primitive_type result = type(lindex, xis_table_dof);
3327 
3328  if(xauto_access)
3329  {
3330  release_access();
3331  }
3332 
3333  // Postconditions:
3334 
3335  // Exit:
3336 
3337  return result;
3338 }
3339 
3342 type(const std::string& xname, bool xis_table_dof, bool xauto_access) const
3343 {
3344  // Preconditions:
3345 
3346  require(state_is_auto_read_accessible(xauto_access));
3347 
3348  if(xauto_access)
3349  {
3350  get_read_access();
3351  }
3352 
3353  require(contains_dof(xname, xis_table_dof));
3354 
3355  // Body:
3356 
3357  pod_index_type lhub_id = host()->member_id(xname, false);
3358 
3359  pod_index_type lindex = dof_id_space(xis_table_dof).pod(lhub_id);
3360  primitive_type result = type(lindex, xis_table_dof);
3361 
3362  if(xauto_access)
3363  {
3364  release_access();
3365  }
3366 
3367  // Postconditions:
3368 
3369  // Exit:
3370 
3371  return result;
3372 }
3373 
3376 offset(pod_index_type xdof_id, bool xis_table_dof) const
3377 {
3378  // Preconditions:
3379 
3380  require(state_is_read_accessible());
3381  require(dof_id_space(xis_table_dof).contains(xdof_id));
3382 
3383  // Body:
3384 
3385  size_type result = (*dof_descriptors(xis_table_dof))[xdof_id].offset;
3386 
3387  // Postconditions:
3388 
3389  // Exit:
3390 
3391  return result;
3392 }
3393 
3396 offset(const scoped_index& xdof_id, bool xis_table_dof, bool xauto_access) const
3397 {
3398  // Preconditions:
3399 
3400  require(state_is_auto_read_accessible(xauto_access));
3401  require(dof_id_space(xis_table_dof, xauto_access).contains(xdof_id));
3402 
3403  // Body:
3404 
3405  if(xauto_access)
3406  {
3407  get_read_access();
3408  }
3409 
3410  pod_index_type lindex = dof_id_space(xis_table_dof).pod(xdof_id);
3411  size_type result = offset(lindex, xis_table_dof);
3412 
3413  if(xauto_access)
3414  {
3415  release_access();
3416  }
3417 
3418  // Postconditions:
3419 
3420  // Exit:
3421 
3422  return result;
3423 }
3424 
3427 offset(const std::string& xname, bool xis_table_dof, bool xauto_access) const
3428 {
3429  // Preconditions:
3430 
3431  require(state_is_auto_read_accessible(xauto_access));
3432 
3433  if(xauto_access)
3434  {
3435  get_read_access();
3436  }
3437 
3438  require(contains_dof(xname, xis_table_dof));
3439 
3440  // Body:
3441 
3442  pod_index_type lhub_id = host()->member_id(xname, false);
3443 
3444  pod_index_type lindex = dof_id_space(xis_table_dof).pod(lhub_id);
3445  size_type result = offset(lindex, xis_table_dof);
3446 
3447  if(xauto_access)
3448  {
3449  release_access();
3450  }
3451 
3452  // Postconditions:
3453 
3454  // Exit:
3455 
3456  return result;
3457 }
3458 
3459 // PROTECTED MEMBER FUNCTIONS
3460 
3461 // PRIVATE MEMBER FUNCTIONS
3462 
3463 
3464 // ===========================================================
3465 // I/O SUPPORT FACET
3466 // ===========================================================
3467 
3468 // PUBLIC MEMBER FUNCTIONS
3469 
3473 {
3476 
3477  // Preconditions:
3478 
3479  require(state_is_read_accessible());
3480  require(host()->includes_subposet(xindex));
3481 
3482  // Body:
3483 
3484  index_iterator* result = host()->get_decomposition(xindex);
3485 
3486  // Postconditions:
3487 
3488  // Exit:
3489 
3490  return result;
3491 }
3492 
3495 bound_iterator(const poset_bounds& xbounds, bool xis_ub) const
3496 {
3497  index_iterator* result;
3498 
3499  // Preconditions:
3500 
3501  require(state_is_read_accessible());
3502 
3503  // Body:
3504 
3505  pod_index_type lbnd_id;
3506  bool lsingleton;
3507 
3508  if(xis_ub)
3509  {
3510  lbnd_id = xbounds.ub_id();
3511  lsingleton = xbounds.ub_is_singleton();
3512  }
3513  else
3514  {
3515  lbnd_id = xbounds.lb_id();
3516  lsingleton = xbounds.lb_is_singleton();
3517  }
3518 
3519  if(lsingleton)
3520  {
3521  zn_to_bool* l_lb = new zn_to_bool();
3522  l_lb->force(lbnd_id, true);
3523  result = new index_iterator(l_lb, _host->member_hub_id_space(false), true);
3524  }
3525  else
3526  {
3527  result = get_decomposition(lbnd_id);
3528  }
3529 
3530  // Postconditions:
3531 
3532  ensure(result != 0);
3533 
3534  // Exit:
3535 
3536  return result;
3537 }
3538 
3541 get_int_id(pod_index_type xext_id, const std::string& xid_space_name) const
3542 {
3543  // Preconditions:
3544 
3545  require(state_is_read_accessible());
3546  require(xext_id >= host()->standard_member_ct() ?
3547  host()->member_id_spaces(false).contains(xid_space_name) :
3548  true);
3549  require(xext_id >= host()->standard_member_ct() ?
3550  host()->member_id_spaces(false).contains(xid_space_name, xext_id) :
3551  true);
3552 
3553  // Body:
3554 
3555  pod_index_type result = host()->get_int_id(xext_id, xid_space_name, false);
3556 
3557  // Postconditions:
3558 
3559  ensure(host()->contains_member(result, false));
3560 
3561  // Exit:
3562 
3563  return result;
3564 }
3565 
3568 get_ext_id(const std::string& xid_space_name) const
3569 {
3570  // Preconditions:
3571 
3572  require(state_is_read_accessible());
3573  require(precondition_of(host()->get_ext_id(index(), xid_space_name)));
3574 
3575 
3576  // Body:
3577 
3578  pod_index_type result = host()->get_ext_id(index(), xid_space_name, false);
3579 
3580  // Postconditions:
3581 
3582  // Exit:
3583 
3584  return result;
3585 }
3586 
3587 void
3589 get_ext_ids(const std::string& xid_space_name,
3590  pod_index_type& xschema_poset_ext_id,
3591  pod_index_type& xschema_member_ext_id,
3592  pod_index_type& xbase_space_ext_id,
3593  pod_index_type& xfiber_schema_ext_id,
3594  pod_index_type& xlocal_schema_ext_id) const
3595 {
3596  // Preconditions:
3597 
3598  require(state_is_read_accessible());
3599  require(name_space()->state_is_read_accessible());
3600 
3601  // Body:
3602 
3603  // Get the external ids for the schema poset (this->host()) and member (this).
3604 
3605  xschema_poset_ext_id =
3606  name_space()->get_ext_id(host()->index(), xid_space_name, false);
3607 
3608  xschema_member_ext_id =
3609  host()->get_ext_id(index(), xid_space_name, false);
3610 
3611  // Other external ids are undefined.
3612 
3613  xbase_space_ext_id = invalid_pod_index();
3614  xfiber_schema_ext_id = invalid_pod_index();
3615  xlocal_schema_ext_id = invalid_pod_index();
3616 
3617  // Postconditions:
3618 
3619  // Exit:
3620 
3621  return;
3622 }
3623 
3627 {
3628  return *this;
3629 }
3630 
3631 size_t
3633 ext_data_type_ct(bool xis_table_schema) const
3634 {
3635  // Preconditions:
3636 
3637  require(state_is_read_accessible());
3638 
3639  // Body:
3640 
3641  // For oridnary schema members,
3642  // the external data type is the entire schema.
3643 
3644  size_t result = 1;
3645 
3646  // Postconditions:
3647 
3648  // Exit:
3649 
3650  return result;
3651 }
3652 
3653 // PROTECTED MEMBER FUNCTIONS
3654 
3655 // PRIVATE MEMBER FUNCTIONS
3656 
3657 
3658 // ===========================================================
3659 // DEGREE OF FREEDOM (DOF) TUPLE FACET
3660 // ===========================================================
3661 
3662 // PUBLIC MEMBER FUNCTIONS
3663 
3666 dof_map(bool xrequire_write_access)
3667 {
3668 
3669  // Preconditions:
3670 
3671  require(xrequire_write_access ?
3674  require(is_jim(false));
3675 
3676  // Body:
3677 
3678  // poset_state_handle ensures schema uses primitives_poset_dof_map
3681 
3682  primitives_poset_dof_map& result =
3683  reinterpret_cast<primitives_poset_dof_map&>(total_poset_member::dof_map(xrequire_write_access));
3684 
3685  // Postconditions:
3686 
3687  // Exit:
3688 
3689  return result;
3690 }
3691 
3694 dof_map(bool xrequire_write_access) const
3695 {
3696  // Preconditions:
3697 
3698  require(xrequire_write_access ?
3701  require(is_jim(false));
3702 
3703  // Body:
3704 
3705  // poset_state_handle ensures schema uses primitives_poset_dof_map
3708 
3709  const primitives_poset_dof_map& result =
3710  reinterpret_cast<const primitives_poset_dof_map&>(total_poset_member::dof_map(xrequire_write_access));
3711 
3712  // Postconditions:
3713 
3714  // Exit:
3715 
3716  return result;
3717 }
3718 
3719 bool
3722 {
3723  bool result;
3724 
3725  // Preconditions:
3726 
3727  require(xdof_map != 0);
3728 
3729  // Body:
3730 
3731  result = dynamic_cast<const primitives_poset_dof_map*>(xdof_map) != 0;
3732 
3733  // Postconditions:
3734 
3735  // Exit
3736 
3737  return result;
3738 }
3739 
3740 // PROTECTED MEMBER FUNCTIONS
3741 
3742 // PRIVATE MEMBER FUNCTIONS
3743 
3744 
3745 // ===========================================================
3746 // STATE FACET
3747 // ===========================================================
3748 
3749 // PUBLIC MEMBER FUNCTIONS
3750 
3751 void
3754 {
3755  // Preconditions:
3756 
3757  // Body:
3758 
3759  if(_table_dof_id_space != 0)
3760  {
3762  _table_dof_id_space = 0;
3763  }
3764 
3765  if(_row_dof_id_space != 0)
3766  {
3768  _row_dof_id_space = 0;
3769  }
3770 
3772 
3773  // Postconditions:
3774 
3775  ensure(invariant());
3776  ensure(!is_attached());
3777 }
3778 
3779 // PROTECTED MEMBER FUNCTIONS
3780 
3781 // PRIVATE MEMBER FUNCTIONS
3782 
3783 
3784 // ===========================================================
3785 // ANY FACET
3786 // ===========================================================
3787 
3788 // PUBLIC MEMBER FUNCTIONS
3789 
3790 bool
3792 is_ancestor_of(const any* xother) const
3793 {
3794  bool result;
3795 
3796  // Preconditions:
3797 
3798  // Body:
3799 
3800  result = dynamic_cast<const schema_poset_member*>(xother) != 0;
3801 
3802  // Postconditions:
3803 
3804  // Exit
3805 
3806  return result;
3807 }
3808 
3811 clone() const
3812 {
3813  // Preconditions:
3814 
3815  // Body:
3816 
3817  // create new handle of the current class.
3818 
3819  schema_poset_member *result = new schema_poset_member();
3820 
3821  // Postconditions:
3822 
3823  ensure(result != 0);
3824  ensure(result->invariant());
3825 
3826  // Exit:
3827 
3828  return result;
3829 
3830 }
3831 
3832 bool
3834 invariant() const
3835 {
3836  bool result = true;
3837 
3838  // Preconditions:
3839 
3840  // Body:
3841 
3842  // Must satisfy base class invariant
3843 
3844  result = result && total_poset_member::invariant();
3845 
3846  if(invariant_check())
3847  {
3848  // Prevent recursive calls to invariant
3849 
3851 
3852  // Invariants for this class:
3853 
3856 
3857  // Finished, turn invariant checking back on.
3858 
3860  }
3861 
3862  // Postconditions:
3863 
3864  // Exit
3865 
3866  return result;
3867 }
3868 
3869 // PROTECTED MEMBER FUNCTIONS
3870 
3871 // PRIVATE MEMBER FUNCTIONS
3872 
3873 
3874 // ===========================================================
3875 // NON-MEMBER FUNCTIONS
3876 // ===========================================================
3877 
3878 size_t
3879 sheaf::
3880 deep_size(const schema_poset_member& xp, bool xinclude_shallow)
3881 {
3882  size_t result;
3883 
3884  // Preconditions:
3885 
3886  require(xp.state_is_read_accessible());
3887 
3888  // Body:
3889 
3890  result = xinclude_shallow ? sizeof(xp) : 0;
3891 
3892 #ifdef DIAGNOSTIC_OUTPUT
3893  cout << "$$$ deep_size(const schema_poset_mamber& xp) &xp = " << &xp << endl;
3894  cout << "$$$ deep_size(const schema_poset_mamber& xp) sizeof(xp) = " << sizeof(xp) << endl;
3895 #endif
3896 
3897  // Add any contributions from the parent class.
3898 
3899  const total_poset_member& p = static_cast<const total_poset_member&>(xp);
3900  result += deep_size(p);
3901 
3902  // Determine the deep size of data members:
3903  // dof_descriptor_array* _table_dof_descriptors.
3904  // dof_descriptor_array* _row_dof_descriptors.
3905 
3906  if(xp.table_dof_descriptors() != 0)
3907  {
3908  result += deep_size(*(xp.table_dof_descriptors()), false);
3909  }
3910 
3911  if(xp.row_dof_descriptors() != 0)
3912  {
3913  result += deep_size(*(xp.row_dof_descriptors()), false);
3914  }
3915 
3916 #ifdef DIAGNOSTIC_OUTPUT
3917  cout << "$$$ deep_size(const schema_poset_mamber& xp) result = " << result << endl;
3918 #endif
3919 
3920  // Postconditions:
3921 
3922  ensure(result >= 0);
3923 
3924  // Exit
3925 
3926  return result;
3927 }
virtual void force_is_done()
Force the iterator to be done.
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...
pod_index_type ub_id() const
The index of the upper bound member, if the upper bound contains a single member. ...
poset_state_handle * host() const
The poset which this is a handle to a component of.
virtual bool invariant() const
Class invariant.
virtual poset_path path(bool xauto_access=true) const
The path of this poset.
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 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 ~schema_poset_member()
Destructor; deletes a poset member and its attached state, if any.
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(...
bool is_valid() const
True if this is a valid id.
Definition: scoped_index.h:832
virtual void schematize(subposet *xtable_dof_subposet, subposet *xrow_dof_subposet, bool xall_members=false)
Prepare this poset and its top member for use as a schema. If xall_members = true, schematize all other members as well.
bool table_cache_consistent() const
True if cached table properties are consistent with index() and version().
bool lb_is_singleton() const
True if the lower bound contains a single member.
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
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.
bool covers(const abstract_poset_member *xother) const
True if this covers other.
virtual void next()
Makes this the next member of the subset.
const index_space_handle & row_dof_id_space() const
The row dof id space for the schema defined by this.
An abstract iterator over the ids of an id space.
virtual schema_poset_member * clone() const
Make a new handle, no state instance of current.
virtual size_t size() const
The number of bytes in this dof.
const index_space_handle & dof_id_space(bool xis_table_dofs) const
The table dof (xis_table_dof true) or row dof id space for the schema defined by this.
virtual bool has_id_space() const
True if this already has an id space.
Definition: subposet.cc:622
virtual index_iterator * get_decomposition(pod_index_type xindex) const
An iterator over the members of the decomposition identified by xindex.
virtual bool is_ancestor_of(const any *other) const
True if other conforms to this.
poset_path path(bool xauto_access=true) const
A path to this component.
pod_type pod() const
The current id in the iteration.
bool conforms_to(const schema_poset_member &xother) const
True if the dofs defined by this agree in type and in order with the dofs defined by xother...
The default name space; a poset which contains other posets as members.
bool table_conforms_to(const schema_poset_member &xother) const
True if the table dofs defined by this agree in type and in order with the dofs defined by xother...
virtual subposet_state * powerset_member(const scoped_index &xindex) const
The hidden state of the subposet asocciated with index xindex.
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 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 put_type(int xindex)
Put type dof. Note: have to use "type" in name in order to avoid name conflict with index() inherited...
schema_poset_member & item()
The current member of the iteration (mutable version).
poset_state_handle * _host
The host poset for this component.
static void make_table_dofs_schema(namespace_poset *xns, const std::string member_names[], const int num_members, const int member_dof_type, const std::string &schema_poset_name, const std::string &schema_member_name, const std::string &schema_inherits_name)
The data structure representing the state of a subposet.
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...
bool state_is_auto_read_accessible(bool xauto_access) const
True if the state is auto accessible for read, that is, if the state is already accessible for read o...
const scoped_index & table_dof_subposet_index() const
The index in host() of the subposet containing the the table dofs in the down set of this (const vers...
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.
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.
index_space_handle & get_id_space(const std::string &xname) const
Allocates an id space handle from the handle pool attached to state with name xname.
bool is_component() const
True if this represents a component in the row dofs part of some schema.
static int dof_ct(const namespace_poset &xns, const poset_path &xpath, bool xis_table_dof, bool xauto_access=true)
The number of table dofs (xis_table_dof true) or row dofs defined by the schema specified by xns and ...
static host_type & standard_host(namespace_type &xns, const poset_path &xhost_path, bool xauto_access)
The host with path xhost_path.Returns the host if it already exists, otherwise, creates it in namespa...
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
dof_descriptor_array * dof_descriptors(bool xis_table_dof) const
The dof_descriptors_array for the table dof tuple (xis_table_dof true) or row dof tuple defined by th...
const index_space_family & member_id_spaces(bool xauto_access) const
Collection of member id spaces for this (const version).
static poset_path make_row_schema(const namespace_poset &xns, const poset_path &xparent_path, const std::string &xname, const std::string xdof_names[], const primitive_type xdof_types[], size_type xdof_ct, bool xauto_access)
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
STL namespace.
index_space_handle * _row_dof_id_space
The row dof id space for the schema defined by this.
bool is_factor_of(const schema_poset_member &xother) const
True if this represents a factor in the row dofs part of schema xother.
bool is_same_state(const poset_state_handle *xhost, pod_index_type xhub_id) const
True is this is attached to state with hub id xhub_id in host xhost.
An abstract handle to a space of alternate integer identifiers (aliases) for a subset of a hub set of...
virtual pod_index_type get_ext_id(const std::string &xid_space_name) const
Gets an external id corresponding to index() in the id space with name xid_space_name.
std::string row_dof_subposet_name() const
The standard name for the row dof subposet associated with this schema member. Synonym for dof_subpos...
virtual bool is_done() const
True if iteration finished.
virtual void release_id_space() const =0
Returns this id space handle to the handle pool.
virtual void get_read_access() const
Get read access to the state associated with this.
A (lower, upper) bounds pair for a poset. Specifies a portion of a poset for a bounded i/o operation...
Definition: poset_bounds.h:50
index_space_handle * _table_dof_id_space
The table dof id space for the schema defined by 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 invalidate()
Make this id invalid.
Definition: scoped_index.h:852
virtual namespace_poset * name_space() const
The namespace of host()
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.
std::string name() const
A name for this.
The general, abstract map from dof ids to dof values.
Definition: poset_dof_map.h:59
virtual bool is_attached() const =0
True if this handle is attached to a state.
virtual primitive_type type() const
The primitive type index of the dof defined by this.
virtual schema_poset_member & ext_data_type_schema()
The schema for the external data type associated with this schema.
const index_space_handle & table_dof_id_space() const
The table dof id space for the schema defined by this.
bool row_cache_consistent() const
True if cached row properties are consistent with index() and version().
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...
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
virtual int dof_ct() const
The number of dofs in the dof tuple for jims of this poset;.
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...
Abstract base class with useful features for all objects.
Definition: any.h:39
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
bool path_is_available(const poset_path &xpath, bool xauto_access) const
True if the state referred to xpath does not exist or exists and conforms to poset type P...
virtual index_iterator * get_decomposition(pod_index_type xindex) const
An iterator over the members of the decomposition identified by xindex. /.
virtual size_t alignment() const
The alignment for this dof.
pod_index_type get_int_id(pod_index_type xext_id, const std::string &xid_space_name, bool xauto_access) const
Translates xext_id to an internal id using the equivalence map with name xid_space_name.
int row_dof_ct() const
The number of row dofs defined by this schema. Synonym for dof_ct(false).
virtual schema_poset_member & schema()
The schema for this poset (mutable version).
bool has_same_host(const poset_component *xother) const
True if xother is attached to the same host as this or if both are unattached.
dof_descriptor_array * table_dof_descriptors() const
The dof_descriptors_array for the table dof tuple defined by this schema. Synonym for dof_descriptors...
void push_back(const_reference_type item)
Insert item at the end of the items in the auto_block.
bool is_done() const
True if iteration is finished.
scoped_index _row_cache_index
The index with respect to which the cached row properties were evaluated.
virtual void update_row_dof_id_space() const
Update the row dof id space.
bool is_component_of(const schema_poset_member &xother) const
True if this represents a component in the row dofs part of schema xother.
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...
virtual pod_index_type get_ext_id(pod_index_type xint_id, const std::string &xid_space_name, bool xauto_access) const
Translates xint_id to an external id using the equivalence map with name xid_space_name.
primitive_type
Type ids for sheaf primitives.
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
primitive_type type() const
Get type dof. Note: have to use "type" in name in order to avoid name conflict with index() inherited...
size_type _row_dof_ct
The number of row dofs defined by this schema.
A map from schema poset member ids to dof values for primitives_poset members.
pointer_type base() const
The underlying storage array.
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)
virtual void release_iterator(index_space_iterator &xitr) const =0
Returns the id space iterator xitr to the iterator pool.
virtual void detach_from_state()
Detach this handle from its state, if any.
int table_dof_ct() const
The number of table dofs defined by this schema. Synonym for dof_ct(true).
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
static poset_path make_homogeneous_row_schema(const namespace_poset &xns, const poset_path &xparent_path, const std::string &xname, const std::string xdof_names[], const primitive_type xdof_type, size_type xdof_ct, bool xauto_access)
size_type _row_dof_tuple_ub
The size in bytes of the row dof tuple defined by this schema.
virtual bool is_attached() const
True if this handle is attached to a non-void state.
virtual pod_index_type get_int_id(pod_index_type xext_id, const std::string &xid_space_name) const
Gets the internal id corresponding to xext_id in the id space with name xid_space_name.
dof_descriptor_array * _row_dof_descriptors
The dof_descriptors_array for the row dof tuple defined by this schema.
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.
virtual void update_row_cache(bool xupdate_id_space=false) const
Updates cached row properties; if xupdate_id_space, force the update of the row dof id space...
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
std::string poset_name() const
The poset name part of the path.
Definition: poset_path.cc:473
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 contains_path(const poset_path &xpath, bool xauto_access=true) const
True if this contains the poset or poset member specified by xpath.
void new_jim_state(primitive_type xprimitive_type, bool xauto_access=true)
Creates a new jim state in host() with dof map a copy of the primitive type specified by xprimitive_t...
static std::string reserved_prefix()
Prefix for identifying member names reserved by the sheaf system.
Definition: poset_path.cc:883
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. ...
std::string name(pod_index_type xdof_id, bool xis_table_dof) const
The name of the table dof (xis_table_dof true) or row dof referred to by xdof_id in the schema define...
void reserve(size_type xcapacity)
Reserve enough memory for xcapacity number of ids.
bool le(pod_index_type xother_index) const
True if this is less than or equal to the member with index xother_index.
size_t table_dof_tuple_ub() const
The size in bytes of the table dof tuple defined by this schema. Synonym for dof_tuple_ub(true).
SHEAF_DLL_SPEC bool is_primitive_index(pod_index_type xindex)
True if xindex is a valid primitive index.
virtual size_type ct() const =0
The number of members.
int _table_cache_version
The version with respect to which the cached table properties were evaluated.
virtual bool invariant() const
Class invariant.
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.
virtual primitive_type dof_tuple_type(bool xis_table_dof) const
The type of table dofs (xis_table_dof == true) or row dofs (xis_table_dof == false) defined by this s...
virtual void begin_jim_edit_mode(bool xauto_access=true)
Allow editing of jims and jim order relation.
bool ub_is_singleton() const
True if the upper bound contains a single member.
virtual void update_table_dof_descriptors() const
Update the table dof descriptors.
An array for storing structs which describe the size, alignment, and offset of dofs within a dof tupl...
int _row_cache_version
The version with respect to which the cached row properties were evaluated.
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...
size_t alignment() const
Get alignment dof.
virtual bool initialize_table_dof_id_space() const
Initialize table dof id space. Return true, if and only if the table dof id space was created...
virtual pod_type pod(pod_type xid) const =0
The pod index in this space equivalent to xid in the hub id space.
bool initialize_dof_id_space(bool xis_table_dof) const
Initializes the dof id space. If xis_table_dof, otherwise initialize table dof id space...
void force_cache_update()
Forces update of the attribute cache.
virtual size_t ext_data_type_ct(bool xis_table_schema) const
The number of instances of the external data type needed to represent this schema.
virtual index_space_iterator & get_iterator() const =0
Allocates an id space iterator from the iterator pool.
bool contains_poset(pod_index_type xhub_id, bool xauto_access=true) const
True if this contains a poset with hub id xhub_id..
index_iterator * bound_iterator(const poset_bounds &xbnd_id, bool xis_ub) const
An iterator for the upper bound (xis_ub == true) or the lower bound (xis_ub == false) for xbounds...
const hub_index_space_handle & member_hub_id_space(bool xauto_access) const
The member hub id space.
virtual const scoped_index & index()
The index of the current member of the iteration.
size_type _table_dof_ct
The number of table dofs defined by this schema.
virtual bool is_atom() const
True if this member covers the bottom.
Iterates over the subset of Zn defined by the characteristic function host().
friend SHEAF_DLL_SPEC size_t deep_size(const schema_poset_member &xp, bool xinclude_shallow)
The deep size of the referenced object of type schema_poset_member.
subposet_state * dof_subposet_state(bool xis_table_dof)
The subposet_state for the table/row dof subposet.
const scattered_insertion_index_space_handle & id_space() const
The id space for the members of with this (const version).
Definition: subposet.cc:508
static void make_schema_no_jims(namespace_poset *xns, const std::string &xposet_name, const std::string &xmember_name, const std::string &xparent_name)
static const poset_path & standard_schema_path()
The path to the standard schema for this class.
virtual void detach_from_state()
Detach this handle from its state, if any.
pod_type hub_pod(pod_type xid) const
The pod index in the unglued hub id space equivalent to xid in this id space; synonym for unglued_hub...
bool ge(pod_index_type xother_index) const
True if this is greater than or equal to the member with index xother_index.
virtual bool initialize_row_dof_id_space() const
Initialize row dof id space. Return true, if and only if the row dof id space was created...
void remove_reference()
Remove a reference from this.
virtual void update_table_dof_id_space() const
Update the table dof id space.
virtual void update_table_cache() const
Updates cached table properties.
bool is_table_dof() const
True if this is in the table_dofs part of some schema. Synonym for is_dof(true).
size_t row_dof_tuple_ub() const
The size in bytes of the row dof tuple defined by this schema. Synonym for dof_tuple_ub(false).
virtual bool is_schematized(bool xauto_access) const
True if this poset has been prepared for use as a schema, that is, if the top member has been schemat...
bool invariant_check() const
True if invariant checking is enabled.
Definition: any.h:79
Iterates in postorder over dofs of a schema member anchor. Attaches a handle of type schema_poset_mem...
size_t dof_tuple_ub(bool xis_table_dof) const
The size in bytes of the table dof tuple (xis_table_dof true) or the row dof tuple defined by this sc...
static poset_path make_schema(const namespace_poset &xns, const poset_path &xparent_path, const std::string &xname)
Creates a schema member with name xname which is join-equivalent the schema with path xparent_path...
bool contains_dof(const schema_poset_member &xother, bool xin_table_dofs) const
True if xother is a dof in the table dofs part (xin_table_dofs == true) or in the row dofs part (xin_...
virtual void attach_handle_data_members()
Initializes _table_dof_subset_index and _row_dof_subposet_index;.
virtual void get_ext_ids(const std::string &xid_space_name, pod_index_type &xschema_poset_ext_id, pod_index_type &xschema_member_ext_id, pod_index_type &xbase_space_ext_id, pod_index_type &xfiber_schema_ext_id, pod_index_type &xlocal_schema_ext_id) const
Gets the external ids of this in the id space with name xid_space_name.
virtual poset_dof_iterator * dof_iterator(bool xis_table_dofs, int xversion=CURRENT_MEMBER_VERSION) const
A postorder iterator over the table (xis_table_dofs == true) or row (xis_table_dofs == false) dofs de...
void update_dof_id_space(bool xis_table_dof) const
Update the ids in the dof id space. If xis_table_dof, otherwise initialize table dof id space...
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
std::string member_name() const
The member name part of the path.
Definition: poset_path.cc:511
virtual primitives_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) ...
void add_reference()
Add a reference to this.
primitive_type id() const
The id for the primitive type associated with this.
size_t align(const size_t xoffset, const size_t xalignment)
Smallest offset greater than or equal to xoffset that has alignment xalignment.
A handle for a scattered_insertion_index_space_state.
const scoped_index & row_dof_subposet_index() const
The index in host() of the subposet containing the the row dofs in the down set of this (const versio...
bool contains(pod_type xid) const
True, if this contains an id space with id xid.
dof_descriptor_array * _table_dof_descriptors
The dof_descriptors_array for the table dof tuple defined by this schema.
static array_index_space_handle new_space(index_space_family &xid_spaces, const std::string &xname, bool xis_persistent, size_type xcapacity)
Create a new array id space in the id space family xid_spaces at the next available id space index wi...
size_type _table_dof_tuple_ub
The size in bytes of the table dof tuple defined by this schema.
static std::string dof_subposet_name(const std::string &xname, bool xis_table_dof)
The standard name for the table (xis_table_dof true) or row (xis_table_dof false) dof subposet associ...
void push_back(const scoped_index &xhub_id)
Make the next id in this space equivalent to xhub_id in the hub id space. synonym for push_back(xhub_...
pod_index_type lb_id() const
The index of the lower bound member, if the lower bound contains a single member. ...
virtual void end_jim_edit_mode(bool xensure_lattice_invariant=true, bool xauto_access=true)
Prevent editing of jims and jim order relation.
dof_descriptor_array * row_dof_descriptors() const
The dof_descriptors_array for the row dof tuple defined by this schema. Synonym for dof_descriptors(f...
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.
scoped_index _row_dof_subposet_index
The index within host of the row dofs subposet associated with this.
virtual void get_read_access() const
Get read access to the state associated with this.
virtual size_type offset(pod_index_type xdof_id, bool xis_table_dof) const
The offset for the table dof (xis_table_dof true) or row dof referred to by xdof_id in the schema def...
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 pod_index_type subposet_id(const std::string &xname) const
The hub id of the subposet with name xname.
scoped_index _table_dof_subposet_index
The index within host of the table dofs subposet associated with this.
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...
bool in_jim_edit_mode() const
True if editing jims and jim order relation is allowed.
const scoped_index & dof_subposet_index(bool xis_table_dof) const
The index in host() of the subposet containing the the table dofs (xis_table_dof true) or row dofs in...
virtual void update_row_dof_descriptors() const
Update the row dof descriptors.
virtual schema_poset_member & schema()
The schema for this member (mutable version).
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
SHEAF_DLL_SPEC pod_index_type invalid_pod_index()
The invalid pod index value.
Definition: pod_types.cc:31
void enable_invariant_check() const
Enable invariant checking.
Definition: any.h:87
bool is_factor() const
True if this represents a factor in the row dofs part of some schema.
static void make_row_dofs_schema(namespace_poset *xns, const std::string member_names[], const int num_members, const int member_dof_type, const std::string &schema_poset_name, const std::string &schema_member_name, const std::string &schema_inherits_name)
std::string table_dof_subposet_name() const
The standard name for the table dof subposet associated with this schema member. Synonym for dof_subp...
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...
bool state_is_not_read_accessible() const
True if this is attached and if the state is accessible for read or if access control is disabled...
A client handle for a poset member which has been prepared for use as a schema.
virtual bool is_dof(bool xin_table_dofs) const
True if this is in the table dofs part (xin_table_dofs == true) or in the row dofs part (xin_table_do...
virtual schema_poset_member & operator=(const abstract_poset_member &xother)
Assignment operator; attaches this to the same state as xother.
scoped_index _table_cache_index
The index with respect to which the cached table properties were evaluated.
Whitespace-separated-value block; A block of objects of type T that can be conveniently initialized b...
Definition: tuple.h:62
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...
schema_poset_member()
Default constructor; creates a new, unattached schema_poset_member handle.
bool dof_tuple_is_homogeneous(bool xis_table_dof) const
True if all the table dofs (xis_table_dof == true) or all the row dofs (xis_table_dof == false) defin...
virtual void new_jrm_state(bool xauto_access=true)
Creates a new jrm (join-reducible member) state in host() and attaches this to it.
void update_dof_descriptors(bool xis_table_dof, dof_descriptor_array *&xdof_descriptors, size_type xdof_ct, size_type &xdof_tuple_ub) const
Update the dof descriptors. If xis_table_dof, otherwise initialize table dof id space. Otherwise, initialize the row dof id space.
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...
bool is_row_dof() const
True if this is in in the row_dofs part of some schema. Synonym for is_dof(false).
bool has_version(int xversion) const
True if xversion is a valid version for this.
void force(int i, bool value)
Sets the i-th member to value, extends the upper bound if necessary.
Definition: zn_to_bool.cc:607
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