SheafSystem  0.0.0.0
poset_scaffold.cc
Go to the documentation of this file.
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
20 
21 #include "SheafSystem/subposet.h"
22 #include "SheafSystem/poset_scaffold.h"
23 #include "SheafSystem/assert_contract.h"
24 #include "SheafSystem/data_converter.h"
25 #include "SheafSystem/error_message.h"
26 #include "SheafSystem/index_space_iterator.h"
27 #include "SheafSystem/interval_index_space_state.h"
28 #include "SheafSystem/namespace_poset.h"
29 #include "SheafSystem/namespace_relative_member_index.h"
30 #include "SheafSystem/namespace_relative_subposet_index.h"
31 #include "SheafSystem/poset.h"
32 #include "SheafSystem/poset_bounds.h"
33 #include "SheafSystem/primitive_type.h"
34 #include "SheafSystem/std_cstdlib.h"
35 #include "SheafSystem/std_sstream.h"
36 #include "SheafSystem/storage_agent.h"
37 
38 using namespace std;
39 
40 //#define DIAGNOSTIC_OUTPUT
41 //#undef DIAGNOSTIC_OUTPUT
42 
43 // ===========================================================
44 // POSET_SCAFFOLD FACET
45 // ===========================================================
46 
47 // PUBLIC MEMBER FUNCTIONS
48 
51  : _structure(xother._structure),
52  _row_bounds(xother._row_bounds),
53  _col_bounds(xother._col_bounds),
54  _toc_bounds(xother._toc_bounds),
55  _type_map(xother._type_map),
56  _external_schema(xother._external_schema),
57  _member_id_space(xother._member_id_space),
58  _subposet_id_space(xother._subposet_id_space),
59  _dof_tuple_id_space(xother._dof_tuple_id_space),
60  _subposets(xother._subposets)
61 {
62 
63  // Preconditions:
64 
65  // Body:
66 
67  not_implemented();
68 
69  // Postconditions:
70 
71  ensure(invariant());
72 }
73 
76 {
77  // Preconditions:
78 
79  // Body:
80 
81  // Delete the bounds objects.
82 
83  delete _row_bounds;
84  delete _col_bounds;
85  delete _toc_bounds;
86 
87  // Detach the resident subposet.
88 
89  _resident.detach_from_state();
90 
91  // Detach and delete the schema handles.
92 
93  _internal_schema->detach_from_state();
94  delete _internal_schema;
95 
96  _transfer_schema->detach_from_state();
97  delete _transfer_schema;
98 
99  _external_schema->detach_from_state();
100  delete _external_schema;
101 
102  // Delete all the subposet handles.
103 
104  vector<subposet*>::iterator itr = _subposets.begin();
105  while(itr != _subposets.end())
106  {
107  subposet* sp = *itr;
108  if(sp != 0)
109  {
110  sp->detach_from_state();
111  delete sp;
112  }
113  itr++;
114  }
115 
116  // Release id space handles.
117 
118  for(int i = 0; i < _id_spaces.ub(); i++)
119  {
120  if(_id_spaces[i] != 0)
121  {
122  _id_spaces[i]->release_id_space();
123  }
124  }
125 
126  // Postconditions:
127 
128  // Exit:
129 
130  return;
131 }
132 
135  const storage_agent::transaction& xtrans,
136  data_type_map& xtype_map,
137  const std::string& xfile_id_space_name,
138  bool xis_write_transaction)
139  : _structure(const_cast<poset_state_handle&>(xposet)),
140  _type_map(xtype_map),
141  _file_id_space_name(xfile_id_space_name)
142 {
143  // Preconditions:
144 
145  require(xis_write_transaction ? !xposet.is_external() : true);
146  require(!xposet.is_external() ? xposet.state_is_read_accessible() : true);
147 
148  // Body:
149 
150  _is_write_transaction = xis_write_transaction;
151 
152  _row_bounds = new poset_bounds(xtrans.row_bounds);
153  _col_bounds = new poset_bounds(xtrans.col_bounds);
155 
156 
157  if(xis_write_transaction)
158  {
159  // Initialize the member index space.
160 
162 
163  // Initialize the schema
164 
165  initialize_schema_for_write();
166 
167  // Initialize the dof tuple index space.
168 
170 
171  // Initialize the subposet index space.
172 
174 
175  // Initialize the subposet handle buffer.
176 
177  initialize_subposets();
178  }
179  else
180  {
181  // Read transaction:
182  //
183  // Can't initialize index spaces until we've created the poset;
184  //
185  // see id_space_names_record::transfer_internal_buffer_to_poset() for
186  // member index space initialization.
187  //
188  // see subposet_names_record::transfer_internal_buffer_to_poset() for
189  // subposet index space initialization.
190  //
191  // set member_record::internalize() for dof tuple index space initialization.
192  }
193 
194  _is_versioned = false; // set on read in poset_general_record.
195 
196  // Postconditions:
197 
198  ensure(invariant());
199  ensure(!resident().is_attached());
200 
201  // Exit
202 
203  return;
204 }
205 
209 {
210  return _structure;
211 }
212 
215 structure() const
216 {
217  return _structure;
218 }
219 
223 {
224  return _structure.powerset();
225 }
226 
229 powerset() const
230 {
231  return _structure.powerset();
232 }
233 
237 {
238  return _structure.table();
239 }
240 
243 table() const
244 {
245  return _structure.table();
246 }
247 
248 bool
251 {
252  return _is_write_transaction;
253 }
254 
258 {
259  return *_row_bounds;
260 }
261 
262 const sheaf::poset_bounds&
264 row_bounds() const
265 {
266  return *_row_bounds;
267 }
268 
272 {
273  return *_col_bounds;
274 }
275 
276 const sheaf::poset_bounds&
278 col_bounds() const
279 {
280  return *_col_bounds;
281 }
282 
283 const sheaf::poset_bounds&
285 toc_bounds() const
286 {
287  return *_toc_bounds;
288 }
289 
290 void
293 {
294  // Preconditions:
295 
296  // Body:
297 
298  delete _toc_bounds;
299  _toc_bounds = new poset_bounds(xdesc);
300 
301  // Postconditions:
302 
303  // Exit
304 
305  return;
306 }
307 
308 void
311 {
312  // Preconditions:
313 
314  // Body:
315 
316  if(_row_bounds->lb_id() == TOC_INDEX)
317  {
318  // Replace row bounds with toc bounds
319 
320  delete _row_bounds;
321  _row_bounds = _toc_bounds->clone();
322  }
323 
324  // Postconditions:
325 
326  // Exit
327 
328  return;
329 }
330 
334 {
335  return _resident;
336 }
337 
338 const sheaf::subposet&
340 resident() const
341 {
342  return _resident;
343 }
344 
347 name_space() const
348 {
349  namespace_poset* result;
350 
351  // Preconditions:
352 
353  // Body:
354 
355  result = dynamic_cast<namespace_poset*>(&_structure);
356  if(result == 0)
357  {
358  result = _structure.name_space();
359  }
360 
361  // Postconditions:
362 
363  ensure(structure_is_namespace() ? result == &(structure()) : result == structure().name_space());
364 
365  // Exit
366 
367  return result;
368 }
369 
370 bool
373 {
374  bool result;
375 
376  // Preconditions:
377 
378  // Body:
379 
380  result = dynamic_cast<namespace_poset*>(&_structure) != 0;
381 
382  // Postconditions:
383 
384  // Exit
385 
386  return result;
387 }
388 
391 index() const
392 {
393  return _structure.index();
394 }
395 
396 std::string
398 name() const
399 {
400  return _structure.name();
401 }
402 
406 {
407  return *_internal_schema;
408 }
409 
413 {
414  return *_internal_schema;
415 }
416 
420 {
421  return *_transfer_schema;
422 }
423 
427 {
428  return *_transfer_schema;
429 }
430 
434 {
435  return *_external_schema;
436 }
437 
441 {
442  return *_external_schema;
443 }
444 
448 {
449  return _type_map;
450 }
451 
454 type_map() const
455 {
456  return _type_map;
457 }
458 
459 const std::string&
462 {
463  return _file_id_space_name;
464 }
465 
466 bool&
469 {
470  return _is_versioned;
471 }
472 
473 const bool&
476 {
477  return _is_versioned;
478 }
479 
480 void
483  int xschema_version)
484 {
485  // Preconditions:
486 
487  require(xext_schema != 0);
488  require(xext_schema->is_attached());
489 
490  // Body:
491 
492  if(col_bounds().ub_is_singleton() &&
493  col_bounds().ub_id() == TOP_INDEX)
494  {
495  // Adjust the upper bounds.
496  // For a read operation, the upper bound can not be greater than
497  // the external schema, so the only consistent interpretation is
498  // upper bounds == top means use external schema as upper bound.
499 
500  col_bounds().put_ub_id(xext_schema->index());
501  }
502 
503  // Create the schema handles.
504  // Ensure right type by cloning top member of poset.
505 
506  _external_schema = xext_schema;
507  _internal_schema = _external_schema->clone();
508  _transfer_schema = _external_schema->clone();
509 
510 
511  // Initialize the internal schema.
512 
513  if(structure().is_external())
514  {
515  // Internal poset doesn't have a schema yet;
516 
517  if(col_bounds().ub_is_singleton())
518  {
519  // Upper bound is a single member; use the member specified in the bounds.
520  // Internal schema has to be in the same poset as external schema.
521 
522  _internal_schema->attach_to_state(_external_schema->host(),
523  col_bounds().ub_id());
524  }
525  else
526  {
527  // Upper bound is a subposet; internal schema is join of members.
528 
530  {
531  // Join of members equals external schema.
532 
533  _internal_schema->attach_to_state(_external_schema);
534  }
535  else
536  {
537  // Must compute join of upper bound.
538 
539  post_fatal_error_message("non-decomposition upper bound not implemented");
540  }
541  }
542  }
543  else
544  {
545  // Internal poset already has a schema; use it.
546 
547  _internal_schema->attach_to_state(&(structure().schema()));
548  }
549 
550  // Temporarily attach transfer schema to external schema.
551  // Sets host, proper member will be set in poset_scaffold::read_records.
552 
553  _transfer_schema->attach_to_state(_external_schema);
554 
555  // Set the schema version; all use the same version.
556 
557  _external_schema->put_version(xschema_version);
558  _internal_schema->put_version(xschema_version);
559  _transfer_schema->put_version(xschema_version);
560 
561  // Postconditions:
562 
563  ensure(external_schema().is_attached());
564  ensure(internal_schema().is_attached());
565  ensure(transfer_schema().is_attached());
566 
567  // Exit
568 
569  return;
570 }
571 
572 void
575 {
576  // Preconditions:
577 
578  // Postconditions:
579 
580  not_implemented();
581 
582  // Exit
583 
584  return;
585 }
586 
587 void
589 insert_id_name_pair(pod_index_type xid, const std::string& xname, block<char>& xbuf)
590 {
591  // Preconditions:
592 
593  // Body:
594 
595  // Convert the member id to a string
596 
597  stringstream lmbr_id_stream;
598  lmbr_id_stream << xid;
599  string lmbr_id_str(lmbr_id_stream.str());
600 
601  // Put the member id string in the buffer.
602 
603  for(int i=0; i<lmbr_id_str.size(); i++)
604  {
605  xbuf.push_back(lmbr_id_str[i]);
606  }
607 
608  // Terminate the string in the buffer.
609 
610  xbuf.push_back('\0');
611 
612  // Put the name into the buffer.
613 
614  for(int i=0; i<xname.size(); i++)
615  {
616  // Nothing prevents a client from padding a
617  // C++ string with nulls using << ends. But
618  // such nulls will be interprettd as 0-length strings
619  // in the file. So make sure we don't put any in the file
620  // considering first null as end of string.
621 
622  char lchr = xname[i];
623  if(lchr == '\0')
624  break;
625 
626  xbuf.push_back(lchr);
627  }
628 
629  // Terminate the string in the buffer.
630 
631  xbuf.push_back('\0');
632 
633  // Postconditions:
634 
635  // Exit:
636 
637  return;
638 }
639 
640 void
642 extract_id_name_pair(pod_index_type& xid, std::string& xname, char*& xbuf)
643 {
644  // Preconditions:
645 
646  // Body:
647 
648  // Extract the id.
649 
650  xid = atoi(xbuf);
651 
652  // Advance xbuf past the member id to
653  // the beginning of the name.
654 
655  xbuf += strlen(xbuf) + 1;
656 
657  // Extract the name
658 
659  xname = xbuf;
660 
661  // Advance xbuf to the next entry.
662 
663  xbuf += strlen(xbuf) + 1;
664 
665  // Postconditions:
666 
667  // Exit:
668 
669  return;
670 }
671 
672 void
675 {
676  // cout << endl << "Entering poset_scaffold::get_member_names_from_poset." << endl;
677 
678  // Preconditions:
679 
680 
681  // Body:
682 
683  _member_name_map.clear();
684  _member_name_map = _structure.member_name_map();
685 
686  // Postconditions:
687 
688  ensure(member_name_map() == structure().member_name_map());
689 
690  // Exit:
691 
692  // cout << "Leaving poset_scaffold::get_member_names_from_poset." << endl;
693  return;
694 }
695 
696 void
699 {
700  // cout << endl << "Entering poset_scaffold::get_member_names_from_poset." << endl;
701 
702  // Preconditions:
703 
704  require(structure().state_is_read_write_accessible());
705 
706  // Body:
707 
708  _structure.member_name_map().clear();
709  _structure.member_name_map() = _member_name_map;
710 
712  while(itr != _structure.member_name_map().end())
713  {
714  pod_index_type lpod = itr->first;
715  ++itr;
716 
717  if(!_structure.contains_member(lpod, false))
718  {
719  _structure.member_name_map().delete_index(lpod);
720  }
721  }
722 
723  // Postconditions:
724 
725  // Exit:
726 
727  // cout << "Leaving poset_scaffold::get_member_names_from_poset." << endl;
728  return;
729 }
730 
731 
732 // PROTECTED MEMBER FUNCTIONS
733 
734 // PRIVATE MEMBER FUNCTIONS
735 
736 void
737 sheaf::poset_scaffold::
738 initialize_schema_for_write()
739 {
740  // Preconditions:
741 
748 
749  // Body:
750 
751  // Get a handle to the schema poset.
752 
753  poset_state_handle* lschema_poset = structure().schema().host();
754 
755  if(col_bounds().ub_is_singleton() &&
756  col_bounds().ub_id() == TOP_INDEX)
757  {
758  // Adjust the upper bounds. For a write operation,
759  // the upper bound can not be greater than the internal schema,
760  // so the only consistent interpretation is
761  // upper bounds == top means use internal schema as upper bound.
762 
763  col_bounds().put_ub_id(structure().schema().index());
764  }
765 
766  // Create the schema handles.
767  // Ensure right type by cloning schema of structure().
768 
769  _external_schema = structure().schema().clone();
770  _transfer_schema = _external_schema->clone();
771  _internal_schema = _external_schema->clone();
772 
773  // Initialize internal schema to the schema of the internal poset.
774 
775  _internal_schema->attach_to_state(&(structure().schema()));
776 
777  // Initialize the external schema.
778  // (Currently update is not supported, only write with clobber.)
779 
780  if(col_bounds().ub_is_singleton())
781  {
782  // Upper bound is a single member.
783 
784  if(col_bounds().ub_id() == TOP_INDEX)
785  {
786  // ub_id == top means use internal schema.
787 
788  _external_schema->attach_to_state(_internal_schema);
789  }
790  else
791  {
792  // Use the member specified in the bounds.
793 
794  _external_schema->attach_to_state(_internal_schema->host(),
795  col_bounds().ub_id());
796  }
797  }
798  else
799  {
800  // Upper bound is a subposet; in principle the external schema
801  // is the join of the meets of the internal schema with each member.
802 
804  {
805  // The join of the ub members is the host schema;
806  // join of meets of internal schema with members equals internal schema.
807 
808  _external_schema->attach_to_state(_internal_schema);
809  }
810  else
811  {
812  // Must compute join of upper bound; but we don't support that yet.
813 
814  post_fatal_error_message("non-decomposition upper bound not implemented");
815  }
816  }
817 
818  // Temporarily initialize the transfer schema to the external schema.
819  // Sets the host, proper member will be set in ???.
820 
821  _transfer_schema->attach_to_state(_external_schema);
822 
823  // Set the schema version
824 
825  int lver = structure().schema().version();
826  _external_schema->put_version(lver);
827  _transfer_schema->put_version(lver);
828  _internal_schema->put_version(lver);
829 
830  // Postconditions:
831 
832  ensure(internal_schema().is_attached());
833  ensure(external_schema().is_attached());
834  ensure(transfer_schema().is_attached());
835 
836  // Exit
837 
838  return;
839 }
840 
841 
842 // ===========================================================
843 // MEMBER FACET
844 // ===========================================================
845 
846 // PUBLIC MEMBER FUNCTIONS
847 
848 void
851  int xdof_tuple_id_index,
852  int xoffset_index)
853 {
854 
855  // Preconditions:
856 
857  require(is_primitive_index(xtoc_index));
858  require(is_primitive_index(xdof_tuple_id_index));
859  require(is_primitive_index(xoffset_index));
860 
861  // Body:
862 
863  type_map().put_member_record_type_aliases(xtoc_index, xdof_tuple_id_index, xoffset_index);
864 
865  // Postconditions:
866 
867  ensure(invariant());
868 }
869 
870 void
873 {
874  // Preconditions:
875 
876  require(structure().state_is_read_accessible());
877 
878  // Body:
879 
880  // Space is created in initialize_poset_index_spaces_for_write() during write.
881  // But it is not persistent and must be recreated on read.
882  // It persists between partial reads or writes, so if it exists, we don't
883  // want to clear it, or otherwise change it.
884 
885  if(!_structure.member_id_spaces(false).contains(_file_id_space_name))
886  {
888  _file_id_space_name, false, false);
889  }
890 
891  _member_id_space.attach_to(_structure.member_id_spaces(false),
892  _file_id_space_name);
893 
894  // Postconditions:
895 
896  ensure(member_id_space_initialized());
897 
898  // Exit:
899 
900  return;
901 }
902 
903 bool
906 {
907  bool result;
908 
909  // Preconditions:
910 
911  // Body:
912 
913  result = _member_id_space.is_attached();
914 
915  // Postconditions:
916 
917  // Exit:
918 
919  return result;
920 }
921 
924 member_ext_id(const scoped_index& xid) const
925 {
926  // Preconditions:
927 
928  require(member_id_space_initialized());
929 
930  // Body:
931 
932  scoped_index result(_member_id_space, xid);
933 
934  // Postconditions:
935 
936  // Exit:
937 
938  return result;
939 }
940 
944 {
945  // Preconditions:
946 
947  require(member_id_space_initialized());
948 
949  // Body:
950 
951  scoped_index result(_member_id_space, xid);
952 
953  // Postconditions:
954 
955  // Exit:
956 
957  return result;
958 }
959 
963 {
964  // Preconditions:
965 
966  require(member_id_space_initialized());
967 
968  // Body:
969 
970  member_index_space_type& result = _member_id_space;
971 
972  // Postconditions:
973 
974  ensure(result.is_attached());
975 
976  // Exit:
977 
978  return result;
979 }
980 
984 {
985  // Preconditions:
986 
987  require(member_id_space_initialized());
988 
989  // Body:
990 
991  const member_index_space_type& result = _member_id_space;
992 
993  // Postconditions:
994 
995  ensure(result.is_attached());
996 
997  // Exit:
998 
999  return result;
1000 }
1001 
1005 {
1006  return _member_name_map;
1007 }
1008 
1012 {
1013  return _member_name_map;
1014 }
1015 
1019 {
1020  return _member_class_names;
1021 }
1022 
1026 {
1027  return _member_class_names;
1028 }
1029 
1030 void
1033 {
1034  // Preconditions:
1035 
1036  require(name_space() != 0);
1037  require(name_space()->state_is_read_accessible());
1038 
1039  // Body:
1040 
1041  // Some covenient typedefs.
1042 
1043  typedef namespace_relative_member_index nrmi_type;
1044  typedef namespace_relative_record_index nrri_type;
1045 
1046  // Convert dof from pod type to index type.
1047 
1048  nrmi_type lmbr_id(_structure.member_hub_id_space(false),
1049  *reinterpret_cast<nrmi_type::pod_type*>(xbuf));
1050 
1051  // Convert member index to record index.
1052 
1053  nrri_type lrec_id;
1054 
1055  assertion(!lrec_id.is_valid());
1056 
1057  if(name_space()->contains_poset(lmbr_id.poset_id, false))
1058  {
1059  lrec_id.poset_id =
1060  name_space()->get_ext_id(lmbr_id.poset_id, _file_id_space_name, false);
1061 
1062  poset_state_handle& lposet = name_space()->member_poset(lmbr_id.poset_id, false);
1063  if(lposet.contains_member(lmbr_id.member_id))
1064  {
1065  lrec_id.member_id =
1066  lposet.get_ext_id(lmbr_id.member_id, _file_id_space_name, true);
1067  }
1068  }
1069 
1070  // Convert record index back to pod type.
1071 
1072  *reinterpret_cast<nrri_type::pod_type*>(xbuf) = lrec_id.pod();
1073 
1074  // Postconditions:
1075 
1076  // Exit
1077 
1078  return;
1079 }
1080 
1081 void
1084 {
1085  // Preconditions:
1086 
1087  require(name_space()->state_is_read_accessible());
1088  require(name_space()->member_id_spaces(false).contains(file_id_space_name()));
1089 
1090  // Body:
1091 
1092  // Some covenient typedefs.
1093 
1094  typedef namespace_relative_member_index nrmi_type;
1095  typedef namespace_relative_record_index nrri_type;
1096 
1097  // Convert dof from pod type to index type.
1098 
1099  nrri_type::pod_type* lrec_id = reinterpret_cast<nrri_type::pod_type*>(xbuf);
1100 
1101  // Conver record index to member index.
1102 
1103  nrmi_type lint_id;
1104 
1105  if(is_valid(lrec_id->poset_id))
1106  {
1107  lint_id.poset_id =
1108  name_space()->get_int_id(lrec_id->poset_id, _file_id_space_name, false);
1109 
1110  if(is_valid(lrec_id->member_id))
1111  {
1112  poset_state_handle& lposet =
1113  name_space()->member_poset(lint_id.poset_id, false);
1114  lint_id.member_id =
1115  lposet.get_int_id(lrec_id->member_id, _file_id_space_name, true);
1116  }
1117  }
1118 
1119  // Convert member index back to pod type.
1120 
1121  *reinterpret_cast<nrmi_type::pod_type*>(xbuf) = lint_id.pod();
1122 
1123  // Postconditions:
1124 
1125  // Exit
1126 
1127  return;
1128 }
1129 
1130 // PROTECTED MEMBER FUNCTIONS
1131 
1132 // PRIVATE MEMBER FUNCTIONS
1133 
1134 
1135 // ===========================================================
1136 // SUBPOSET FACET
1137 // ===========================================================
1138 
1139 // PUBLIC MEMBER FUNCTIONS
1140 
1141 void
1144 {
1145  // Preconditions:
1146 
1147  require(structure().state_is_read_accessible());
1148 
1149  // Body:
1150 
1151  // Space is created in initialize_poset_index_spaces_for_write() during write.
1152  // But it is not persistent and must be recreated on read.
1153  // It does not persist between partial reads or writes, so if it exists,
1154  // we want to clear it.
1155 
1156  if(!_structure.subposet_id_spaces(false).contains(_file_id_space_name))
1157  {
1159  _file_id_space_name, false, false);
1160  }
1161 
1162  _subposet_id_space.attach_to(_structure.subposet_id_spaces(false),
1163  _file_id_space_name);
1164  _subposet_id_space.clear();
1165 
1166  // Postconditions:
1167 
1169  ensure(subposet_id_space().is_empty());
1170 
1171  // Exit:
1172 
1173  return;
1174 }
1175 
1176 bool
1179 {
1180  bool result;
1181 
1182  // Preconditions:
1183 
1184  // Body:
1185 
1186  result = _subposet_id_space.is_attached();
1187 
1188  // Postconditions:
1189 
1190  // Exit:
1191 
1192  return result;
1193 }
1194 
1198 {
1199  // Preconditions:
1200 
1201  require(subposet_id_space_initialized());
1202 
1203  // Body:
1204 
1205  scoped_index result(_subposet_id_space, xid);
1206 
1207  // Postconditions:
1208 
1209  // Exit:
1210 
1211  return result;
1212 }
1213 
1217 {
1218  // Preconditions:
1219 
1220  require(subposet_id_space_initialized());
1221 
1222  // Body:
1223 
1224  scoped_index result(_subposet_id_space, xid);
1225 
1226  // Postconditions:
1227 
1228  // Exit:
1229 
1230  return result;
1231 }
1232 
1236 {
1237  // Preconditions:
1238 
1239  require(subposet_id_space_initialized());
1240 
1241  // Body:
1242 
1243  subposet_index_space_type& result = _subposet_id_space;
1244 
1245  // Postconditions:
1246 
1247  ensure(result.is_attached());
1248 
1249  // Exit:
1250 
1251  return result;
1252 }
1253 
1257 {
1258  // Preconditions:
1259 
1260  require(subposet_id_space_initialized());
1261 
1262  // Body:
1263 
1264  const subposet_index_space_type& result = _subposet_id_space;
1265 
1266  // Postconditions:
1267 
1268  ensure(result.is_attached());
1269 
1270  // Exit:
1271 
1272  return result;
1273 }
1274 
1275 std::vector<sheaf::subposet*>&
1278 {
1279  return _subposets;
1280 }
1281 
1282 const std::vector<sheaf::subposet*>&
1284 subposets() const
1285 {
1286  return _subposets;
1287 }
1288 
1289 void
1292 {
1293  // Preconditions:
1294 
1295  require(name_space()->state_is_read_accessible());
1296  require(name_space()->member_id_spaces(false).contains(file_id_space_name()));
1297 
1298  // Body:
1299 
1300  // Some convenient typedefs.
1301 
1302  typedef namespace_relative_subposet_index nrsi_type;
1303  typedef namespace_relative_record_index nrri_type;
1304 
1305  // Convert pod type to subposet index.
1306 
1307  nrsi_type lsp_id(_structure.member_hub_id_space(false),
1308  *reinterpret_cast<nrsi_type::pod_type*>(xbuf));
1309 
1310  // Convert subposet index to record index.
1311 
1313 
1314  lrec_id.poset_id =
1315  name_space()->get_ext_id(lsp_id.poset_id, _file_id_space_name, false);
1316 
1317  poset_state_handle& lposet = name_space()->member_poset(lsp_id.poset_id, false);
1318  if(lposet.includes_subposet(lsp_id.subposet_id))
1319  {
1320  lrec_id.member_id = subposet_ext_id(lsp_id.subposet_id);
1321  }
1322 
1323  // Convert record index back to pod type.
1324 
1325  *reinterpret_cast<nrri_type::pod_type*>(xbuf) = lrec_id.pod();
1326 
1327  // Postconditions:
1328 
1329  // Exit
1330 
1331  return;
1332 }
1333 
1334 void
1337 {
1338  // Preconditions:
1339 
1340  // Body:
1341 
1342  // Some convenient typedefs.
1343 
1344  typedef namespace_relative_subposet_index nrsi_type;
1345  typedef namespace_relative_record_index nrri_type;
1346 
1347  // Convert pod type to record index.
1348 
1349  nrri_type::pod_type* lrec_id = reinterpret_cast<nrri_type::pod_type*>(xbuf);
1350 
1351  // Convert record index to subposet index.
1352 
1353  nrsi_type lint_id;
1354 
1355  if(is_valid(lrec_id->poset_id))
1356  {
1357  lint_id.poset_id =
1358  name_space()->get_int_id(lrec_id->poset_id, _file_id_space_name, false);
1359 
1360  if(is_valid(lrec_id->member_id))
1361  {
1362  poset_powerset_state& lpowerset =
1363  name_space()->member_poset(lint_id.poset_id, false).powerset();
1364  lint_id.subposet_id =
1365  lpowerset.hub_id(_subposet_id_space.hub_pod(lrec_id->member_id));
1366  }
1367  }
1368 
1369  // Convert subposet index back to pod type.
1370 
1371  *reinterpret_cast<nrsi_type::pod_type*>(xbuf) = lint_id.pod();
1372 
1373  // Postconditions:
1374 
1375  // Exit
1376 
1377  return;
1378 }
1379 
1380 // PROTECTED MEMBER FUNCTIONS
1381 
1382 // PRIVATE MEMBER FUNCTIONS
1383 
1384 void
1385 sheaf::poset_scaffold::
1386 initialize_subposets()
1387 {
1388  // Preconditions:
1389 
1390  require(subposet_id_space_initialized());
1391 
1392  // Body:
1393 
1394  const poset_state_handle& lposet = structure();
1395 
1396  // Initialize iteration.
1397 
1398  _subposets.reserve(lposet.subposet_ct());
1399 
1401  subposet lsp;
1402 
1403  while(!itr.is_done())
1404  {
1405  pod_index_type lid = itr.hub_pod();
1406 
1407  lsp.attach_to_state(&lposet, lid);
1408 
1409  if(lsp.is_persistent())
1410  {
1411  // This subposet is a persistent subposet; we'll have to write it out.
1412 
1413  // Assign a sequential external index. Note that this preserves the
1414  // indexing for the standard subposets, as long as they are sequentially
1415  // indexed internally, starting at 0.
1416 
1417  _subposet_id_space.push_back(lid);
1418 
1419  // Create a handle and save it in the buffer.
1420 
1421  _subposets.push_back(new subposet(&lposet, lid));
1422  }
1423  itr.next();
1424  }
1425 
1427 
1428  lsp.detach_from_state();
1429 
1430  // Postconditions:
1431 
1432  // Exit
1433 
1434  return;
1435 }
1436 
1437 
1438 // ===========================================================
1439 // DOF_TUPLE FACET
1440 // ===========================================================
1441 
1442 // PUBLIC MEMBER FUNCTIONS
1443 
1444 void
1447 {
1448  // Preconditions:
1449 
1450  require(structure().state_is_read_accessible());
1451 
1452  // Body:
1453 
1454  // Space is created in initialize_poset_index_space_for_write() during write.
1455  // But it is not persistent and must be recreated on read.
1456  // It does not persist between partial reads or writes, so if it exists,
1457  // we want to clear it.
1458 
1459  if(!_structure.dof_tuple_id_spaces(false).contains(_file_id_space_name))
1460  {
1462  _file_id_space_name, false, false);
1463  }
1464 
1465  _dof_tuple_id_space.attach_to(_structure.dof_tuple_id_spaces(false),
1466  _file_id_space_name);
1467  _dof_tuple_id_space.clear();
1468 
1469  _dof_tuple_scratch_id = 0;
1470 
1471  // Postconditions:
1472 
1474  ensure(dof_tuple_id_space().is_empty());
1475 
1476  // Exit:
1477 
1478  return;
1479 }
1480 
1481 bool
1484 {
1485  bool result;
1486 
1487  // Preconditions:
1488 
1489  // Body:
1490 
1491  result = _dof_tuple_id_space.is_attached();
1492 
1493  // Postconditions:
1494 
1495  // Exit:
1496 
1497  return result;
1498 }
1499 
1503 {
1504  // Preconditions:
1505 
1506  require(dof_tuple_id_space_initialized());
1507 
1508  // Body:
1509 
1510  scoped_index result(_dof_tuple_id_space, xid);
1511 
1512  // Postconditions:
1513 
1514  // Exit:
1515 
1516  return result;
1517 }
1518 
1522 {
1523  // Preconditions:
1524 
1525  require(dof_tuple_id_space_initialized());
1526 
1527  // Body:
1528 
1529  scoped_index result(_dof_tuple_id_space, xid);
1530 
1531  // Postconditions:
1532 
1533  // Exit:
1534 
1535  return result;
1536 }
1537 
1541 {
1542  // Preconditions:
1543 
1544  require(dof_tuple_id_space_initialized());
1545 
1546  // Body:
1547 
1548  dof_tuple_index_space_type& result = _dof_tuple_id_space;
1549 
1550  // Postconditions:
1551 
1552  ensure(result.is_attached());
1553 
1554  // Exit:
1555 
1556  return result;
1557 }
1558 
1562 {
1563  // Preconditions:
1564 
1565  require(dof_tuple_id_space_initialized());
1566 
1567  // Body:
1568 
1569  const dof_tuple_index_space_type& result = _dof_tuple_id_space;
1570 
1571  // Postconditions:
1572 
1573  ensure(result.is_attached());
1574 
1575  // Exit:
1576 
1577  return result;
1578 }
1579 
1583 {
1584  return _dof_tuple_scratch_id;
1585 }
1586 
1587 void
1590 {
1591  // Preconditions:
1592 
1593  // Body:
1594 
1595  _dof_tuple_scratch_id = xid;
1596 
1597  // Postconditions:
1598 
1599  ensure(dof_tuple_scratch_id() == xid);
1600 
1601  // Exit:
1602 
1603  return;
1604 }
1605 
1609 {
1610  return _dof_tuple_types;
1611 }
1612 
1616 {
1617  return _dof_tuple_types;
1618 }
1619 
1623 {
1624  return _dof_tuple_class_names;
1625 }
1626 
1630 {
1631  return _dof_tuple_class_names;
1632 }
1633 
1637 {
1638  return _dof_tuple_schema_versions;
1639 }
1640 
1644 {
1645  return _dof_tuple_schema_versions;
1646 }
1647 
1648 bool
1651 {
1652  bool result;
1653 
1654  // Preconditions:
1655 
1656  // Body:
1657 
1658  result =
1659  dof_tuple_schema_versions().find(xdof_tuple_ext_id) !=
1660  dof_tuple_schema_versions().end();
1661 
1662  // Postconditions:
1663 
1664  // Exit:
1665 
1666  return result;
1667 }
1668 
1669 int
1672 {
1673  // Preconditions:
1674 
1675  require(dof_tuple_schema_versions_contains(xdof_tuple_ext_id));
1676 
1677  // Body:
1678 
1679  int result = dof_tuple_schema_versions().find(xdof_tuple_ext_id)->second;
1680 
1681  // Postconditions:
1682 
1683  // Exit:
1684 
1685  return result;
1686 }
1687 
1691 {
1692  return _dof_tuple_schema_ids;
1693 }
1694 
1698 {
1699  return _dof_tuple_schema_ids;
1700 }
1701 
1702 bool
1705 {
1706  bool result;
1707 
1708  // Preconditions:
1709 
1710  // Body:
1711 
1712  result =
1713  dof_tuple_schema_ids().find(xdof_tuple_ext_id) != dof_tuple_schema_ids().end();
1714 
1715  // Postconditions:
1716 
1717  // Exit:
1718 
1719  return result;
1720 }
1721 
1724 dof_tuple_schema_id(pod_index_type xdof_tuple_ext_id) const
1725 {
1726  // Preconditions:
1727 
1728  require(dof_tuple_schema_ids_contains(xdof_tuple_ext_id));
1729 
1730  // Body:
1731 
1732  pod_index_type result =
1733  dof_tuple_schema_ids().find(xdof_tuple_ext_id)->second;
1734 
1735  // Postconditions:
1736 
1737  // Exit:
1738 
1739  return result;
1740 }
1741 
1744 dof_tuple_schema_int_id(pod_index_type xdof_tuple_ext_id) const
1745 {
1746  // Preconditions:
1747 
1748  require(dof_tuple_schema_ids_contains(xdof_tuple_ext_id));
1749 
1750  // Body:
1751 
1752  // Get the dof tuple schema ext id.
1753 
1754  pod_index_type lschema_ext_id = dof_tuple_schema_id(xdof_tuple_ext_id);
1755 
1756  // Translate to an internal id.
1757 
1760 
1767 
1768  pod_index_type result =
1769  structure().schema().get_int_id(lschema_ext_id, _file_id_space_name);
1770 
1771  // Postconditions:
1772 
1773  // Exit:
1774 
1775  return result;
1776 }
1777 
1781 {
1782  return _dof_tuple_col_bounds;
1783 }
1784 
1788 {
1789  return _dof_tuple_col_bounds;
1790 }
1791 
1792 bool
1795 {
1796  bool result;
1797 
1798  // Preconditions:
1799 
1800  // Body:
1801 
1802  result =
1803  dof_tuple_col_bounds().find(xdof_tuple_ext_id) != dof_tuple_col_bounds().end();
1804 
1805  // Postconditions:
1806 
1807  // Exit:
1808 
1809  return result;
1810 }
1811 
1814 dof_tuple_col_bound(pod_index_type xdof_tuple_ext_id) const
1815 {
1816  // Preconditions:
1817 
1818  require(dof_tuple_col_bounds_contains(xdof_tuple_ext_id));
1819 
1820  // Body:
1821 
1822  const poset_bounds_descriptor& result =
1823  dof_tuple_col_bounds().find(xdof_tuple_ext_id)->second;
1824 
1825  // Postconditions:
1826 
1827  // Exit:
1828 
1829  return result;
1830 }
1831 
1832 void
1835 {
1836  // Preconditions:
1837 
1838  require(!dof_tuple_col_bounds_contains(xdof_tuple_ext_id) ||
1839  dof_tuple_col_bound(xdof_tuple_ext_id) == col_bounds().descriptor());
1840 
1841  // Body:
1842 
1843  dof_tuple_col_bounds_type::value_type
1844  lmap_pair(xdof_tuple_ext_id, col_bounds().descriptor());
1845 
1846  // Insert will not do anything if entry already present.
1847 
1848  _dof_tuple_col_bounds.insert(lmap_pair);
1849 
1850  // Postconditions:
1851 
1852  ensure(dof_tuple_col_bound(xdof_tuple_ext_id) == col_bounds().descriptor());
1853 
1854  // Exit:
1855 
1856  return;
1857 }
1858 
1859 void
1862 {
1863  // Preconditions:
1864 
1865  // Body:
1866 
1867  schema_poset_member& lschema = external_schema();
1868  poset_powerset_state& lschema_powerset = lschema.host()->powerset();
1869 
1872 
1873 #ifdef DIAGNOSTIC_OUTPUT
1874 
1875  cout << *lsp_id_map << endl;
1876 #endif
1877 
1878  for(dof_tuple_col_bounds_type::iterator itr = _dof_tuple_col_bounds.begin();
1879  itr != _dof_tuple_col_bounds.end();
1880  ++itr)
1881  {
1882  poset_bounds_descriptor& ldesc = itr->second;
1883 
1884 #ifdef DIAGNOSTIC_OUTPUT
1885 
1886  cout << "before: "
1887  << " mode: " << ldesc.mode()
1888  << " lb: " << ldesc.lb_id()
1889  << " ub: " << ldesc.ub_id()
1890  << endl;
1891 #endif
1892 
1893  // Translate the bounds descriptor to internal ids.
1894 
1895  pod_index_type lb_int_id;
1896  if(ldesc.lb_is_member())
1897  {
1898  lb_int_id = lschema.get_int_id(ldesc.lb_id(), _file_id_space_name);
1899  }
1900  else
1901  {
1902  lb_int_id = ldesc.lb_id();
1903  }
1904  ldesc.put_lb_id(lb_int_id);
1905 
1906  pod_index_type ub_int_id;
1907  if(ldesc.ub_is_member())
1908  {
1909  ub_int_id = lschema.get_int_id(ldesc.ub_id(), _file_id_space_name);
1910  }
1911  else
1912  {
1913  ub_int_id = ldesc.ub_id();
1914  }
1915  ldesc.put_ub_id(ub_int_id);
1916 
1917 #ifdef DIAGNOSTIC_OUTPUT
1918 
1919  cout << "after: "
1920  << " mode: " << ldesc.mode()
1921  << " lb: " << ldesc.lb_id()
1922  << " ub: " << ldesc.ub_id()
1923  << endl;
1924 #endif
1925 
1926  }
1927 
1928  // Postconditions:
1929 
1930  // Exit:
1931 
1932  return;
1933 }
1934 
1938 {
1939  return _dof_tuple_domain_offsets;
1940 }
1941 
1945 {
1946  return _dof_tuple_domain_offsets;
1947 }
1948 
1949 bool
1952  pod_index_type xdomain_key) const
1953 {
1954  bool result;
1955 
1956  // Preconditions:
1957 
1958  // Body:
1959 
1960  dof_tuple_domain_offsets_type::key_type lkey(xdof_tuple_ext_id, xdomain_key);
1961  result = (_dof_tuple_domain_offsets.find(lkey) != _dof_tuple_domain_offsets.end());
1962 
1963  // Postconditions:
1964 
1965  // Exit:
1966 
1967  return result;
1968 }
1969 
1973  pod_index_type xdomain_key) const
1974 {
1975  // Preconditions:
1976 
1977  require(dof_tuple_domain_offsets_contains(xdof_tuple_ext_id, xdomain_key));
1978 
1979  // Body:
1980 
1981  dof_tuple_domain_offsets_type::key_type lkey(xdof_tuple_ext_id, xdomain_key);
1982  pod_index_type result(_dof_tuple_domain_offsets.find(lkey)->second);
1983 
1984  // Postconditions:
1985 
1986  // Exit:
1987 
1988  return result;
1989 }
1990 
1991 // PROTECTED MEMBER FUNCTIONS
1992 
1993 // PRIVATE MEMBER FUNCTIONS
1994 
1995 
1996 // ===========================================================
1997 // ID_SPACE FACET
1998 // ===========================================================
1999 
2000 // PUBLIC MEMBER FUNCTIONS
2001 
2005 {
2006  return _id_spaces;
2007 }
2008 
2011 id_spaces() const
2012 {
2013  return _id_spaces;
2014 }
2015 
2016 // PROTECTED MEMBER FUNCTIONS
2017 
2018 // PRIVATE MEMBER FUNCTIONS
2019 
2020 
2021 // ===========================================================
2022 // ANY FACET
2023 // ===========================================================
2024 
2025 // PUBLIC MEMBER FUNCTIONS
2026 
2029 clone() const
2030 {
2031  poset_scaffold* result;
2032 
2033  // Preconditions:
2034 
2035  // Body:
2036 
2037  result = new poset_scaffold(*this);
2038 
2039  // Postconditions:
2040 
2041  ensure(result != 0);
2042  ensure(is_same_type(result));
2043 
2044  // Exit:
2045 
2046  return result;
2047 }
2048 
2049 bool
2051 invariant() const
2052 {
2053  bool result = true;
2054 
2055  // Preconditions:
2056 
2057  // Body:
2058 
2059  // Must satisfy base class invariant
2060 
2061  result = result && any::invariant();
2062 
2063  if(invariant_check())
2064  {
2065  // Prevent recursive calls to invariant
2066 
2068 
2069 
2070  // Finished, turn invariant checking back on.
2071 
2073  }
2074 
2075  // Postconditions:
2076 
2077  // Exit
2078 
2079  return result;
2080 }
2081 
2082 bool
2084 is_ancestor_of(const any* other) const
2085 {
2086  // Preconditions:
2087 
2088  require(other != 0);
2089 
2090  // Body:
2091 
2092  // True if other conforms to this
2093 
2094  bool result = dynamic_cast<const poset_scaffold*>(other) != 0;
2095 
2096  // Postconditions:
2097 
2098  return result;
2099 
2100 }
2101 
2102 // PROTECTED MEMBER FUNCTIONS
2103 
2104 // PRIVATE MEMBER FUNCTIONS
An implementation of class scattered_insertion_index_space_handle that has a interval id space state...
id_spaces_type & id_spaces()
Buffer for id spaces (mutable version).
virtual bool invariant() const
Class invariant, intended to be redefined in each descendant. See below for template for invariant in...
Definition: any.cc:153
poset_table_state & table() const
The table of dof tuples of this poset.
virtual void put_version(int xversion, bool xunalias=false)
Sets version to (possibly aliased) xversion. If unalias == true, set version to the actual version al...
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.
Index for identifying a poset member relative to a given name space.
A client handle for a subposet.
Definition: subposet.h:86
unordered::unordered_map< pod_index_type, int > dof_tuple_schema_versions_type
Type of dof tuple versions map.
void evaluate_toc_alias()
If row bounds lower bound is an alias for the toc bounds, substitutes the toc bounds into the row bou...
namespace_poset * name_space() const
The name space of this poset.
const poset_bounds_descriptor & dof_tuple_col_bound(pod_index_type xdof_tuple_ext_id) const
A descriptor for the column bound for the dof tuple with external id xdof_tuple_ext_id.
void put_member_record_type_aliases(int xtoc_index, int xdof_tuple_id_index, int xoffset_index)
Sets the member record specific data types.
void insert_id_name_pair(pod_index_type xid, const std::string &xname, block< char > &xbuf)
Inserts xid, xname pair into char buffer xbuf.
virtual void attach_to(pod_type xindex)
Attach to the state with index xindex in the id space family id_spaces().
index_type ub() const
The upper bound on the storage array. The number of items current allocated in the storage array...
int version(bool xunalias=true) const
The (possibly aliased) version of this component. The version of the host used when evaluating proper...
const_iterator begin() const
The initial value for iterators over this map.
const pod_type & pod() const
The "plain old data" storage of this; the value in the external id space.
Definition: scoped_index.h:672
const poset_bounds & toc_bounds() const
The bounds for the table of contents in this transaction.
bool dof_tuple_schema_ids_contains(pod_index_type xdof_tuple_ext_id) const
True if dof_tuple_schema_ids() contains an entry for external dof tuple id xdof_tuple_ext_id ...
An abstract iterator over the ids of an id space.
pod_index_type dof_tuple_schema_int_id(pod_index_type xdof_tuple_ext_id) const
The internal schema id for the dof tuple with external id xdof_tuple_ext_id.
void translate_dof_tuple_col_bounds()
Translate the dof tuple column bounds from external ids to internal ids.
pod_index_type dof_tuple_scratch_id() const
The scratch id for the dof tuple id space.
virtual bool invariant() const
Class invariant.
virtual index_space_iterator & get_subposet_id_space_iterator() const
Allocates an id space iterator over the subposet ids from the iterator pool.
const scoped_index & index() const
The member index of this poset within the namespace host()
void convert_record_id_to_subposet_id(void *xbuf)
Converts namespace relative record id at location xbuf to namespace relative subposet id at location ...
dof_tuple_types_type & dof_tuple_types()
Dof tuple type ids (mutable version).
bool is_persistent() const
True if this id space should be written to disk.
Definition: subposet.cc:645
The default name space; a poset which contains other posets as members.
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
virtual size_type subposet_ct() const
The number of subposets of this poset.
bool ub_is_member() const
True if mode == MEMBER_MEMBER or SUBPOSET_MEMBER.
bool is_write_transaction() const
True is this is a write transaction.
unordered::unordered_map< pod_index_type, std::string > dof_tuple_class_names_type
Type of dof tuple class names map.
scoped_index dof_tuple_ext_id(const scoped_index &xid) const
An id in the dof tuple external id space with pod mapped from xid.
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.
const index_space_family & dof_tuple_id_spaces(bool xauto_access) const
Collection of dof tuple id spaces for this (const version).
dof_tuple_col_bounds_type & dof_tuple_col_bounds()
Dof tuple col bounds map (mutable version).
void clear()
Removes all entries.
poset_table_state & table()
The table state for the poset being transferred. (mutable version)
const index_space_family & member_id_spaces(bool xauto_access) const
Collection of member id spaces for this (const version).
std::vector< subposet * > & subposets()
Buffer for subposet handles (mutable version).
scoped_index subposet_ext_id(const scoped_index &xid) const
An id in the subposet external id space with pod mapped from xid.
A partial multi-valued relation with total injective inverse between names and indices of type index_...
Definition: name_multimap.h:63
STL namespace.
bool dof_tuple_id_space_initialized() const
True if dof_tuple_id_space() has been initialized.
member_name_map_type & member_name_map(bool xrequire_write_access=false)
The bidirectional map between member indices and names.
unordered::unordered_map< pod_index_type, poset_bounds_descriptor > dof_tuple_col_bounds_type
Type of dof tuple col bounds map.
pod_index_type ub_id() const
The index of the upper bound member, if the upper bound contains a single member. ...
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
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.
poset_bounds_descriptor col_bounds
Bounds for the columns accessed in this transaction.
const scoped_index & index() const
The index of the component state this handle is attached to.
virtual void next()=0
Makes id() the next id in the iteration.
void update_toc_bounds(const poset_bounds_descriptor &xdesc)
Replaces toc_bounds() with the bounds specified in descriptor xdesc.
void put_lb_id(pod_index_type xlb_id)
Sets the index of the lower bound to xlb_id.
dof_tuple_class_names_type & dof_tuple_class_names()
Dof tuple class names (mutable version).
bool & is_versioned()
True if poset has more than one version (mutable version).
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
int dof_tuple_schema_version(pod_index_type xext_id) const
The external schema version for the dof tuple with external id xdof_tuple_ext_id. ...
unordered::unordered_map< pod_index_type, pod_index_type > dof_tuple_schema_ids_type
Type of dof tuple schema ids map.
pod_type pod() const
The "plain old data" storage of this.
Definition: record_index.h:238
unordered::unordered_map< pod_index_type, dof_tuple_type > dof_tuple_types_type
Type of dof tuple types map.
const_iterator end() const
The final value for iterators over this map.
void attach_to_state(const poset_state_handle *xhost, pod_index_type xhub_id)
Attach this handle to the state with hub id xhub_id in the current version of host xhost...
scoped_index member_ext_id(const scoped_index &xid) const
An id in the member external id space with pod mapped from xid.
virtual void release_subposet_id_space_iterator(index_space_iterator &xitr) const
Returns the id space iterator xitr to the subposet iterator pool.
void put_ub_id(pod_index_type xub_id)
Sets the index of the upper bound member to xub_ib, if the upper bound contains a single member...
schema_poset_member * clone(bool xnew_state, bool xauto_access=true) const
Make a new handle instance of current. Attach the new instance to a new state if xnew_state is true...
Abstract base class with useful features for all objects.
Definition: any.h:39
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.
virtual schema_poset_member & schema()
The schema for this poset (mutable version).
dof_tuple_index_space_type & dof_tuple_id_space()
External to internal dof_tuple index space for table() (mutable version).
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.
A poset specific collection of data converters, various buffers and other data used while transferrin...
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.
bool is_external() const
True if this has a corresponding member in a name space, but is not yet attached to a state...
record_index member_id
The record index of the member relative to the poset.
Definition: record_index.h:104
void get_member_names_from_poset()
Transfers the enitre poset member name map to the scaffold name map.
poset_bounds_descriptor row_bounds
Bounds for the rows accessed in this transaction.
virtual void detach_from_state()
Detach this handle from its state, if any.
void initialize_dof_tuple_id_space()
Initializes dof_tuple_id_space().
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
virtual bool is_attached() const
True if this handle is attached to a state.
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.
void put_member_record_type_aliases(int xtoc_index, int xdof_tuple_id_index, int xoffset_index)
Sets the member record specific data types These features are logically members of class member_recor...
void convert_record_id_to_member_id(void *buf)
Converts namespace relative record id at location xbuf to namespace relative member id at location xb...
pod_index_type dof_tuple_schema_id(pod_index_type xdof_tuple_ext_id) const
The external schema id for the dof tuple with external id xdof_tuple_ext_id.
bool dof_tuple_domain_offsets_contains(pod_index_type xdof_tuple_ext_id, pod_index_type xdomain_key) const
True of dof_tuple_domain_offsets() contains an entry for pair (xdof_tuple_ext_id, xdomain_key)...
dof_tuple_domain_offsets_type & dof_tuple_domain_offsets()
Dof tuple domain offsets accessor (mutable version).
pod_index_type lb_id() const
The index of the lower bound.
void initialize_transfer_schema_for_read(const scoped_index &xindex)
Initialize internal, transfer, and external schema for read transactions.
schema_poset_member & external_schema()
The schema of the poset in external namespace (mutable version).
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. ...
void put_dof_tuple_scratch_id(pod_index_type xid)
Set the scratch id for the dof tuple id space.
poset_bounds & row_bounds()
The bounds for the rows in this transaction (mutable version).
SHEAF_DLL_SPEC bool is_primitive_index(pod_index_type xindex)
True if xindex is a valid primitive index.
void extract_id_name_pair(pod_index_type &xid, std::string &xname, char *&xbuf)
Extracts xid, xname pair from char buffer xbuf.
poset_bounds & col_bounds()
The bounds for the columns in this transaction (mutable version).
bool ub_is_decomposition() const
True if the join of the members of the upper bound is equal to the external schema.
static const poset_bounds_descriptor & BOTTOM_TOP
An instance with lb() == {bottom} and ub() == {top}.
bool structure_is_namespace() const
True if the poset being transferred is the name space poset.
bool ub_is_singleton() const
True if the upper bound contains a single member.
const scoped_index & hub_id() const
A id in the hub id space; intended for copying to initialize ids to the hub id space.
virtual std::string name() const
The name of this poset.
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
Definition: any.h:97
const index_space_family & subposet_id_spaces(bool xauto_access) const
Collection of subposet id spaces for this (const version).
Record index equivalent to namespace_relative_member_index and namespace_relative_subposet_index.
Definition: record_index.h:67
Index for identifying a subposet relative to a given name space.
void initialize_schema_for_read(schema_poset_member *xext_schema, int xschema_version)
Initialize internal, transfer, and external schema for read transactions.
void put_dof_tuple_col_bound(pod_index_type xdof_tuple_ext_id)
Insets the descriptor for the column bound for the dof tuple with external id xdof_tuple_ext_id into ...
bool contains_poset(pod_index_type xhub_id, bool xauto_access=true) const
True if this contains a poset with hub id xhub_id..
member_name_map_type & member_name_map()
External index to member name map (mutable version).
const hub_index_space_handle & member_hub_id_space(bool xauto_access) const
The member hub id space.
poset_state_handle & structure()
The handle for the poset being transferred. (Name chosen to void name conflict with class poset...
bool lb_is_member() const
True if mode == MEMBER_MEMBER or MEMBER_SUBPOSET.
member_index_space_type & member_id_space()
External to internal member index space for structure() (mutable version).
virtual poset_scaffold * clone() const
Virtual constructor; makes a new instance of the same type as this.
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...
namespace_poset * name_space() const
The namespace this poset resides in.
A description of a (lower, upper) bounds pair for a poset. Specifies a portion of a poset for a bound...
subposet_index_space_type & subposet_id_space()
External to internal subposet index map for powerset() (mutable version).
dof_tuple_schema_versions_type & dof_tuple_schema_versions()
Dof tuple schema versions (mutable version).
bool member_id_space_initialized() const
True if member_id_space() has been initialized.
member_class_names_type & member_class_names()
Member class names (mutable version).
schema_poset_member & internal_schema()
The schema of the poset in internal namespace (mutable version).
bool invariant_check() const
True if invariant checking is enabled.
Definition: any.h:79
dof_tuple_schema_ids_type & dof_tuple_schema_ids()
Dof tuple schema ids (mutable version).
poset_data_type_map & type_map()
Data type map for this poset (mutable version)
bool subposet_id_space_initialized() const
True if subposet_id_space has been initialized.
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
scoped_index index() const
The name space index of this poset.
bool contains(pod_type xid) const
True, if this contains an id space with id xid.
std::string name() const
The name of this poset.
A collection of data converters that map data types between internal and external representations...
Definition: data_type_map.h:49
A poset specific collection of data converters, various buffers and other data used while transferrin...
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_...
schema_poset_member & transfer_schema()
The schema for the restriction that is being read or written (mutable version)
poset_powerset_state & powerset()
The powerset for the poset being transferred. (mutable version)
pod_index_type lb_id() const
The index of the lower bound member, if the lower bound contains a single member. ...
virtual ~poset_scaffold()
Destructor.
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.
record_index poset_id
The record index of the poset relative to the namespace.
Definition: record_index.h:94
subposet & resident()
The resident subposet for structure() (mutable version).
unordered::unordered_map< pod_index_type, std::pair< std::string, size_type > > member_class_names_type
Type of member class names map.
void convert_subposet_id_to_record_id(void *xbuf)
Converts namespace relative subposet id at location xbuf to namespace relative record id at location ...
bool dof_tuple_col_bounds_contains(pod_index_type xdof_tuple_ext_id) const
True if dof_tuple_col_bounds() contains an entry for external dof tuple id xdof_tuple_ext_id ...
void initialize_subposet_id_space()
Initializes subposet_id_space().
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
An auto_block with a no-initialization initialization policy.
std::map< index_type, name_list_type >::const_iterator const_iterator
The const iterator type for this map.
bool is_same_type(const any *other) const
True if other is the same type as this.
Definition: any.cc:79
The set of subsets of a poset.
void enable_invariant_check() const
Enable invariant checking.
Definition: any.h:87
void delete_index(index_type xindex)
Removes all entires for index xindex.
void put_ub_id(pod_index_type xub_id)
Sets the index of the upper bound to xub_id.
bool dof_tuple_schema_versions_contains(pod_index_type xdof_tuple_ext_id) const
True if dof_tuple_schema_versions() contains an entry for external dof tuple id xdof_tuple_ext_id ...
const std::string & file_id_space_name() const
The name of the id space used for the member index map.
virtual poset_bounds * clone() const
Virtual constructor; makes a new instance of the same type as this.
Definition: poset_bounds.cc:30
specification_mode mode() const
Specification mode for this.
pod_index_type dof_tuple_domain_offset(pod_index_type xdof_tuple_ext_id, pod_index_type xdomain_key) const
The offset for domain xdomain_key in tuple xdof_tuple_ext_id.
static interval_index_space_handle new_space(index_space_family &xid_spaces, const std::string &xname, bool xis_persistent, bool xmerge_mode)
Create a new interval id space in the id space family xid_space with name xname, persistence xis_pers...
A client handle for a poset member which has been prepared for use as a schema.
void put_member_names_to_poset()
Transfers all entries in scaffold name map that refer members that exist in the poset.
The data structure representing the table containing the dof tuples of the members of a poset...
std::map< std::pair< pod_index_type, pod_index_type >, pod_index_type > dof_tuple_domain_offsets_type
Type of dof tuple domain offsets map.
poset_powerset_state & powerset() const
The set of subposets of this poset.
pod_type hub_pod() const
The current unglued hub id in the iteration. synonym for unglued_hub_pod().
poset_scaffold(const poset_scaffold &xother)
Copy constructor.
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...
void initialize_member_id_space()
Initializes member_id_space().
void convert_member_id_to_record_id(void *buf)
Converts namespace relative member id at location xbuf to namespace relative record id at location xb...