SheafSystem  0.0.0.0
member_record.cc
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 
18 // Implementation for class member_record
19 
20 #include "SheafSystem/member_record.h"
21 
22 #include "SheafSystem/array_poset_dof_map.h"
23 #include "SheafSystem/assert_contract.h"
24 #include "SheafSystem/data_converter.h"
25 #include "SheafSystem/dof_tuple_record_set.h"
26 #include "SheafSystem/error_message.h"
27 #include "SheafSystem/index_equivalence_iterator.h"
28 #include "SheafSystem/index_space_iterator.h"
29 #include "SheafSystem/implicit_crg_interval.h"
30 #include "SheafSystem/member_record_set.h"
31 #include "SheafSystem/namespace_poset.h"
32 #include "SheafSystem/namespace_poset_dof_map.h"
33 #include "SheafSystem/poset_bounds.h"
34 #include "SheafSystem/poset_dof_iterator.h"
35 #include "SheafSystem/primitives_poset_dof_map.h"
36 #include "SheafSystem/record_queue.h"
37 #include "SheafSystem/standard_dof_tuple_index.h"
38 
39 using namespace std;
40 
41 //#define DIAGNOSTIC_OUTPUT
42 // #undef DIAGNOSTIC_OUTPUT
43 
44 // ===========================================================
45 // MEMBER_RECORD FACET
46 // ===========================================================
47 
51  : variable_length_record(xhost.scaffold()), _host(xhost), _eqv_itr(0)
52 {
53 
54  // Preconditions:
55 
56  require(scaffold().structure().state_is_read_accessible());
57 
58  // Body:
59 
60  // Initialize member-independent offsets.
61 
62  _end_offset = 0;
63 
64  // Neither buffer is initialized.
65 
66  put_is_internal(false);
67  put_is_external(false);
68 
69  // Initialize dof tuple ids to arbitrary size large enough
70  // to avoid several small auto reallocations.
71 
72  _dof_tuple_ids.reserve(32);
73  _dof_tuple_ids.set_ct(0);
74 
75  // Initialize the subposet_ids field in the internal buffer.
76 
77  int lsp_ub = scaffold().subposets().size();
78  _subposet_ids.reserve(lsp_ub);
79  _subposet_ids.set_ct(0);
80 
81  // Initialize equivalent ids to arbitrary size large enough
82  // to avoid several small auto reallocations.
83 
84  _eqv_ids.reserve(32);
85  _eqv_ids.set_ct(0);
86 
87  // Initialize name buffer to arbitrary size large enough
88  // to avoid several small auto reallocations.
89 
90  _names.reserve(32);
91  _names.set_ct(0);
92 
93  // Make sure _mbr_id and _ext_id have
94  // internal and extrnal scope, repsectivly.
95 
96  _mbr_id.put_scope(scaffold().structure().member_hub_id_space(false));
97  _ext_id.put_scope(scaffold().member_id_space());
98 
99  // Postconditions:
100 
101  ensure(invariant());
102 
103  ensure(!(external_index().is_valid()));
104 
105  ensure(&(host()) == &xhost);
106  ensure(buf() == 0);
107  ensure(buf_ub() == 0);
108  ensure(!is_internal());
109  ensure(!is_external());
110 
111  // Exit:
112 
113  return;
114 }
115 
119  : variable_length_record(xother), _host(xother._host), _eqv_itr(0)
120 {
121 
122  // Preconditions:
123 
124  // Body:
125 
126  not_implemented();
127 
128  // Postconditions:
129 
130  ensure(invariant());
131 }
132 
136 {
137 
138  // Preconditions:
139 
140  // Body:
141 
142  if(_eqv_itr != 0)
143  delete _eqv_itr;
144 
145  // Postconditions:
146 
147  // Exit:
148 
149  return;
150 }
151 
152 
153 
157 interval() const
158 {
159  return _interval;
160 }
161 
162 
163 
165 bool
167 is_resident() const
168 {
169  return _is_resident;
170 }
171 
172 
175 sheaf::member_record::
176 host()
177 {
178  // Preconditions:
179 
180  // Body:
181 
182  member_record_set& result = _host;
183 
184  // Postconditions:
185 
186  // Exit:
187 
188  return result;
189 }
190 
191 
194 sheaf::member_record::
195 host() const
196 {
197  // Preconditions:
198 
199  // Body:
200 
201  member_record_set& result = _host;
202 
203  // Postconditions:
204 
205  // Exit:
206 
207  return result;
208 }
209 
210 // ===========================================================
211 // EQUIVALENCE ITERATOR FACET
212 // ===========================================================
213 
214 void
217 {
218  // Preconditions:
219 
220  require(!has_equivalence_iterator());
221  require(scaffold().structure().state_is_read_accessible());
222 
223  // Body:
224 
225  _eqv_itr = new index_equivalence_iterator(scaffold().structure().member_id_spaces(false),
226  true, false);
227 
228  // Postconditions:
229 
230  ensure(has_equivalence_iterator());
231 
232  // Exit:
233 
234  return;
235 }
236 
237 void
240 {
241  // Precondtions:
242 
243  require(has_equivalence_iterator());
244 
245  // Body:
246 
247  delete _eqv_itr;
248  _eqv_itr = 0;
249 
250  // Postconditions:
251 
252  ensure(!has_equivalence_iterator());
253 
254  // Exit:
255 
256  return;
257 }
258 
259 bool
262 {
263  return (_eqv_itr != 0);
264 }
265 
267 sheaf::member_record::
268 equivalence_iterator(const scoped_index& xrep_id)
269 {
270  // Preconditions:
271 
272  require(has_equivalence_iterator());
273  require(scaffold().structure().contains_member(xrep_id, true));
274 
275  // Body:
276 
277  index_equivalence_iterator& result = *_eqv_itr;
278  result.put_rep_id(xrep_id);
279  result.reset();
280 
281  // Postconditions:
282 
283  ensure(result.rep_id() == xrep_id.hub_pod());
284 
285  // Exit:
286 
287  return result;
288 }
289 
290 // ===========================================================
291 // EXTERNAL SIZE FACET
292 // ===========================================================
293 
298 {
299 
300  // Preconditions:
301 
302  require(scaffold().structure().state_is_read_accessible());
303 
304  // Body:
305 
306 #ifdef DIAGNOSTIC_OUTPUT
307  cout << "member_record::external_size: member: " << xmbr_id << endl;
308 #endif
309 
310  // Map xmbr_id into internal and external scope.
311 
312  xmbr_id >> _mbr_id;
313  xmbr_id >> _ext_id;
314 
315  // Initialize poset and interval variables.
316 
317  _poset = &scaffold().structure();
318  _interval = _poset->crg().implicit_member(xmbr_id.hub_pod());
319 
320  _toc.reset();
321 
322  size_type result = 0;
323  result += private_data_external_size();
324  result += dof_tuple_ids_external_size();
325  result += lower_cover_external_size();
326  result += upper_cover_external_size();
327  result += subposet_ids_external_size();
328  result += eqv_ids_external_size();
329  result += toc_external_size();
330 
331 #ifdef DIAGNOSTIC_OUTPUT
332  cout << "\ttoc: " << _toc << " = " << _toc.to_ulong()
333  << " size: " << result
334  << endl;
335 #endif
336 
337  // Postconditions:
338 
339  // Exit
340 
341  return result;
342 }
343 
346 sheaf::member_record::
347 private_data_external_size()
348 {
349  // Preconditions:
350 
351  // Body:
352 
353 #ifdef DIAGNOSTIC_OUTPUT
354  cout << "sheaf::member_record::private_data_external_size " << endl;
355 #endif
356 
357  size_type result;
358 
359  if(_interval != 0)
360  {
361  // This is an implicit member.
362 
363  if(_interval->is_interval_member(_mbr_id.pod()))
364  {
365  // This is the interval member itself;
366  // get the private data.
367 
368  result = _interval->private_data_size();
369  }
370  else
371  {
372  // This is one of the other members in the interval;
373  // doesn't have private data.
374 
375  result = 0;
376  }
377  }
378  else
379  {
380  // This is an explicit member; no private data.
381 
382  result = 0;
383  }
384 
385  if(result > 0)
386  {
387  // Add room for the ct field.
388 
389  ++result;
390  }
391 
392  _toc[HAS_PRIVATE_DATA] = (result > 0);
393 
394 #ifdef DIAGNOSTIC_OUTPUT
395  cout << "\ttoc: " << _toc << " = " << _toc.to_ulong()
396  << " size: " << result
397  << endl;
398 #endif
399 
400  // Postconditions:
401 
402  // Exit
403 
404  return result;
405 }
406 
409 sheaf::member_record::
410 dof_tuple_ids_external_size()
411 {
412  // Preconditions:
413 
414  // Body:
415 
416 #ifdef DIAGNOSTIC_OUTPUT
417  cout << "member_record::dof_tuple_ids_external_size " << endl;
418 #endif
419 
420  size_type result;
421 
422  if(_interval != 0)
423  {
424  // This member is in an implicit interval.
425 
426  if(_interval->is_interval_member(_mbr_id.pod()))
427  {
428  // This is the interval member itself
429 
430  result = _interval->dof_tuple_ids().ct();
431  }
432  else
433  {
434  result = 0;
435  }
436  }
437  else
438  {
439  // This is an explicit member.
440 
441  if(_poset->is_jim(_mbr_id, false))
442  {
443  // Member is a jim in some version; it has a dof tuple.
444 
445  result = 1;
446  }
447  else
448  {
449  // Member is a jrm - doesn't have a dof tuple.
450 
451  result = 0;
452  }
453  }
454 
455  if(result > 0)
456  {
457  // Add room for the ct field.
458 
459  ++result;
460  }
461 
462  _toc[HAS_DOF_TUPLE_IDS] = (result > 0);
463 
464 #ifdef DIAGNOSTIC_OUTPUT
465  cout << "\ttoc: " << _toc << " = " << _toc.to_ulong()
466  << " size: " << result
467  << endl;
468 #endif
469 
470  // Postconditions:
471 
472  // Exit
473 
474  return result;
475 }
476 
479 sheaf::member_record::
480 lower_cover_external_size()
481 {
482  // Preconditions:
483 
484  // Body:
485 
486 #ifdef DIAGNOSTIC_OUTPUT
487  cout << "member_record::lower_cover_external_size " << endl;
488 #endif
489 
490  poset_crg_state& lcrg = _poset->crg();
491 
492  // Lower_cover:
493 
494  pod_index_type lmbr_id = _mbr_id.hub_pod();
495 
496  size_type result;
497  if(lcrg.cover_is_explicit(LOWER, lmbr_id))
498  {
499  // Lover cover for this member is explicit;
500  // must be written to the file.
501 
502  result = lcrg.cover_ct(LOWER, lmbr_id);
503  }
504  else
505  {
506  // Lover cover for this member is implicit.
507 
508  result = 0;
509  }
510 
511  if(result > 0)
512  {
513  // Add room for the ct field.
514 
515  ++result;
516  }
517 
518  _toc[HAS_LOWER_COVER] = (result > 0);
519 
520 #ifdef DIAGNOSTIC_OUTPUT
521  cout << "\ttoc: " << _toc << " = " << _toc.to_ulong()
522  << " size: " << result
523  << endl;
524 #endif
525 
526  // Postconditions:
527 
528  // Exit
529 
530  return result;
531 }
532 
535 sheaf::member_record::
536 upper_cover_external_size()
537 {
538  // Preconditions:
539 
540  // Body:
541 
542 #ifdef DIAGNOSTIC_OUTPUT
543  cout << "member_record::upper_cover_external_size " << endl;
544 #endif
545 
546  poset_crg_state& lcrg = _poset->crg();
547 
548  // Upper_cover:
549 
550  pod_index_type lmbr_id = _mbr_id.hub_pod();
551 
552  size_type result;
553  if(lcrg.cover_is_explicit(UPPER, lmbr_id))
554  {
555  // Upper cover for this member is explicit;
556  // must be written to the file.
557 
558  result = lcrg.cover_ct(UPPER, lmbr_id);
559  }
560  else
561  {
562  // Upper cover for this member is implicit.
563 
564  result = 0;
565  }
566 
567  if(result > 0)
568  {
569  // Add room for the ct field.
570 
571  ++result;
572  }
573 
574  _toc[HAS_UPPER_COVER] = (result > 0);
575 
576 #ifdef DIAGNOSTIC_OUTPUT
577  cout << "\ttoc: " << _toc << " = " << _toc.to_ulong()
578  << " size: " << result
579  << endl;
580 #endif
581 
582  // Postconditions:
583 
584  // Exit
585 
586  return result;
587 }
588 
591 sheaf::member_record::
592 subposet_ids_external_size()
593 {
594  // Preconditions:
595 
596  // Body:
597 
598 #ifdef DIAGNOSTIC_OUTPUT
599  cout << "member_record::subposet_ids_external_size " << endl;
600 #endif
601 
602  // Iterate over all the subposets except the standard ones;
603  // whole doesn't need to be stored and jims is in the toc.
604 
605  int lsp_min = _poset->standard_subposet_ct();
606  int lsp_ub = scaffold().subposets().size();
607 
608  bool lhas_toc_subposet_ids = false;
609  size_type result = 0;
610 
611  for(int i = lsp_min; i<lsp_ub; i++)
612  {
613  subposet* lsp = scaffold().subposets()[i];
614 
615  if( lsp->contains_member(_mbr_id) )
616  {
617  int lsp_bit = i - lsp_min + SUBPOSET_BITS_BEGIN;
618  if(lsp_bit < SUBPOSET_BITS_END)
619  {
620  // This subposet is in the toc.
621 
622  lhas_toc_subposet_ids = true;
623  }
624  else
625  {
626  // Out of room in the toc.
627  // Put subposet id into buffer to be
628  // written explicitly into record.
629 
630  ++result;
631  }
632  }
633  }
634 
635  if(result > 0)
636  {
637  // Add room for the ct field.
638 
639  ++result;
640  }
641 
642  _toc[HAS_TOC_SUBPOSET_IDS] = lhas_toc_subposet_ids;
643  _toc[HAS_SUBPOSET_IDS] = (result > 0);
644 
645 #ifdef DIAGNOSTIC_OUTPUT
646  cout << "\ttoc: " << _toc << " = " << _toc.to_ulong()
647  << " size: " << result
648  << endl;
649 #endif
650 
651  // Postconditions:
652 
653  // Exit
654 
655  return result;
656 }
657 
660 sheaf::member_record::
661 eqv_ids_external_size()
662 {
663  // Preconditions:
664 
665  require(has_equivalence_iterator());
666 
667  // Body:
668 
669 #ifdef DIAGNOSTIC_OUTPUT
670  cout << "member_record::eqv_ids_external_size " << endl;
671 #endif
672 
673  size_type result = 0;
674 
675  // Iterate over the equivalence class of xmbr_id,
676  // transferring to internal buffer.
677 
678  result += (2*equivalence_iterator(_mbr_id).ct());
679 
680  if(result > 0)
681  {
682  // Add room for the ct field.
683 
684  ++result;
685  }
686 
687  _toc[HAS_EQV_IDS] = (result > 0);
688 
689 #ifdef DIAGNOSTIC_OUTPUT
690  cout << "\ttoc: " << _toc << " = " << _toc.to_ulong()
691  << " size: " << result
692  << endl;
693 #endif
694 
695  // Postconditions:
696 
697  // Exit
698 
699  return result;
700 }
701 
704 sheaf::member_record::
705 toc_external_size()
706 {
707  // Preconditions:
708 
709  // Body:
710 
711 #ifdef DIAGNOSTIC_OUTPUT
712  cout << "member_record::toc_external_size" << endl;
713 #endif
714 
715  // Set bits so that if we have to write the toc,
716  // some bit will be turned on. Note that this is
717  // not quite the same definition of the bits as
718  // when we actually write the toc.
719 
720  _toc[IS_JIM] = (_interval == 0) && _poset->is_jim(_mbr_id);
721  _toc[HAS_NAMES] = _poset->member_name_ct(_mbr_id, false) > 0;
722  _toc[IS_INTERVAL] = (_interval != 0) && (_interval->is_interval_member(_mbr_id.pod()));
723 
724 
725  // HAS_DOF_TUPLE _IDS, HAS_LOWER_COVER, HAS_UPPER_COVER, HAS_SUBPOSET_IDS,
726  // and HAS_EQV_IDS flags already set in their respective _external_size routines.
727 
728  size_type result = _toc.any() ? 1 : 0;
729 
730 
731 #ifdef DIAGNOSTIC_OUTPUT
732  cout << "\ttoc: " << _toc << " = " << _toc.to_ulong()
733  << " size: " << result
734  << endl;
735 #endif
736 
737  // Postconditions:
738 
739  // Exit
740 
741  return result;
742 }
743 
744 
745 // ===========================================================
746 // WRITE FACET
747 // ===========================================================
748 
750 void
752 externalize(const scoped_index& xmbr_id, hvl_t* xhdf_buffer)
753 {
754 
755  // Preconditions:
756 
757  require(scaffold().structure().state_is_read_accessible());
758 
759  // Body:
760 
761 #ifdef DIAGNOSTIC_OUTPUT
762  cout << "member_record::externalize: member: " << xmbr_id << endl;
763 #endif
764 
765  // Map xmbr_id into internal and external scope.
766 
767  xmbr_id >> _mbr_id;
768  xmbr_id >> _ext_id;
769 
770  // Initialize poset and interval variables.
771 
772  _poset = &scaffold().structure();
773  _interval = _poset->crg().implicit_member(xmbr_id.hub_pod());
774 
775  // Initialize the internal buffer from the member
776  // with internal id xmbr_id.
777 
778  transfer_member_to_internal_buffer(xmbr_id);
779 
780  // Convert the internal buffer to external form
781  // and place the result in the external buffer.
782 
783  convert_internal_buffer_to_external_buffer();
784 
785  // Transfer the external buffer to HDF
786 
787  transfer_external_buffer_to_HDF(xhdf_buffer);
788 
789  // Postconditions:
790 
791  // Exit
792 
793  return;
794 }
795 
797 void
798 sheaf::member_record::
799 transfer_member_to_internal_buffer(const scoped_index& xmbr_id)
800 {
801  // Preconditions:
802 
803  require(scaffold().structure().state_is_read_accessible());
804 
805  // Body:
806 
807  clear_internal_buffer();
808 
809  // Toc:
810 
811  transfer_member_to_toc(xmbr_id);
812 
813  // Dof tuple id:
814 
815  if(_toc[IS_INTERVAL])
816  {
817  transfer_interval_to_private_data(xmbr_id);
818  transfer_interval_to_dof_tuple_ids(xmbr_id);
819  transfer_interval_to_class_names(xmbr_id);
820  }
821  else
822  {
823  transfer_member_to_dof_tuple_ids(xmbr_id);
824  }
825 
826  // Lower_cover:
827 
828  transfer_member_to_lower_cover(xmbr_id);
829 
830  // Upper_cover:
831 
832  transfer_member_to_upper_cover(xmbr_id);
833 
834  // Subposet ids:
835 
836  transfer_member_to_subposet_ids(xmbr_id);
837 
838  // Equivalent ids:
839 
840  transfer_member_to_eqv_ids(xmbr_id);
841 
842 
843  // Names:
844  // Names now transferred directly by storage agent::commit_transaction
845  // using poset_scaffold::get_member_names_from_poset.
846  // transfer_member_to_names(xmbr_id);
847 
848 
849 #ifdef DIAGNOSTIC_OUTPUT
850  cout << "leaving member_record::transfer_member_to_internal_buffer " << endl;
851  cout << "\ttoc: " << _toc << " = " << _toc.to_ulong() << endl;
852 #endif
853 
854  // Now the internal buffer is initialized;
855 
856  put_is_internal(true);
857 
858  // Postconditions:
859 
860  ensure(is_internal());
861 
862  // Exit
863 
864  return;
865 }
866 
868 void
869 sheaf::member_record::
870 clear_internal_buffer()
871 {
872  // Preconditions:
873 
874 
875  // Body:
876 
877  _toc.reset();
878  _private_data.clear();
879  _dof_tuple_ids.clear();
880  _lower_cover.clear();
881  _upper_cover.clear();
882  _subposet_ids.clear();
883  _eqv_ids.clear();
884  _names.clear();
885 
886  // Postconditions:
887 
888  ensure(_toc.none());
889  ensure(_private_data.ct() == 0);
890  ensure(_dof_tuple_ids.ct() == 0);
891  ensure(_lower_cover.ct() == 0);
892  ensure(_upper_cover.ct() == 0);
893  ensure(_subposet_ids.ct() == 0);
894  ensure(_eqv_ids.ct() == 0);
895  ensure(_names.ct() == 0);
896 
897  // Exit:
898 
899  return;
900 }
901 
903 void
904 sheaf::member_record::
905 transfer_member_to_toc(const scoped_index& xmbr_id)
906 {
907  // Preconditions:
908 
909  require(_toc.none());
910 
911  // Body:
912 
913 #ifdef DIAGNOSTIC_OUTPUT
914  cout << "member_record::transfer_member_to_toc " << endl;
915 #endif
916 
917  // Make some convenient local variables
918 
919  _toc[IS_JIM] = _poset->is_jim(xmbr_id);
920  _toc[HAS_NAMES] = _poset->member_name_ct(_mbr_id, false) > 0;
921 
922  _toc[IS_INTERVAL] = (_interval != 0);
923 
924  // HAS_DOF_TUPLE_IDS, HAS_LOWER_COVER, HAS_UPPER_COVER, HAS_SUBPOSET_IDS,
925  // and HAS_EQV_IDS flags set in transfer_*_to_dof_tuple_ids, transfer_member_to_links,
926  // transfer_member_to_subposet_ids, and transfer_member_to_eqv_ids,
927  // respectively.
928 
929 #ifdef DIAGNOSTIC_OUTPUT
930  cout << "\ttoc: " << _toc << " = " << _toc.to_ulong() << endl;
931 #endif
932 
933  // Postconditions:
934 
935  // Exit
936 
937  return;
938 }
939 
941 void
942 sheaf::member_record::
943 transfer_interval_to_private_data(const scoped_index& xmbr_id)
944 {
945  // Preconditions:
946 
947  require(scaffold().structure().crg().implicit_member(xmbr_id.hub_pod()) != 0);
948  require(_private_data.ct() == 0);
949 
950  // Body:
951 
952 #ifdef DIAGNOSTIC_OUTPUT
953  cout << "member_record::transfer_interval_to_private_data " << endl;
954 #endif
955 
956  // Make some convenient local variables
957 
958  if(_interval->is_interval_member(xmbr_id))
959  {
960  // This is the interval member itself;
961  // get the private data.
962 
963  _interval->get_private_data(_private_data);
964  }
965  else
966  {
967  // This is one of the other members in the interval;
968  // doesn't have private data.
969  // Do nothing.
970  }
971 
972  _toc[HAS_PRIVATE_DATA] = (_private_data.ct() > 0);
973 
974 #ifdef DIAGNOSTIC_OUTPUT
975  cout << "\t_private_data ct: " << _private_data.ct() << " ids: ";
976  for(int i=0; i<_private_data.ct(); i++)
977  {
978  cout << setw(6) << _private_data[i];
979  }
980  cout << endl;
981  cout << "\ttoc: " << _toc << " = " << _toc.to_ulong() << endl;
982 #endif
983 
984 
985  // Postconditions:
986 
987  // Exit
988 
989  return;
990 }
991 
992 void
993 sheaf::member_record::
994 transfer_member_to_dof_tuple_ids(const scoped_index& xmbr_id)
995 {
996  // Preconditions:
997 
998  require(scaffold().structure().crg().implicit_member(xmbr_id.hub_pod()) == 0);
999  require(_dof_tuple_ids.ct() == 0);
1000 
1001  // Body:
1002 
1003 #ifdef DIAGNOSTIC_OUTPUT
1004  cout << "member_record::transfer_member_to_dof_tuple_id " << endl;
1005 #endif
1006 
1007  if(_poset->is_jim(xmbr_id, false))
1008  {
1009  // Member is a jim in some version; it has a dof tuple.
1010 
1011  scoped_index ldof_tuple_id;
1012  pod_index_type lext_dof_tuple_id;
1013 
1014  // Restriction to BOTTOM:
1015  // If the schema is restricted to BOTTOM, then the
1016  // dof tuple is empty. As with the empty set and the null
1017  // vector, we treat the empty dof tuple as unique. So all
1018  // members of a poset on the BOTTOM schema share the same
1019  // dof tuple, which contains no dofs. The dof tuple id for
1020  // the empty dof tuple is 0. This structure is the same for
1021  // both internal and external posets.
1022 
1023  bool ldof_tuple_is_empty =
1024  (scaffold().external_schema().index() == BOTTOM_INDEX);
1025 
1026  if(ldof_tuple_is_empty)
1027  {
1028  // Dof tuple is empty; use the unique empty dof tuple id.
1029 
1030  ldof_tuple_id = _poset->dof_tuple_id(EMPTY_DOF_TUPLE_INDEX, false);
1031  }
1032  else
1033  {
1034  // External dof tuple is not empty;
1035  // use the member's dof tuple id.
1036 
1037  _poset->member_dof_tuple_id(xmbr_id, ldof_tuple_id, false);
1038  }
1039 
1040  // Get the external dof tuple id, if one has been assigned.
1041 
1042  lext_dof_tuple_id =
1043  scaffold().dof_tuple_id_space().pod(ldof_tuple_id);
1044 
1045  if(!is_valid(lext_dof_tuple_id))
1046  {
1047  // This is the first time we've encountered this dof tuple;
1048  // get an external id for it. External id will be the offset of
1049  // the beginning of the tuple in the dataset.
1050 
1051  lext_dof_tuple_id =
1052  host().dof_tuple_records().compute_ext_id(ldof_tuple_id);
1053 
1054  // If there's something to write, put it on the write queue.
1055 
1056  if(!ldof_tuple_is_empty)
1057  {
1058  host().dof_tuple_records().queue().enqueue(lext_dof_tuple_id);
1059  }
1060 
1061  // Save the dof tuple type and class name to be written in the
1062  // respective maps; maps must not already contain an entry for
1063  // lext_dof_tuple_id.
1064 
1065  assertion(scaffold().dof_tuple_types().find(lext_dof_tuple_id) ==
1066  scaffold().dof_tuple_types().end());
1067 
1068  const poset_dof_map& ldof_map = _poset->row_dof_map(ldof_tuple_id);
1069 
1070  dof_tuple_type ltype_id = ldof_map.type_id();
1071 
1072  typedef poset_scaffold::dof_tuple_types_type::value_type types_value_type;
1073  types_value_type ltypes_value(lext_dof_tuple_id, ltype_id);
1074 
1075  scaffold().dof_tuple_types().insert(ltypes_value);
1076 
1077  assertion(scaffold().dof_tuple_class_names().find(lext_dof_tuple_id) ==
1078  scaffold().dof_tuple_class_names().end());
1079 
1080  string lclass_name = ldof_map.class_name();
1081 
1082  typedef poset_scaffold::dof_tuple_class_names_type::value_type names_value_type;
1083  names_value_type lnames_value(lext_dof_tuple_id, lclass_name);
1084 
1085  scaffold().dof_tuple_class_names().insert(lnames_value);
1086  }
1087 
1088  // Save the external id in the internal buffer.
1089 
1090  _dof_tuple_ids.push_back(lext_dof_tuple_id);
1091  }
1092  else
1093  {
1094  // Member is a jrm - doesn't have a dof tuple; do nothing.
1095  }
1096 
1097  _toc[HAS_DOF_TUPLE_IDS] = (_dof_tuple_ids.ct() > 0);
1098 
1099 #ifdef DIAGNOSTIC_OUTPUT
1100  cout << "\t_dof_tuple_ids ct: " << _dof_tuple_ids.ct() << " ids : ";
1101  for(int i=0; i<_dof_tuple_ids.ct(); i++)
1102  {
1103  cout << setw(6) << _dof_tuple_ids[i];
1104  }
1105  cout << endl;
1106  cout << "\ttoc: " << _toc << " = " << _toc.to_ulong() << endl;
1107 #endif
1108 
1109  // Postconditions:
1110 
1111  // Exit
1112 
1113  return;
1114 }
1115 
1116 void
1117 sheaf::member_record::
1118 transfer_interval_to_dof_tuple_ids(const scoped_index& xmbr_id)
1119 {
1120  // Preconditions:
1121 
1122  require(scaffold().structure().crg().implicit_member(xmbr_id.hub_pod()) != 0);
1123  require(_dof_tuple_ids.ct() == 0);
1124 
1125  // Body:
1126 
1127 #ifdef DIAGNOSTIC_OUTPUT
1128  cout << "member_record::transfer_interval_to_dof_tuple_id " << endl;
1129 #endif
1130 
1131  // Make some convenient local variables
1132 
1133  interval_index_space_handle& ldof_tuple_space =
1135 
1136  if(_interval->is_interval_member(xmbr_id))
1137  {
1138  // This is the interval member itself.
1139 
1140  for(int i=0; i< _interval->dof_tuple_ids().ct(); ++i)
1141  {
1142  scoped_index ldof_tuple_id = scaffold().structure().dof_tuple_id(_interval->dof_tuple_ids()[i], false);
1143 
1144  // Get the external dof tuple id, if one has been assigned.
1145 
1146  pod_index_type lext_dof_tuple_id = ldof_tuple_space.pod(ldof_tuple_id);
1147 
1148  if(!is_valid(lext_dof_tuple_id))
1149  {
1150  // This is the first time we've encountered this dof tuple;
1151  // get an external id for it. External id will be the offset of
1152  // the beginning of the tuple in the dataset.
1153 
1154  lext_dof_tuple_id =
1155  host().dof_tuple_records().compute_ext_id(ldof_tuple_id);
1156 
1157  // Put the dof tuple id on the write queue.
1158 
1159  host().dof_tuple_records().queue().enqueue(lext_dof_tuple_id);
1160 
1161  // Save the dof tuple type and class name to be written in the
1162  // respective maps; maps must not already contain an entry for
1163  // lext_dof_tuple_id.
1164 
1165  assertion(scaffold().dof_tuple_types().find(lext_dof_tuple_id) ==
1166  scaffold().dof_tuple_types().end());
1167 
1168  const poset_dof_map& ldof_map = _poset->row_dof_map(ldof_tuple_id);
1169 
1170  dof_tuple_type ltype_id = ldof_map.type_id();
1171 
1172  typedef poset_scaffold::dof_tuple_types_type::value_type types_value_type;
1173  types_value_type ltypes_value(lext_dof_tuple_id, ltype_id);
1174 
1175  scaffold().dof_tuple_types().insert(ltypes_value);
1176 
1177  assertion(scaffold().dof_tuple_class_names().find(lext_dof_tuple_id) ==
1178  scaffold().dof_tuple_class_names().end());
1179 
1180  string lclass_name = ldof_map.class_name();
1181 
1182  typedef poset_scaffold::dof_tuple_class_names_type::value_type names_value_type;
1183  names_value_type lnames_value(lext_dof_tuple_id, lclass_name);
1184 
1185  scaffold().dof_tuple_class_names().insert(lnames_value);
1186  }
1187 
1188  // Save the external id in the internal buffer.
1189 
1190  _dof_tuple_ids.push_back(lext_dof_tuple_id);
1191  }
1192  }
1193  else
1194  {
1195  // This is one of the other members in the interval;
1196  // dof tuple has already been written out.
1197  // Do nothing.
1198  }
1199 
1200  _toc[HAS_DOF_TUPLE_IDS] = (_dof_tuple_ids.ct() > 0);
1201 
1202 #ifdef DIAGNOSTIC_OUTPUT
1203  cout << "\t_dof_tuple_ids ct: " << _dof_tuple_ids.ct() << " ids: ";
1204  for(int i=0; i<_dof_tuple_ids.ct(); i++)
1205  {
1206  cout << setw(6) << _dof_tuple_ids[i];
1207  }
1208  cout << endl;
1209  cout << "\ttoc: " << _toc << " = " << _toc.to_ulong() << endl;
1210 #endif
1211 
1212 
1213  // Postconditions:
1214 
1215  // Exit
1216 
1217  return;
1218 }
1219 
1221 void
1222 sheaf::member_record::
1223 transfer_member_to_lower_cover(const scoped_index& xmbr_id)
1224 {
1225  // Preconditions:
1226 
1227  require(_lower_cover.ct() == 0);
1228 
1229  // Body:
1230 
1231 #ifdef DIAGNOSTIC_OUTPUT
1232  cout << "member_record::transfer_member_to_lower_cover " << endl;
1233 #endif
1234 
1235  // Lower_cover:
1236 
1237  pod_index_type lmbr_id = xmbr_id.hub_pod();
1238 
1239  if(_poset->crg().cover_is_explicit(LOWER, lmbr_id))
1240  {
1241  // Lover cover for this member is explicit;
1242  // must be written to the file.
1243 
1244  index_space_iterator& itr = _poset->get_cover_id_space_iterator(LOWER, lmbr_id);
1245  while(!itr.is_done())
1246  {
1247  _lower_cover.push_back(itr.hub_pod());
1248  itr.next();
1249  }
1250  _poset->release_cover_id_space_iterator(itr);
1251  }
1252  else
1253  {
1254  // Lover cover for this member is implicit; do nothing.
1255  }
1256 
1257  _toc[HAS_LOWER_COVER] = (_lower_cover.ct() > 0);
1258 
1259 #ifdef DIAGNOSTIC_OUTPUT
1260  cout << "\t_lower_cover ct: " << _lower_cover.ct() << " ids: ";
1261  for(int i=0; i<_lower_cover.ct(); i++)
1262  {
1263  cout << setw(6) << _lower_cover[i];
1264  }
1265  cout << endl;
1266  cout << "\ttoc: " << _toc << " = " << _toc.to_ulong() << endl;
1267 #endif
1268 
1269  // Postconditions:
1270 
1271  // Exit
1272 
1273  return;
1274 }
1275 
1277 void
1278 sheaf::member_record::
1279 transfer_member_to_upper_cover(const scoped_index& xmbr_id)
1280 {
1281  // Preconditions:
1282 
1283  require(_upper_cover.ct() == 0);
1284 
1285  // Body:
1286 
1287 #ifdef DIAGNOSTIC_OUTPUT
1288  cout << "member_record::transfer_member_to_upper_cover " << endl;
1289 #endif
1290 
1291  // Upper_cover:
1292 
1293  pod_index_type lmbr_id = xmbr_id.hub_pod();
1294 
1295  if(_poset->crg().cover_is_explicit(UPPER, lmbr_id) &&
1296  (lmbr_id != BOTTOM_INDEX))
1297  {
1298  // Every explicit upper cover except bottom must be written to disk.
1299 
1300  index_space_iterator& itr = _poset->get_cover_id_space_iterator(UPPER, lmbr_id);
1301  while(!itr.is_done())
1302 
1303  {
1304  _upper_cover.push_back(itr.hub_pod());
1305  itr.next();
1306  }
1307  _poset->release_cover_id_space_iterator(itr);
1308  }
1309  else
1310  {
1311  // Either Upper cover for this member is implicit or
1312  // this member is bottom; do nothing.
1313 
1314  // Upper cover of bottom is not written to disk, it is
1315  // reconstructed on read, see transfer_lower_cover_to_member.
1316  }
1317 
1318  _toc[HAS_UPPER_COVER] = (_upper_cover.ct() > 0);
1319 
1320 #ifdef DIAGNOSTIC_OUTPUT
1321  cout << "\t_upper_cover ct: " << _upper_cover.ct() << " ids: ";
1322  for(int i=0; i<_upper_cover.ct(); i++)
1323  {
1324  cout << setw(6) << _upper_cover[i];
1325  }
1326  cout << endl;
1327  cout << "\ttoc: " << _toc << " = " << _toc.to_ulong() << endl;
1328 #endif
1329 
1330  // Postconditions:
1331 
1332  // Exit
1333 
1334  return;
1335 }
1336 
1338 void
1339 sheaf::member_record::
1340 transfer_member_to_subposet_ids(const scoped_index& xmbr_id)
1341 {
1342  // Preconditions:
1343 
1344  require(_subposet_ids.ct() == 0);
1345 
1346  // Body:
1347 
1348 #ifdef DIAGNOSTIC_OUTPUT
1349  cout << "member_record::transfer_member_to_subposet_ids " << endl;
1350 #endif
1351 
1352  // Transfer ids:
1353 
1354  // Iterate over all the subposets except the standard ones;
1355  // whole doesn't need to be stored and jims is in the toc.
1356 
1357  int lsp_min = _poset->standard_subposet_ct();
1358  int lsp_ub = scaffold().subposets().size();
1359 
1360  bool lhas_toc_subposet_ids = false;
1361 
1362  for(pod_index_type i = lsp_min; i<lsp_ub; i++)
1363  {
1364  subposet* lsp = scaffold().subposets()[i];
1365 
1366  if( lsp->contains_member(xmbr_id) )
1367  {
1368  int lsp_bit = i - lsp_min + SUBPOSET_BITS_BEGIN;
1369  if(lsp_bit < SUBPOSET_BITS_END)
1370  {
1371  // Haven't used all the subposet bits in the toc yet.
1372 
1373 #ifdef DIAGNOSTIC_OUTPUT
1374  cout << "\tsetting bit " << lsp_bit
1375  << " subposet id " << lsp->index()
1376  << " name: " << lsp->name() << endl;
1377 #endif
1378 
1379  _toc[lsp_bit] = true;
1380  lhas_toc_subposet_ids = true;
1381  }
1382  else
1383  {
1384  // Out of room in the toc.
1385  // Put subposet id into buffer to be
1386  // written explicitly into record
1387 
1388  _subposet_ids.push_back(i);
1389  }
1390  }
1391  }
1392 
1393  _toc[HAS_TOC_SUBPOSET_IDS] = lhas_toc_subposet_ids;
1394  _toc[HAS_SUBPOSET_IDS] = (_subposet_ids.ct() > 0);
1395 
1396 #ifdef DIAGNOSTIC_OUTPUT
1397  cout << "\t_subposet_ids ct: " << _subposet_ids.ct() << " ids: ";
1398  for(int i=0; i<_subposet_ids.ct(); i++)
1399  {
1400  cout << setw(6) << _subposet_ids[i];
1401  }
1402  cout << endl;
1403  cout << "\ttoc: " << _toc << " = " << _toc.to_ulong() << endl;
1404 #endif
1405 
1406  // Postconditions:
1407 
1408  // Exit
1409 
1410  return;
1411 }
1412 
1414 void
1415 sheaf::member_record::
1416 transfer_member_to_eqv_ids(const scoped_index& xmbr_id)
1417 {
1418  // Preconditions:
1419 
1420  require(_eqv_ids.ct() == 0);
1421  require(has_equivalence_iterator());
1422 
1423  // Body:
1424 
1425 #ifdef DIAGNOSTIC_OUTPUT
1426  cout << "member_record::transfer_member_to_eqv_ids " << endl;
1427 #endif
1428 
1429  // Transfer ids:
1430 
1431  // Iterate over the equivalence class of xmbr_id,
1432  // transferring to internal buffer.
1433  // Invariant of index_space_family ensures internal id
1434  // is always the representative of its equivalence class.
1435 
1436  scoped_index lrep_id(xmbr_id.hub_id());
1437  index_equivalence_iterator& litr = equivalence_iterator(lrep_id);
1438  while(!litr.is_done())
1439  {
1440  index_equivalence_iterator::member_type litem = litr.item();
1441 
1442  _eqv_ids.push_back(litem.first);
1443  _eqv_ids.push_back(litem.second);
1444 
1445  litr.next();
1446  }
1447 
1448  _toc[HAS_EQV_IDS] = (_eqv_ids.ct() > 0);
1449 
1450 #ifdef DIAGNOSTIC_OUTPUT
1451  cout << "\t_eqv_ids ct: " << _eqv_ids.ct() << " ids: ";
1452  for(int i=0; i<_eqv_ids.ct(); i++)
1453  {
1454  cout << setw(6) << _eqv_ids[i];
1455  }
1456  cout << endl;
1457  cout << "\ttoc: " << _toc << " = " << _toc.to_ulong() << endl;
1458 #endif
1459 
1460  // Postconditions:
1461 
1462  // Exit
1463 
1464  return;
1465 }
1466 
1468 void
1469 sheaf::member_record::
1470 transfer_member_to_names(const scoped_index& xmbr_id)
1471 {
1472  // Preconditions:
1473 
1474  require(_names.ct() == 0);
1475 
1476  // Body:
1477 
1478 #ifdef DIAGNOSTIC_OUTPUT
1479  cout << "member_record::transfer_member_to_names " << endl;
1480 #endif
1481 
1482  const scoped_index& lext_id = scaffold().member_ext_id(xmbr_id);
1483 
1484  assertion(lext_id.is_valid());
1485 
1486  // Put all of its names in the name map.
1487 
1488  _poset->all_member_names(xmbr_id, _names);
1489  for(int i=0; i<_names.ct();i++)
1490  {
1491  scaffold().member_name_map().put_entry(lext_id.pod(), _names[i], false);
1492  }
1493 
1494  _names.set_ct(0);
1495 
1496  // Postconditions:
1497 
1498  // Exit
1499 
1500  return;
1501 }
1502 
1504 void
1505 sheaf::member_record::
1506 transfer_interval_to_class_names(const scoped_index& xmbr_id)
1507 {
1508  // Preconditions:
1509 
1510  require(_toc[IS_INTERVAL]);
1511 
1512  // Body:
1513 
1514 #ifdef DIAGNOSTIC_OUTPUT
1515  cout << "member_record::transfer_interval_to_class_names"
1516  << " mbr id: " << xmbr_id
1517  << endl;
1518 #endif
1519 
1520  if(_interval->is_interval_member(xmbr_id))
1521  {
1522  // This is the interval member itself.
1523 
1524  typedef poset_scaffold::member_class_names_type map_type;
1525  typedef map_type::mapped_type mapped_type;
1526  mapped_type lmapped;
1527 
1528  lmapped.first = _interval->class_name();
1529  lmapped.second = _interval->size();
1530 
1531 #ifdef DIAGNOSTIC_OUTPUT
1532  cout << "\tclass name: " << lmapped.first
1533  << " size: " << lmapped.second
1534  << " int id: " << xmbr_id.pod()
1535  << endl;
1536 #endif
1537 
1538  scaffold().member_class_names()[xmbr_id.hub_pod()] = lmapped;
1539  }
1540 
1541 
1542  // Postconditions:
1543 
1544  // Exit
1545 
1546  return;
1547 }
1548 
1549 void
1550 sheaf::member_record::
1551 convert_internal_buffer_to_external_buffer()
1552 {
1553  // Preconditions:
1554 
1555  // Body:
1556 
1557  // Initialize the external buffer from the internal buffer.
1558 
1559  initialize_external_buffer();
1560 
1561  // Externalize all the data fields.
1562 
1563  size_t lnext_field_offset = 0;
1564 
1565  externalize_toc(lnext_field_offset);
1566 
1567  externalize_private_data_ct(lnext_field_offset);
1568  externalize_private_data(lnext_field_offset);
1569 
1570  externalize_dof_tuple_ids_ct(lnext_field_offset);
1571  externalize_dof_tuple_ids(lnext_field_offset);
1572 
1573  externalize_lower_cover_ct(lnext_field_offset);
1574  externalize_lower_cover(lnext_field_offset);
1575 
1576  externalize_upper_cover_ct(lnext_field_offset);
1577  externalize_upper_cover(lnext_field_offset);
1578 
1579  externalize_subposet_ids_ct(lnext_field_offset);
1580  externalize_subposet_ids(lnext_field_offset);
1581 
1582  externalize_eqv_ids(lnext_field_offset);
1583 
1584  // Now the external buffer is valid.
1585 
1586  put_is_external(true);
1587 
1588  // Postconditions:
1589 
1590  ensure(is_external());
1591 
1592  // Exit
1593 
1594  return;
1595 }
1596 
1598 void
1599 sheaf::member_record::
1600 initialize_external_buffer()
1601 {
1602  // Preconditions:
1603 
1604 
1605  // Body:
1606 
1607  // Determine the size of the external buffer.
1608 
1609  _end_offset = 0;
1610 
1611  // Space for toc
1612 
1613  _end_offset += 1;
1614 
1615  // Space for private_data_ct.
1616 
1617  _end_offset += _toc[HAS_PRIVATE_DATA] ? 1 : 0;
1618 
1619  // Space for private data.
1620 
1621  _end_offset += _private_data.ct();
1622 
1623  // Space for dof_tuple_ids_ct.
1624 
1625  _end_offset += _toc[HAS_DOF_TUPLE_IDS] ? 1 : 0;
1626 
1627  // Space for dof tuple ids.
1628 
1629  _end_offset += _dof_tuple_ids.ct();
1630 
1631  // Space for lower_cover_ct
1632 
1633  _end_offset += _toc[HAS_LOWER_COVER] ? 1 : 0;
1634 
1635  // Space for lower_cover
1636 
1637  _end_offset += _lower_cover.ct();
1638 
1639  // Space for upper_cover_ct
1640 
1641  _end_offset += _toc[HAS_UPPER_COVER] ? 1 : 0;
1642 
1643  // Space for upper_cover
1644 
1645  _end_offset += _upper_cover.ct();
1646 
1647  // Space for subposet ids count.
1648 
1649  _end_offset += _toc[HAS_SUBPOSET_IDS] ? 1 : 0;
1650 
1651  // Space for subposet ids.
1652 
1653  _end_offset += _subposet_ids.ct();
1654 
1655  // Space for equivalent ids
1656 
1657  _end_offset += _eqv_ids.ct() ;
1658 
1659  // Allocate the external buffer.
1660  // Buffer will be deleted in member_record_set::delete_external_buffers.
1662 
1663  void* lbuf = new pod_index_type[_end_offset];
1664 
1665  put_buf(lbuf, _end_offset);
1666 
1667  // Buffer will not be deleted in destructor for this.
1668 
1669  put_delete_buffer(false);
1670 
1671  // The external buffer is allocated but not initialized.
1672 
1673  put_is_external(false);
1674 
1675  // Postconditions:
1676 
1677  ensure(!is_external());
1678  ensure(buf() != 0);
1679 
1680  // Exit
1681 
1682  return;
1683 }
1684 
1686 void
1687 sheaf::member_record::
1688 externalize_toc(size_t& xnext_field_offset)
1689 {
1690 
1691  // Preconditions:
1692 
1693  require(is_internal());
1694  require(!type_map().toc_converter()->internal_size_greater());
1695 
1696  // Body:
1697 
1698 #ifdef DIAGNOSTIC_OUTPUT
1699  cout << "\ttoc: " << _toc << " = " << _toc.to_ulong() << endl;
1700 #endif
1701 
1702 
1703  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
1704 
1714 
1715  int_buf()[xnext_field_offset++] = static_cast<int>(_toc.to_ulong());
1716 
1717  // Postconditions:
1718 
1719  ensure(xnext_field_offset == old_xnext_field_offset + 1);
1720  ensure(xnext_field_offset <= buf_ub());
1721 
1722  // Exit
1723 
1724  return;
1725 }
1726 
1728 void
1729 sheaf::member_record::
1730 externalize_private_data_ct(size_t& xnext_field_offset)
1731 {
1732 
1733  // Preconditions:
1734 
1735  require(is_internal());
1736  require(!type_map().dof_tuple_id_converter()->internal_size_greater());
1737 
1738  // Body:
1739 
1740  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
1741 
1742  // Put the dof tuple id ct and the dof tuple ids in the buffer.
1743 
1744  if(_toc[HAS_PRIVATE_DATA])
1745  {
1746  int_buf()[xnext_field_offset++] = _private_data.ct();
1747  }
1748 
1749  // Postconditions:
1750 
1751  ensure(xnext_field_offset >= old_xnext_field_offset);
1752  ensure(xnext_field_offset <= buf_ub());
1753 
1754  // Exit
1755 
1756  return;
1757 }
1758 
1760 void
1761 sheaf::member_record::
1762 externalize_private_data(size_t& xnext_field_offset)
1763 {
1764 
1765  // Preconditions:
1766 
1767  require(is_internal());
1768  require(!type_map().dof_tuple_id_converter()->internal_size_greater());
1769 
1770  // Body:
1771 
1772 #ifdef DIAGNOSTIC_OUTPUT
1773  cout << "\tprivate_data: " << _private_data << endl;
1774 #endif
1775 
1776  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
1777 
1778  // Put the dof tuple id ct and the dof tuple ids in the buffer.
1779 
1780  if(_toc[HAS_PRIVATE_DATA])
1781  {
1782  int lct = _private_data.ct();
1783  for(int i=0; i<lct; ++i)
1784  {
1785  int_buf()[xnext_field_offset++] = _private_data[i];
1786  }
1787  }
1788 
1789  // Postconditions:
1790 
1791  ensure(xnext_field_offset == old_xnext_field_offset + _private_data.ct());
1792  ensure(xnext_field_offset <= buf_ub());
1793 
1794  // Exit
1795 
1796  return;
1797 }
1798 
1800 void
1801 sheaf::member_record::
1802 externalize_dof_tuple_ids_ct(size_t& xnext_field_offset)
1803 {
1804 
1805  // Preconditions:
1806 
1807  require(is_internal());
1808 
1809  // Body:
1810 
1811  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
1812 
1813  // Put the dof tuple id ct and the dof tuple ids in the buffer.
1814 
1815  if(_toc[HAS_DOF_TUPLE_IDS])
1816  {
1817  int_buf()[xnext_field_offset++] = _dof_tuple_ids.ct();
1818  }
1819 
1820  // Postconditions:
1821 
1822  ensure(xnext_field_offset >= old_xnext_field_offset);
1823  ensure(xnext_field_offset <= buf_ub());
1824 
1825  // Exit
1826 
1827  return;
1828 }
1829 
1831 void
1832 sheaf::member_record::
1833 externalize_dof_tuple_ids(size_t& xnext_field_offset)
1834 {
1835 
1836  // Preconditions:
1837 
1838  require(is_internal());
1839  require(!type_map().dof_tuple_id_converter()->internal_size_greater());
1840 
1841  // Body:
1842 
1843 #ifdef DIAGNOSTIC_OUTPUT
1844  cout << "\tdof_tuple_ids: " << _dof_tuple_ids << endl;
1845 #endif
1846 
1847  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
1848 
1849  // Put the dof tuple id ct and the dof tuple ids in the buffer.
1850 
1851  if(_toc[HAS_DOF_TUPLE_IDS])
1852  {
1853  int lct = _dof_tuple_ids.ct();
1854  for(int i=0; i<lct; ++i)
1855  {
1856  int_buf()[xnext_field_offset++] = _dof_tuple_ids[i];
1857  }
1858  }
1859 
1860  // Postconditions:
1861 
1862  ensure(xnext_field_offset == old_xnext_field_offset + _dof_tuple_ids.ct());
1863  ensure(xnext_field_offset <= buf_ub());
1864 
1865  // Exit
1866 
1867  return;
1868 }
1869 
1871 void
1872 sheaf::member_record::
1873 externalize_lower_cover_ct(size_t& xnext_field_offset)
1874 {
1875 
1876  // Preconditions:
1877 
1878  require(is_internal());
1879 
1880  // Body:
1881 
1882  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
1883 
1884  if(_toc[HAS_LOWER_COVER])
1885  {
1886  int_buf()[xnext_field_offset++] = _lower_cover.ct();
1887  }
1888 
1889 
1890  // Postconditions:
1891 
1892  ensure(xnext_field_offset >= old_xnext_field_offset);
1893  ensure(xnext_field_offset <= buf_ub());
1894 
1895  // Exit
1896 
1897  return;
1898 }
1899 
1901 void
1902 sheaf::member_record::
1903 externalize_lower_cover(size_t& xnext_field_offset)
1904 {
1905  // Preconditions:
1906 
1907  require(is_internal());
1908 
1909  // Body:
1910 
1911 #ifdef DIAGNOSTIC_OUTPUT
1912  cout << "\tlower_cover: " << _lower_cover << endl;
1913 #endif
1914 
1915  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
1916 
1917  if(_toc[HAS_LOWER_COVER])
1918  {
1919  int_type lct = _lower_cover.ct();
1920  for(int_type i=0; i<lct; ++i)
1921  {
1922  int_buf()[xnext_field_offset++] = _lower_cover[i];
1923  }
1924  }
1925 
1926  // Postconditions:
1927 
1928  ensure(xnext_field_offset == old_xnext_field_offset + _lower_cover.ct());
1929  ensure(xnext_field_offset <= buf_ub());
1930 
1931  // Exit
1932 
1933  return;
1934 }
1935 
1937 void
1938 sheaf::member_record::
1939 externalize_upper_cover_ct(size_t& xnext_field_offset)
1940 {
1941 
1942  // Preconditions:
1943 
1944  require(is_internal());
1945 
1946  // Body:
1947 
1948  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
1949 
1950  if(_toc[HAS_UPPER_COVER])
1951  {
1952  int_buf()[xnext_field_offset++] = _upper_cover.ct();
1953  }
1954 
1955 
1956  // Postconditions:
1957 
1958  ensure(xnext_field_offset >= old_xnext_field_offset);
1959  ensure(xnext_field_offset <= buf_ub());
1960 
1961  // Exit
1962 
1963  return;
1964 }
1965 
1967 void
1968 sheaf::member_record::
1969 externalize_upper_cover(size_t& xnext_field_offset)
1970 {
1971  // Preconditions:
1972 
1973  require(is_internal());
1974 
1975  // Body:
1976 
1977 #ifdef DIAGNOSTIC_OUTPUT
1978  cout << "\tupper_cover: " << _upper_cover << endl;
1979 #endif
1980 
1981  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
1982 
1983  if(_toc[HAS_UPPER_COVER])
1984  {
1985  int_type lct = _upper_cover.ct();
1986  for(int_type i=0; i<lct; ++i)
1987  {
1988  int_buf()[xnext_field_offset++] = _upper_cover[i];
1989  }
1990  }
1991 
1992  // Postconditions:
1993 
1994  ensure(xnext_field_offset == old_xnext_field_offset + _upper_cover.ct());
1995  ensure(xnext_field_offset <= buf_ub());
1996 
1997  // Exit
1998 
1999  return;
2000 }
2001 
2003 void
2004 sheaf::member_record::
2005 externalize_subposet_ids_ct(size_t& xnext_field_offset)
2006 {
2007 
2008  // Preconditions:
2009 
2010  require(is_internal());
2011 
2012  // Body:
2013 
2014  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
2015 
2016  if(_toc[HAS_SUBPOSET_IDS])
2017  {
2018  int_buf()[xnext_field_offset++] = _subposet_ids.ct();
2019  }
2020 
2021 
2022  // Postconditions:
2023 
2024  ensure(xnext_field_offset >= old_xnext_field_offset);
2025  ensure(xnext_field_offset <= buf_ub());
2026 
2027  // Exit
2028 
2029  return;
2030 }
2031 
2033 void
2034 sheaf::member_record::
2035 externalize_subposet_ids(size_t& xnext_field_offset)
2036 {
2037  // Preconditions:
2038 
2039  require(is_internal());
2040 
2041  // Body:
2042 
2043 #ifdef DIAGNOSTIC_OUTPUT
2044  cout << "\tsubposet_ids: " << _subposet_ids << endl;
2045 #endif
2046 
2047  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
2048 
2049  if(_toc[HAS_SUBPOSET_IDS])
2050  {
2051  int_type lids_ct = _subposet_ids.ct();
2052  for(int_type i=0; i<lids_ct; ++i)
2053  {
2054  int_buf()[xnext_field_offset++] = _subposet_ids[i];
2055  }
2056  }
2057 
2058 
2059  // Postconditions:
2060 
2061  ensure(xnext_field_offset == old_xnext_field_offset + _subposet_ids.ct());
2062  ensure(xnext_field_offset <= buf_ub());
2063 
2064  // Exit
2065 
2066  return;
2067 }
2068 
2070 void
2071 sheaf::member_record::
2072 externalize_eqv_ids(size_t& xnext_field_offset)
2073 {
2074  // Preconditions:
2075 
2076  require(is_internal());
2077 
2078  // Body:
2079 
2080 #ifdef DIAGNOSTIC_OUTPUT
2081  cout << "\teqv_ids: " << _eqv_ids << endl;
2082 #endif
2083 
2084  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
2085 
2086  if(_toc[HAS_EQV_IDS])
2087  {
2088  int_type lct = _eqv_ids.ct();
2089  for(int_type i=0; i<lct; ++i)
2090  {
2091  int_buf()[xnext_field_offset++] = _eqv_ids[i];
2092  }
2093  }
2094 
2095  // Postconditions:
2096 
2097  ensure(xnext_field_offset == old_xnext_field_offset + _eqv_ids.ct());
2098  ensure(xnext_field_offset == buf_ub());
2099 
2100  // Exit
2101 
2102  return;
2103 }
2104 
2106 void
2107 sheaf::member_record::
2108 transfer_external_buffer_to_HDF(hvl_t* xbuf)
2109 {
2110  // Preconditions:
2111 
2112  require(xbuf != 0);
2113  require(is_external());
2114 
2115  // Body:
2116 
2117  xbuf->p = buf();
2118  xbuf->len = buf_ub();
2119 
2120  // Postconditions:
2121 
2122  ensure(xbuf->p == buf());
2123  ensure(xbuf->len == buf_ub());
2124 
2125  // Exit
2126 
2127  return;
2128 }
2129 
2130 // ===========================================================
2131 // READ FACET
2132 // ===========================================================
2133 
2135 void
2137 internalize(hvl_t* xhdf_buffer, const scoped_index& xmbr_id)
2138 {
2139 
2140  // Preconditions:
2141 
2142  require(scaffold().structure().state_is_read_write_accessible());
2143 
2144  // Body:
2145 
2146 #ifdef DIAGNOSTIC_OUTPUT
2147  cout << "member_record::internalize: member: " << xmbr_id << endl;
2148 #endif
2149 
2150  // Map xmbr_id into internal and external scope.
2151 
2152  xmbr_id >> _mbr_id;
2153  xmbr_id >> _ext_id;
2154 
2155  // Initialize poset and interval variables.
2156 
2157  _poset = &scaffold().structure();
2158  _interval = _poset->crg().implicit_member(xmbr_id.hub_pod());
2159 
2160  // Initialize the external buffer from the HDF buffer.
2161 
2162  transfer_HDF_to_external_buffer(xhdf_buffer);
2163 
2164  // Convert the external buffer to internal format
2165  // and place the result in the internal buffer
2166 
2167  convert_external_buffer_to_internal_buffer();
2168 
2169  // Transfer the internal buffer to the member.
2170 
2171  transfer_internal_buffer_to_member(xmbr_id);
2172 
2173  // Postconditions:
2174 
2175  // Exit
2176 
2177  return;
2178 }
2179 
2181 void
2182 sheaf::member_record::
2183 transfer_HDF_to_external_buffer(hvl_t* xbuf)
2184 {
2185  // Preconditions:
2186 
2187  require(xbuf != 0);
2188 
2189  // Body:
2190 
2191  put_buf(xbuf->p, xbuf->len);
2192  _end_offset = xbuf->len;
2193 
2194  put_is_external(true);
2195  put_is_internal(false);
2196 
2197  // Postconditions:
2198 
2199  ensure(buf() == xbuf->p);
2200  ensure(buf_ub() == xbuf->len);
2201  ensure(is_external());
2202  ensure(!is_internal());
2203 
2204  // Exit
2205 
2206  return;
2207 }
2208 
2210 void
2211 sheaf::member_record::
2212 convert_external_buffer_to_internal_buffer()
2213 {
2214  // Preconditions:
2215 
2216  // Body:
2217 
2218  size_t lnext_field_offset = 0;
2219 
2220  // Internalize all the data fields.
2221 
2222  internalize_toc(lnext_field_offset);
2223 
2224  internalize_private_data_ct(lnext_field_offset);
2225  internalize_private_data(lnext_field_offset);
2226 
2227  internalize_dof_tuple_ids_ct(lnext_field_offset);
2228  internalize_dof_tuple_ids(lnext_field_offset);
2229 
2230  internalize_lower_cover_ct(lnext_field_offset);
2231  internalize_lower_cover(lnext_field_offset);
2232 
2233  internalize_upper_cover_ct(lnext_field_offset);
2234  internalize_upper_cover(lnext_field_offset);
2235 
2236  internalize_subposet_ids_ct(lnext_field_offset);
2237  internalize_subposet_ids(lnext_field_offset);
2238 
2239  internalize_eqv_ids(lnext_field_offset);
2240 
2241  // Now the internal buffer is valid.
2242 
2243  put_is_internal(true);
2244 
2245  // Postconditions:
2246 
2247  ensure(is_internal());
2248 
2249  // Exit
2250 
2251  return;
2252 }
2253 
2254 
2256 void
2257 sheaf::member_record::
2258 internalize_toc(size_t& xnext_field_offset)
2259 {
2260  // Preconditions:
2261 
2262  require(is_external());
2263  require(!type_map().toc_converter()->external_size_greater());
2264 
2265  // Body:
2266 
2267  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
2268 
2269  _toc = toc_type(static_cast<unsigned long long>(int_buf()[xnext_field_offset++]));
2270 
2271 #ifdef DIAGNOSTIC_OUTPUT
2272  cout << "\ttoc: " << _toc << " = " << _toc.to_ulong() << endl;
2273 #endif
2274 
2275  // Postconditions:
2276 
2277  ensure(xnext_field_offset == old_xnext_field_offset + 1);
2278  ensure(xnext_field_offset <= buf_ub());
2279 
2280  // Exit
2281 
2282  return;
2283 }
2284 
2285 
2287 void
2288 sheaf::member_record::
2289 internalize_private_data_ct(size_t& xnext_field_offset)
2290 {
2291 
2292  // Preconditions:
2293 
2294  require(is_external());
2295 
2296  // Body:
2297 
2298  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
2299 
2300  if(_toc[HAS_PRIVATE_DATA])
2301  {
2302  pod_index_type lprivate_data_ct = int_buf()[xnext_field_offset++];
2303  _private_data.reserve(lprivate_data_ct);
2304  _private_data.set_ct(lprivate_data_ct);
2305  }
2306  else
2307  {
2308  _private_data.set_ct(0);
2309  }
2310 
2311  // Postconditions:
2312 
2313  ensure(xnext_field_offset >= old_xnext_field_offset);
2314  ensure(xnext_field_offset <= buf_ub());
2315 
2316  // Exit
2317 
2318  return;
2319 }
2320 
2322 void
2323 sheaf::member_record::
2324 internalize_private_data(size_t& xnext_field_offset)
2325 {
2326 
2327  // Preconditions:
2328 
2329  require(is_external());
2330 
2331  // Body:
2332 
2333  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
2334 
2335  if(_toc[HAS_PRIVATE_DATA])
2336  {
2337  int_type lct = _private_data.ct();
2338  for(int i=0; i<lct; ++i)
2339  {
2340  _private_data[i] = int_buf()[xnext_field_offset++];
2341  }
2342  }
2343 
2344 #ifdef DIAGNOSTIC_OUTPUT
2345  cout << "\tprivate_data: " << _private_data << endl;
2346 #endif
2347 
2348  // Postconditions:
2349 
2350  ensure(xnext_field_offset == old_xnext_field_offset + _private_data.ct());
2351  ensure(xnext_field_offset <= buf_ub());
2352 
2353  // Exit
2354 
2355  return;
2356 }
2357 
2359 void
2360 sheaf::member_record::
2361 internalize_dof_tuple_ids_ct(size_t& xnext_field_offset)
2362 {
2363 
2364  // Preconditions:
2365 
2366  require(is_external());
2367 
2368  // Body:
2369 
2370  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
2371 
2372  if(_toc[HAS_DOF_TUPLE_IDS])
2373  {
2374  pod_index_type ldof_tuple_ids_ct = int_buf()[xnext_field_offset++];
2375  _dof_tuple_ids.reserve(ldof_tuple_ids_ct);
2376  _dof_tuple_ids.set_ct(ldof_tuple_ids_ct);
2377  }
2378  else
2379  {
2380  _dof_tuple_ids.set_ct(0);
2381  }
2382 
2383  // Postconditions:
2384 
2385  ensure(xnext_field_offset >= old_xnext_field_offset);
2386  ensure(xnext_field_offset <= buf_ub());
2387 
2388  // Exit
2389 
2390  return;
2391 }
2392 
2394 void
2395 sheaf::member_record::
2396 internalize_dof_tuple_ids(size_t& xnext_field_offset)
2397 {
2398 
2399  // Preconditions:
2400 
2401  require(is_external());
2402 
2403  // Body:
2404 
2405  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
2406 
2407  if(_toc[HAS_DOF_TUPLE_IDS])
2408  {
2409  int_type lct = _dof_tuple_ids.ct();
2410  for(int i=0; i<lct; ++i)
2411  {
2412  _dof_tuple_ids[i] = int_buf()[xnext_field_offset++];
2413  }
2414  }
2415 
2416 #ifdef DIAGNOSTIC_OUTPUT
2417  cout << "\tdof_tuple_ids: " << _dof_tuple_ids << endl;
2418 #endif
2419 
2420  // Postconditions:
2421 
2422  ensure(xnext_field_offset == old_xnext_field_offset + _dof_tuple_ids.ct());
2423  ensure(xnext_field_offset <= buf_ub());
2424 
2425  // Exit
2426 
2427  return;
2428 }
2429 
2431 void
2432 sheaf::member_record::
2433 internalize_lower_cover_ct(size_t& xnext_field_offset)
2434 {
2435  // Preconditions:
2436 
2437  require(is_external());
2438 
2439  // Body:
2440 
2441  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
2442 
2443  if(_toc[HAS_LOWER_COVER])
2444  {
2445  int llower_cover_ct = int_buf()[xnext_field_offset++];
2446  _lower_cover.reserve(llower_cover_ct);
2447  _lower_cover.set_ct(llower_cover_ct);
2448  }
2449  else
2450  {
2451  _lower_cover.set_ct(0);
2452  }
2453 
2454  // Postconditions:
2455 
2456  ensure(xnext_field_offset >= old_xnext_field_offset);
2457  ensure(xnext_field_offset <= buf_ub());
2458 
2459  // Exit
2460 
2461  return;
2462 }
2463 
2464 
2466 void
2467 sheaf::member_record::
2468 internalize_lower_cover(size_t& xnext_field_offset)
2469 {
2470  // Preconditions:
2471 
2472  require(is_external());
2473  require(unexecutable(_lower_cover_ct is internal));
2474 
2475  // Body:
2476 
2477  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
2478 
2479  if(_toc[HAS_LOWER_COVER])
2480  {
2481  int_type lct = _lower_cover.ct();
2482  for(int_type i=0; i<lct; ++i)
2483  {
2484  _lower_cover[i] = int_buf()[xnext_field_offset++];
2485  }
2486  }
2487 
2488 #ifdef DIAGNOSTIC_OUTPUT
2489  cout << "\tlower_cover: " << _lower_cover << endl;
2490 #endif
2491 
2492  // Postconditions:
2493 
2494  ensure(xnext_field_offset == old_xnext_field_offset + _lower_cover.ct());
2495  ensure(xnext_field_offset <= buf_ub());
2496 
2497  // Exit
2498 
2499  return;
2500 }
2501 
2502 
2504 void
2505 sheaf::member_record::
2506 internalize_upper_cover_ct(size_t& xnext_field_offset)
2507 {
2508  // Preconditions:
2509 
2510  require(is_external());
2511 
2512  // Body:
2513 
2514  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
2515 
2516  if(_toc[HAS_UPPER_COVER])
2517  {
2518  int lupper_cover_ct = int_buf()[xnext_field_offset++];
2519  _upper_cover.reserve(lupper_cover_ct);
2520  _upper_cover.set_ct(lupper_cover_ct);
2521  }
2522  else
2523  {
2524  _upper_cover.set_ct(0);
2525  }
2526 
2527  // Postconditions:
2528 
2529  ensure(xnext_field_offset >= old_xnext_field_offset);
2530  ensure(xnext_field_offset <= buf_ub());
2531 
2532  // Exit
2533 
2534  return;
2535 }
2536 
2537 
2539 void
2540 sheaf::member_record::
2541 internalize_upper_cover(size_t& xnext_field_offset)
2542 {
2543  // Preconditions:
2544 
2545  require(is_external());
2546  require(unexecutable(_upper_cover_ct is internal));
2547 
2548  // Body:
2549 
2550  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
2551 
2552  if(_toc[HAS_UPPER_COVER])
2553  {
2554  int_type lct = _upper_cover.ct();
2555  for(int_type i=0; i<lct; ++i)
2556  {
2557  _upper_cover[i] = int_buf()[xnext_field_offset++];
2558  }
2559  }
2560 
2561 #ifdef DIAGNOSTIC_OUTPUT
2562  cout << "\tupper_cover: " << _upper_cover << endl;
2563 #endif
2564 
2565  // Postconditions:
2566 
2567  ensure(xnext_field_offset == old_xnext_field_offset + _upper_cover.ct());
2568  ensure(xnext_field_offset <= buf_ub());
2569 
2570  // Exit
2571 
2572  return;
2573 }
2574 
2575 
2577 void
2578 sheaf::member_record::
2579 internalize_subposet_ids_ct(size_t& xnext_field_offset)
2580 {
2581 
2582  // Preconditions:
2583 
2584  require(is_external());
2585  require(xnext_field_offset <= buf_ub());
2586 
2587  // Body:
2588 
2589  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
2590 
2591  if(_toc[HAS_SUBPOSET_IDS])
2592  {
2593  int lsubposet_ids_ct = int_buf()[xnext_field_offset++];
2594  _subposet_ids.reserve(lsubposet_ids_ct);
2595  _subposet_ids.set_ct(lsubposet_ids_ct);
2596  }
2597  else
2598  {
2599  _subposet_ids.set_ct(0);
2600  }
2601 
2602 
2603  // Postconditions:
2604 
2605  ensure(xnext_field_offset >= old_xnext_field_offset);
2606  ensure(xnext_field_offset <= buf_ub());
2607 
2608  // Exit
2609 
2610  return;
2611 }
2612 
2613 
2614 
2616 void
2617 sheaf::member_record::
2618 internalize_subposet_ids(size_t& xnext_field_offset)
2619 {
2620  // Preconditions:
2621 
2622  require(is_external());
2623  require(xnext_field_offset <= buf_ub());
2624 
2625  // Body:
2626 
2627  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
2628 
2629  if(_toc[HAS_SUBPOSET_IDS])
2630  {
2631  size_t lids_ct = _subposet_ids.ct();
2632  for(size_t i=0; i< lids_ct; ++i)
2633  {
2634  _subposet_ids[i] = int_buf()[xnext_field_offset++];
2635  }
2636  }
2637 
2638 #ifdef DIAGNOSTIC_OUTPUT
2639  cout << "\tsubposet_ids: " << _subposet_ids << endl;
2640 #endif
2641 
2642  // Postconditions:
2643 
2644  ensure(xnext_field_offset == old_xnext_field_offset + _subposet_ids.ct());
2645  ensure(xnext_field_offset <= buf_ub());
2646 
2647  // Exit
2648 
2649  return;
2650 }
2651 
2652 
2653 
2655 void
2656 sheaf::member_record::
2657 internalize_eqv_ids(size_t& xnext_field_offset)
2658 {
2659  // Preconditions:
2660 
2661  require(is_external());
2662  require(xnext_field_offset <= buf_ub());
2663 
2664  // Body:
2665 
2666  define_old_variable(size_t old_xnext_field_offset = xnext_field_offset);
2667 
2668  if(_toc[HAS_EQV_IDS])
2669  {
2670  // Compute the count.
2671 
2672  size_t lct = _end_offset - xnext_field_offset;
2673 
2674  _eqv_ids.reserve(lct);
2675  _eqv_ids.set_ct(lct);
2676  for(size_t i=0; i<lct; ++i)
2677  {
2678  _eqv_ids[i] = int_buf()[xnext_field_offset++];
2679  }
2680  }
2681  else
2682  {
2683  _eqv_ids.set_ct(0);
2684  }
2685 
2686 
2687 #ifdef DIAGNOSTIC_OUTPUT
2688  cout << "\teqv_ids: " << _eqv_ids << endl;
2689 #endif
2690 
2691  // Postconditions:
2692 
2693  ensure(xnext_field_offset == old_xnext_field_offset + _eqv_ids.ct());
2694  ensure(xnext_field_offset == buf_ub());
2695 
2696  // Exit
2697 
2698  return;
2699 }
2700 
2702 void
2703 sheaf::member_record::
2704 transfer_internal_buffer_to_member(const scoped_index& xmbr_id)
2705 {
2706  // Preconditions:
2707 
2708  require(scaffold().structure().state_is_read_write_accessible());
2709 
2710  // Body:
2711 
2712  // Transfer toc.
2713 
2714  transfer_toc_to_member(xmbr_id);
2715 
2716  if(_toc[IS_INTERVAL])
2717  {
2718  if(xmbr_id.pod() >= _poset->standard_member_ct())
2719  {
2720  // Transfer private data, id map data, and dof tuple ids.
2721 
2722  transfer_private_data_to_interval(xmbr_id);
2723 
2724  transfer_dof_tuple_ids_to_interval(xmbr_id);
2725 
2726  if(_interval->is_interval_member(xmbr_id))
2727  {
2728  // Finalize the initialization.
2729 
2730  _interval->finalize(*_poset);
2731  }
2732  }
2733  else
2734  {
2735  // The interval is a standard member. Nothing to do, it has
2736  // already been initialized.
2737  }
2738  }
2739  else
2740  {
2741  // Just transfer dof tuple ids.
2742 
2743  transfer_dof_tuple_ids_to_member(xmbr_id);
2744  }
2745 
2746  // Transfer equivalent ids.
2747 
2748  transfer_eqv_ids_to_member(xmbr_id);
2749 
2750  // Transfer subposet ids;
2751  // must process subposets ids before lower cover
2752  // so we can test for lower bound.
2753 
2754  transfer_subposet_ids_to_member(xmbr_id);
2755 
2756  // Transfer the upper cover.
2757 
2758  transfer_upper_cover_to_member(xmbr_id);
2759 
2760  // Transfer the lower cover.
2761 
2762  poset_bounds& lrow_bounds = scaffold().row_bounds();
2763 
2764  if(lrow_bounds.bounded_below() &&
2765  _poset->bound_contains_member(lrow_bounds, false, xmbr_id))
2766  {
2767  // The current member is on the lower bound.
2768  // Truncate descent by not transferring links.
2769  // Member will be linked to bottom by ensure_lattice_invariant() const
2770  // called from end_jim_edit_mode().
2771  // Links are still external, so leave member not resident
2772 
2773  _is_resident = false;
2774  }
2775  else
2776  {
2777  // The current member is above the lower bound.
2778  // Transfer lower cover into member and continue descent.
2779 
2780  transfer_lower_cover_to_member(xmbr_id);
2781  _is_resident = true;
2782  }
2783 
2784  // Names.
2785  // Names now transferred directly by storage agent::begin_read_transaction
2786  // using poset_scaffold::get_member_names_from_poset.
2787 
2788  // transfer_names_to_member(xmbr_id);
2789 
2790  // Postconditions:
2791 
2792  // Exit
2793 
2794  return;
2795 }
2796 
2798 void
2799 sheaf::member_record::
2800 transfer_toc_to_member(const scoped_index& xmbr_id)
2801 {
2802  // Preconditions:
2803 
2804  // Body:
2805 
2806 #ifdef DIAGNOSTIC_OUTPUT
2807  cout << "member_record::transfer_toc_to_member" << endl;
2808  cout << "\ttoc: " << _toc << " = " << _toc.to_ulong() << endl;
2809 #endif
2810 
2811  // Is_jim and Dof tuple id:
2812 
2813  if( xmbr_id.pod() >= _poset->standard_member_ct() )
2814  {
2815  // The current member is not a standard member;
2816  // process _toc.is_jim() and _dof_tuple_id.
2817 
2818  if(_toc[IS_JIM])
2819  {
2820  // The current member is a jim;
2821  // insert it in the jims subposet.
2822 
2823  _poset->jims().insert_member(xmbr_id);
2824  }
2825  else
2826  {
2827  // The current member is a jrm.
2828 
2829  // Note that a member in memory with down set on disk is a jim
2830  // until its down set is read in and it becomes a jrm.
2831 
2832  // Make sure the current member is a jrm,
2833  // remove it from the jims subposet;
2834  // won't hurt if it isn't in it.
2835 
2836  _poset->jims().remove_member(xmbr_id);
2837  }
2838  }
2839  else
2840  {
2841  // The current member is a standard member and
2842  // it's jim status is already set; do nothing.
2843  }
2844 
2845  // Postconditions:
2846 
2847  // Exit
2848 
2849  return;
2850 }
2851 
2853 void
2854 sheaf::member_record::
2855 transfer_private_data_to_interval(const scoped_index& xmbr_id)
2856 {
2857  // Preconditions:
2858 
2859  require(scaffold().structure().crg().implicit_member(xmbr_id.hub_pod()) != 0);
2860 
2861  // Body:
2862 
2863 #ifdef DIAGNOSTIC_OUTPUT
2864  cout << "member_record::transfer_private_data_to_interval " << endl;
2865  cout << "\txmbr_id: " << xmbr_id << endl;
2866  cout << "\t_private_data ct: " << _private_data.ct() << " ids: ";
2867  for(int i=0; i<_private_data.ct(); i++)
2868  {
2869  cout << setw(6) << _private_data[i];
2870  }
2871  cout << endl;
2872 #endif
2873 
2874  if(_interval->is_interval_member(xmbr_id))
2875  {
2876  _interval->put_private_data(_private_data);
2877  }
2878 
2879  // Postconditions:
2880 
2881  // Exit
2882 
2883  return;
2884 }
2885 
2887 void
2888 sheaf::member_record::
2889 transfer_dof_tuple_ids_to_interval(const scoped_index& xmbr_id)
2890 {
2891  // Preconditions:
2892 
2893  require(scaffold().structure().crg().implicit_member(xmbr_id.hub_pod()) != 0);
2894 
2895  // Body:
2896 
2897 #ifdef DIAGNOSTIC_OUTPUT
2898  cout << "member_record::transfer_dof_tuple_id_to_interval " << endl;
2899 #endif
2900 
2901  // Get some convenient references
2902 
2903  interval_index_space_handle& ldof_tuple_space =
2905 
2906  pod_index_type lint_dof_tuple_pod;
2907 
2908  // Dof tuple ids.
2909 
2910  int ldof_tuple_ct = _dof_tuple_ids.ct();
2911 
2912  if(_interval->is_interval_member(xmbr_id))
2913  {
2914  // Translate external ids to internal ids.
2915 
2916  block<pod_index_type> ldof_tuple_ids;
2917  ldof_tuple_ids.reserve(ldof_tuple_ct);
2918  ldof_tuple_ids.set_ct(ldof_tuple_ct);
2919 
2920  for(int i=0; i<_dof_tuple_ids.ct(); ++i)
2921  {
2922  pod_index_type lext_dof_tuple_id = _dof_tuple_ids[i];
2923 
2924  scoped_index ldof_tuple_id(ldof_tuple_space, lext_dof_tuple_id);
2925 
2926  if(!ldof_tuple_id.in_scope())
2927  {
2928  // This is the first time we've encountered this dof tuple id,
2929  // create the dof tuple.
2930 
2931  ldof_tuple_id = new_row_dof_tuple(lext_dof_tuple_id);
2932 
2933  // Put it in the map and in the read queue.
2934 
2935  ldof_tuple_space.insert(lext_dof_tuple_id, ldof_tuple_id);
2936 
2937  host().dof_tuple_records().queue().enqueue(lext_dof_tuple_id);
2938  }
2939 
2940  // Put the internal dof tuple id back into _dof_tuple_ids.
2941 
2942  ldof_tuple_ids[i] = ldof_tuple_id.hub_pod();
2943  }
2944 
2945  // Initialize the dof tuple ids in the interval.
2946 
2947  _interval->initialize_dof_tuple_ids(ldof_tuple_ids);
2948  }
2949 
2950 
2951  // Postconditions:
2952 
2953  // Exit
2954 
2955  return;
2956 }
2957 
2958 
2960 void
2961 sheaf::member_record::
2962 transfer_dof_tuple_ids_to_member(const scoped_index& xmbr_id)
2963 {
2964  // Preconditions:
2965 
2966  // Body:
2967 
2968 #ifdef DIAGNOSTIC_OUTPUT
2969  cout << "member_record::transfer_dof_tuple_ids_to_member " << endl;
2970 #endif
2971 
2972  // Get some convenient references
2973 
2974  interval_index_space_handle& ldof_tuple_space =
2976 
2977  if( xmbr_id.pod() >= _poset->standard_member_ct() )
2978  {
2979  // The current member is not a standard member.
2980 
2981  // A member can have a dof tuple whether or not it is considered
2982  // a jim in the current version. _dof_tuple_id contains the
2983  // external dof tuple id in internal format.
2984 
2985  if(_dof_tuple_ids.ct() > 0)
2986  {
2987  // This member has a dof tuple; get the scoped id.
2988 
2989  scoped_index ldof_tuple_id(ldof_tuple_space, _dof_tuple_ids[0]);
2990 
2991  if(!ldof_tuple_id.in_scope())
2992  {
2993  // This is the first time we've encountered this dof tuple id,
2994  // create the dof tuple.
2995 
2996  ldof_tuple_id = new_row_dof_tuple(_dof_tuple_ids[0]);
2997 
2998  if(scaffold().external_schema().index() == BOTTOM_INDEX)
2999  {
3000  // External dof tuple is empty.
3001  // Don't put emtpy id in read queue - nothing to read.
3002 
3003  if( scaffold().structure().schema().index() == BOTTOM_INDEX)
3004  {
3005  // Internal dof tuple is also empty.
3006  // Every member should share the unique empty dof map.
3007  // Since external dof tuple ids all == empty id
3008  // putting empty id in the map will ensure shared map.
3009 
3010  ldof_tuple_space.insert(_dof_tuple_ids[0], ldof_tuple_id);
3011  }
3012  else
3013  {
3014  // Internal dof map is not empty.
3015  // Every member should have its own dof map.
3016  // Don't put empty id in map; empty id will
3017  // always be treated as not previously seen
3018  // and a new dof map will be created.
3019  }
3020  }
3021  else
3022  {
3023  // External dof tuple is not empty.
3024  // Put it in the map and in the read queue.
3025 
3028 
3029  ldof_tuple_space.insert(_dof_tuple_ids[0], ldof_tuple_id);
3030 
3031 #ifdef DIAGNOSTIC_OUTPUT
3032  cout << "\tqueuing dof tuple id: " << ldof_tuple_id << endl;
3033 #endif
3034 
3035  host().dof_tuple_records().queue().enqueue(_dof_tuple_ids[0]);
3036  }
3037  }
3038 
3039  // Set the dof tuple into the member.
3040 
3041  _poset->put_member_dof_tuple_id(xmbr_id, ldof_tuple_id, false);
3042 
3043 #ifdef DIAGNOSTIC_OUTPUT
3044  cout << "\tsetting dof tuple id for member: " << xmbr_id.hub_pod()
3045  << " to " << ldof_tuple_id.hub_pod()
3046  << endl;
3047 #endif
3048  }
3049  }
3050  else
3051  {
3052  // The current member is a standard member
3053  // and it's dof tuple id is already set;
3054  // do nothing.
3055  }
3056 
3057 
3058 
3059  // Postconditions:
3060 
3061  // Exit
3062 
3063  return;
3064 }
3065 
3066 const sheaf::scoped_index&
3067 sheaf::member_record::
3068 new_row_dof_tuple(pod_index_type xext_dof_tuple_pod)
3069 {
3070  // Preconditions:
3071 
3072  require(scaffold().structure().state_is_read_write_accessible());
3073  require(scaffold().dof_tuple_types().find(xext_dof_tuple_pod) !=
3074  scaffold().dof_tuple_types().end());
3075  require(scaffold().dof_tuple_class_names().find(xext_dof_tuple_pod) !=
3076  scaffold().dof_tuple_class_names().end());
3077  require(scaffold().dof_tuple_schema_ids().find(xext_dof_tuple_pod) !=
3078  scaffold().dof_tuple_schema_ids().end());
3079  require(scaffold().dof_tuple_schema_versions().find(xext_dof_tuple_pod) !=
3080  scaffold().dof_tuple_schema_versions().end());
3081 
3082 
3083  // Body:
3084 
3085 #ifdef DIAGNOSTIC_OUTPUT
3086  cout << "member_record::new_row_dof_tuple " << endl;
3087 #endif
3088 
3089  define_old_variable(int old_row_dof_tuple_ct = scaffold().structure().row_dof_tuple_ct());
3090 
3091  // poset_state_handle* lposet = &(scaffold().structure());
3092 
3093  // Get the dof tuple type.
3094  // The dof tuple type map was populated when the dof_tuple_types record
3095  // in the attributes record set was read. It must contain an entry for xext_dof_tuple_pod.
3096 
3097  dof_tuple_type ltype_id = scaffold().dof_tuple_types().find(xext_dof_tuple_pod)->second;
3098 
3099  // Get the dof tuple class names.
3100 
3101  string lclass_name =
3102  scaffold().dof_tuple_class_names().find(xext_dof_tuple_pod)->second;
3103 
3104  // Get the dof tuple schema internal id.
3105 
3106  pod_index_type lschema_int_id =
3107  scaffold().dof_tuple_schema_int_id(xext_dof_tuple_pod);
3108 
3109  // Get the dof tuple schema version
3110 
3111  int lschema_ver = scaffold().dof_tuple_schema_version(xext_dof_tuple_pod);
3112 
3113 
3114 #ifdef DIAGNOSTIC_OUTPUT
3115  cout << "\tclass name= " << lclass_name
3116  << " schema id= " << lschema_int_id
3117  << " schema version= " << lschema_ver
3118  << endl;
3119 #endif
3120 
3125 
3134 
3135  schema_poset_member& lposet_schema = _poset->schema();
3136  pod_index_type ltuple_schema_id;
3137  if(lposet_schema.ge(lschema_int_id))
3138  {
3139  // External schema is less than internal schema,
3140  // use external schema.
3141 
3142  ltuple_schema_id = lschema_int_id;
3143  }
3144  else if(lposet_schema.le(lschema_int_id))
3145  {
3146  // Internal schema is less than external schema;
3147  // use internal schema.
3148 
3149  ltuple_schema_id = lposet_schema.index().pod();
3150  }
3151  else
3152  {
3153  // Internal and external schema are incomparable;
3154  // We can't handle this case currently.
3155 
3156  post_fatal_error_message("Incomparable internal and external schema not supported.");
3157  }
3158 
3159  // Create a dof map of the proper type and initialize it..
3160 
3161  poset_dof_map* lmap = poset_dof_map::new_dof_map(lclass_name, ltype_id);
3162  lmap->init_row_dof_map(_poset, ltuple_schema_id, lschema_ver);
3163 
3164  // Must have created a dof tuple by now.
3165 
3166  assertion(lmap != 0);
3167 
3168  // Insert the dof tuple in the poset state.
3169 
3171 
3172  const scoped_index& result = lmap->index();
3173 
3174  // Postconditions:
3175 
3176  ensure(scaffold().structure().row_dof_tuple_ct() == old_row_dof_tuple_ct+1);
3177  ensure(scaffold().structure().contains_row_dof_tuple(result));
3178 
3179  // Exit
3180 
3181  return result;
3182 }
3183 
3184 
3186 void
3187 sheaf::member_record::
3188 transfer_lower_cover_to_member(const scoped_index& xmbr_id)
3189 {
3190  // Preconditions:
3191 
3192  // Body:
3193 
3194 #ifdef DIAGNOSTIC_OUTPUT
3195  cout << "member_record::transfer_lower_cover_to_member" << endl;
3196  cout << "\tmbr: " << xmbr_id << " lower_cover ct: " << _lower_cover.ct() << endl;
3197 #endif
3198 
3199  if(_lower_cover.ct() > 0)
3200  {
3201  pod_index_type lmbr_id = xmbr_id.hub_pod();
3202 
3203  // This record specifies an explicit cover set;
3204  // it should replace any temporary or implicit lower
3205  // cover the member already has.
3206 
3207  // Get some convenient references
3208 
3209  poset_crg_state& lcrg = _poset->crg();
3210  pod_index_type lint_lesser;
3211 
3212  // Force the cover set for xmbr_id to be explicit and empty.
3213 
3214  _poset->crg().clear_cover(LOWER, lmbr_id);
3215 
3216  // Transfer the lower cover from the record into the member.
3217 
3218  for(int i=0; i<_lower_cover.ct(); i++)
3219  {
3220  // Get the internal id of the lesser end of link;
3221 
3222  lint_lesser = _lower_cover[i];
3223 
3224  if(!lcrg.contains_member(lint_lesser))
3225  {
3226  // The lesser member has not yet been created;
3227  // create it and enter it into the index map.
3228 
3229  new_member(lint_lesser);
3230  }
3231 
3232  _poset->crg().insert_cover_member(lint_lesser, LOWER, lmbr_id);
3233 
3234 #ifdef DIAGNOSTIC_OUTPUT
3235  cout << "\tinserted: " << lint_lesser << " in lower cover of: " << xmbr_id << endl;
3236 #endif
3237 
3238  if(lint_lesser == BOTTOM_INDEX)
3239  {
3240  // Add xmbr_id to the upper cover of bottom.
3241 
3242  _poset->crg().insert_cover_member(lmbr_id, UPPER, BOTTOM_INDEX);
3243  }
3244 
3245  } // end for
3246  } // end if
3247 
3248  // Postconditions:
3249 
3250  // Exit
3251 
3252  return;
3253 }
3254 
3255 
3257 void
3258 sheaf::member_record::
3259 transfer_upper_cover_to_member(const scoped_index& xmbr_id)
3260 {
3261  // Preconditions:
3262 
3263  // Body:
3264 
3265 #ifdef DIAGNOSTIC_OUTPUT
3266  cout << "member_record::transfer_upper_cover_to_member" << endl;
3267  cout << "\tmbr: " << xmbr_id << " upper_cover ct: " << _upper_cover.ct() << endl;
3268 #endif
3269 
3270  if(_upper_cover.ct() > 0)
3271  {
3272  pod_index_type lmbr_id = xmbr_id.hub_pod();
3273 
3274  // This record specifies an explicit cover set;
3275  // it should replace any temporary or implicit upper
3276  // cover the member already has.
3277 
3278  // Force the cover set for xmbr_id to be explicit and empty.
3279 
3280  _poset->crg().clear_cover(UPPER, lmbr_id);
3281 
3282  // Transfer the upper cover from the record into the member.
3283 
3284  for(int i=0; i<_upper_cover.ct(); i++)
3285  {
3286  // Insert the internal id in the cover.
3287 
3288  _poset->crg().insert_cover_member(_upper_cover[i], UPPER, lmbr_id);
3289 
3290 #ifdef DIAGNOSTIC_OUTPUT
3291  cout << "\tinserted: " << _upper_cover[i] << " in upper cover of: " << xmbr_id << endl;
3292 #endif
3293 
3294  } // end for
3295  } // end if
3296 
3297  // Postconditions:
3298 
3299  // Exit
3300 
3301  return;
3302 }
3303 
3304 void
3305 sheaf::member_record::
3306 new_member(pod_index_type xmbr_id)
3307 {
3308  // Preconditions:
3309 
3310  require(scaffold().structure().in_jim_edit_mode());
3311 
3312  // Body:
3313 
3314 #ifdef DIAGNOSTIC_OUTPUT
3315  cout << "\tmember_record::new_member id: " << xmbr_id << endl;
3316 #endif
3317 
3318  define_old_variable(int old_member_ct = scaffold().structure().member_ct());
3319 
3320  // Get the member class name and parameters.
3321 
3322  typedef poset_scaffold::member_class_names_type class_names_type;
3323  typedef class_names_type::const_iterator itr_type;
3324 
3325  class_names_type& lclass_names = scaffold().member_class_names();
3326  itr_type litr = lclass_names.find(xmbr_id);
3327 
3328  if(litr != lclass_names.end())
3329  {
3330  // Member is a interval member, create the proper type.
3331 
3332 #ifdef DIAGNOSTIC_OUTPUT
3333  cout << "\tcreating interval member" << endl
3334  << "\tmbr_id= " << xmbr_id
3335  << "\tclass name= " << litr->second.first
3336  << "\tsize: " << litr->second.second
3337  << endl;
3338 #endif
3339 
3340  _poset->new_member_interval(xmbr_id, litr->second.first, litr->second.second);
3341  }
3342  else
3343  {
3344  // Member is an ordinary, explicit member, no member object.
3345  // Create it as a jrm; will make it into a jim, if needed,
3346  // when we process its member record.
3347 
3348 #ifdef DIAGNOSTIC_OUTPUT
3349  cout << "\tcreating ordinary member" << endl;
3350 #endif
3351 
3352  _poset->new_member(xmbr_id, false, 0, false);
3353  }
3354 
3355  // Postconditions:
3356 
3357  ensure(scaffold().structure().member_ct() > old_member_ct);
3358  ensure(scaffold().structure().contains_member(xmbr_id));
3359 
3360  // Exit
3361 
3362  return;
3363 }
3364 
3366 void
3367 sheaf::member_record::
3368 transfer_subposet_ids_to_member(const scoped_index& xmbr_id)
3369 {
3370  // Preconditions:
3371 
3372  // Body:
3373 
3374 #ifdef DIAGNOSTIC_OUTPUT
3375  cout << "member_record::transfer_subposet_ids_to_member" << endl;
3376 #endif
3377 
3378  // Get some convenient references
3379 
3380  int lsp_min = _poset->standard_subposet_ct();
3381 
3382  // Transfer ids stored as bits in toc.
3383 
3384  for(int i=SUBPOSET_BITS_BEGIN; i< SUBPOSET_BITS_END; ++i)
3385  {
3386  if(_toc[i])
3387  {
3388  pod_index_type lsp_id = i - SUBPOSET_BITS_BEGIN + lsp_min;
3389 
3390  subposet* lsp = scaffold().subposets()[lsp_id];
3391 
3392 #ifdef DIAGNOSTIC_OUTPUT
3393  cout << "\tgetting bit " << i
3394  << " subposet id " << lsp->index()
3395  << " name: " << lsp->name() << endl;
3396 #endif
3397 
3398  lsp->insert_member(xmbr_id);
3399  }
3400  }
3401 
3402  // Transfer ids stored explicit in record:
3403 
3404  for(int i = 0; i<_subposet_ids.ct(); i++)
3405  {
3406 
3407 #ifdef DIAGNOSTIC_OUTPUT
3408  cout << "\ti: " << i << " sp_id: " << _subposet_ids[i] << endl;
3409 #endif
3410 
3411  subposet* lsp = scaffold().subposets()[_subposet_ids[i]];
3412  lsp->insert_member(xmbr_id);
3413  }
3414 
3415  // Postconditions:
3416 
3417  // Exit
3418 
3419  return;
3420 }
3421 
3423 void
3424 sheaf::member_record::
3425 transfer_eqv_ids_to_member(const scoped_index& xmbr_id)
3426 {
3427  // Preconditions:
3428 
3429  // Body:
3430 
3431 #ifdef DIAGNOSTIC_OUTPUT
3432  cout << "member_record::transfer_eqv_ids_to_member" << endl;
3433 #endif
3434 
3435  // Transfer ids:
3436 
3437 #ifdef DIAGNOSTIC_OUTPUT
3438  cout << "\tmbr: " << xmbr_id
3439  << " eqv_ids.ct: " << _eqv_ids.ct() << endl;
3440 #endif
3441 
3442 
3443  for(int i = 0; i<_eqv_ids.ct(); i+=2)
3444  {
3445  scattered_insertion_index_space_handle* lid_space = scaffold().id_spaces()[_eqv_ids[i]];
3446  pod_index_type lext_id = _eqv_ids[i+1];
3447  pod_index_type lint_id = xmbr_id.hub_pod();
3448 
3454 
3456 
3462 
3463  if(!lid_space->contains(lext_id, lint_id))
3464  {
3465  // Map does not contain the entry; enter it now.
3466 
3467 #ifdef DIAGNOSTIC_OUTPUT
3468  cout << "\ti: " << i
3469  << " internal id: " << lint_id
3470  << " external id: " << lext_id
3471  << " ... making entry in map."
3472  << endl;
3473 #endif
3474 
3475  lid_space->insert(lext_id, lint_id);
3476  }
3477  else
3478  {
3479  // Map already contains the entry; do nothing.
3480 
3481 #ifdef DIAGNOSTIC_OUTPUT
3482  cout << "\ti: " << i
3483  << " internal id: " << lint_id
3484  << " external id: " << lext_id
3485  << " ... entry already exists, skipping."
3486  << endl;
3487 #endif
3488 
3489  }
3490  }
3491 
3492  // Postconditions:
3493 
3494  // Exit
3495 
3496  return;
3497 }
3498 
3500 void
3501 sheaf::member_record::
3502 transfer_names_to_member(const scoped_index& xmbr_id)
3503 {
3504  // Preconditions:
3505 
3506  // Body:
3507 
3508  const scoped_index& lext_id = scaffold().member_ext_id(xmbr_id);
3509 
3510  assertion(lext_id.is_valid());
3511 
3512 #ifdef DIAGNOSTIC_OUTPUT
3513  cout << "names for member ext id: " << lext_id << " int id: " << xmbr_id << ":" << endl;
3514 #endif
3515 
3516  // Set its names, if it has any.
3517 
3518  typedef poset_scaffold::member_name_map_type member_name_map_type;
3519  typedef member_name_map_type::name_list_type name_list_type;
3520  typedef member_name_map_type::const_name_iterator itr_type;
3521 
3522  member_name_map_type& lname_map = scaffold().member_name_map();
3523  name_list_type lname_list = lname_map.all_names(lext_id.pod());
3524 
3525  for(itr_type lname_itr = lname_list.begin(); lname_itr != lname_list.end(); ++lname_itr)
3526  {
3527 
3528 #ifdef DIAGNOSTIC_OUTPUT
3529  cout << "\t" << *lname_itr << endl;
3530 #endif
3531 
3532  if(!_poset->member_has_name(xmbr_id, *lname_itr))
3533  {
3534  _poset->put_member_name(xmbr_id, *lname_itr, false, false);
3535  }
3536  }
3537 
3538  // Postconditions:
3539 
3540  // Exit
3541 
3542  return;
3543 }
3544 
3545 
3546 
3547 
3548 // ===========================================================
3549 // ANY FACET
3550 // ===========================================================
3551 
3552 
3556 clone() const
3557 {
3558  member_record* result;
3559 
3560  // Preconditions:
3561 
3562  // Body:
3563 
3564  result = new member_record(*this);
3565 
3566  // Postconditions:
3567 
3568  ensure(result != 0);
3569  ensure(is_same_type(result));
3570 
3571  // Exit:
3572 
3573  return result;
3574 }
3575 
3577 bool
3579 invariant() const
3580 {
3581  bool result = true;
3582 
3583  // Preconditions:
3584 
3585  // Body:
3586 
3587  // Must satisfy base class invariant
3588 
3589  result = result && variable_length_record::invariant();
3590 
3591  if(invariant_check())
3592  {
3593  // Prevent recursive calls to invariant
3594 
3596 
3597  // Finished, turn invariant checking back on.
3598 
3600  }
3601 
3602  // Postconditions:
3603 
3604  // Exit
3605 
3606  return result;
3607 }
3608 
3610 bool
3612 is_ancestor_of(const any* other) const
3613 {
3614 
3615  // Preconditions:
3616 
3617  require(other != 0);
3618 
3619  // Body:
3620 
3621  // True if other conforms to this
3622 
3623  bool result = dynamic_cast<const member_record*>(other) != 0;
3624 
3625  // Postconditions:
3626 
3627  return result;
3628 
3629 }
3630 
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).
std::string name() const
Definition: subposet.h:796
A client handle for a subposet.
Definition: subposet.h:86
virtual member_record * clone() const
Virtual constructor; makes a new instance of the same type as this.
void delete_equivalence_iterator()
Destroy the equivalence iterator.
bool is_valid() const
True if this is a valid id.
Definition: scoped_index.h:832
The data structure representing the cover relation graph of a poset.
virtual bool invariant() const
Class invariant.
poset_scaffold & scaffold()
The scaffold for the poset associated with this record (mutable version).
Definition: record.h:112
void get_private_data(block< pod_index_type > &xdata) const
Initializes this using private data xdata.
size_type ct() const
The number of items currently in use.
bool in_scope() const
True if and only if scope() contains an entry for pod().
Definition: scoped_index.h:584
size_type member_name_ct(pod_index_type xmbr_hub_id, bool xauto_access) const
The number of names for the member with hub id xmbr_hub_id.
bool bounded_below() const
True if the lower bound is not the bottom.
const pod_type & pod() const
The "plain old data" storage of this; the value in the external id space.
Definition: scoped_index.h:672
void * buf() const
The buffer.
An abstract iterator over the ids of an id space.
bool contains_member(pod_index_type xid) const
True if and only if there exists a member with index xid.
index_space_iterator & get_cover_id_space_iterator(bool xlower, pod_index_type xmbr_hub_id) const
Allocates an iterator for the lower (xlower true) or upper (xlower false) cover id space of the membe...
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.
index_equivalence_class::member_type member_type
The member type for the equivalence id list. The first value in the pair is the index of the id space...
virtual poset_state * state_obj() const
State object for this poset.
dof_tuple_types_type & dof_tuple_types()
Dof tuple type ids (mutable version).
implicit_crg_interval * implicit_member(pod_index_type xid) const
The implicit interval for the member with index xid. Returns null, if no implicit interval exists...
poset_data_type_map & type_map()
The data type map used to convert data for this record (mutable version).
Definition: record.h:130
void put_row_dof_tuple(poset_dof_map *xdof_tuple)
Sets the dof tuple at index xindex to xdof_tuple.
virtual int standard_subposet_ct() const
The number of standard subposets automatically allocated by the constructor.
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
pod_index_type member_dof_tuple_id(pod_index_type xmbr_hub_id, bool xauto_access) const
The dof tuple hub id of the member with hub id xmbr_hub_id.
const name_list_type & all_names(index_type xindex) const
All names associated with index xindex.
void put_rep_id(pod_index_type xrep_id)
Sets rep_id() to xrep_id.
static poset_dof_map * new_dof_map(const std::string &xclass_name, dof_tuple_type xsheaf_base_class_id)
Creates an uninitialized dof map of type xclass_name, if a prototype of that name exists...
member_record(member_record_set &xhost)
Creates an instance in record set xhost for reading or writing member data.
virtual const scoped_index & dof_tuple_id(bool xauto_access) const
An id in the dof tuple hub id space; intended for copying to initialize ids to the dof tuple id space...
bool is_interval_member(pod_index_type xindex) const
True if xindex is the interval member.
virtual bool contains_member(pod_index_type xmbr_hub_id) const
True if this poset contains poset member with hub id xmbr_hub_id.
Definition: subposet.cc:955
std::vector< subposet * > & subposets()
Buffer for subposet handles (mutable version).
A partial multi-valued relation with total injective inverse between names and indices of type index_...
Definition: name_multimap.h:63
STL namespace.
void reserve(index_type xub)
Makes ub() at least xub; if new storage is allocated, it is uninitialized.
The general variable length record wrapper/adapter for transferring data between the kernel and the i...
virtual bool invariant() const
Class invariant.
block< pod_index_type > & dof_tuple_ids()
The ids of the dof tuples associated with this interval.
void put_delete_buffer(bool xval)
Sets delete_buffer to value xval.
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
record_index external_index() const
The external index of this record.
Definition: record.h:94
void new_equivalence_iterator()
Create the equivalence iterator.
virtual ~member_record()
Destructor.
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.
size_type ct() const
The number of items in the current equivalence list being iterated over.
The general, abstract map from dof ids to dof values.
Definition: poset_dof_map.h:59
record_queue & queue()
The queue of dof tuple record requests.
virtual void put_member_name(pod_index_type xmbr_hub_id, const std::string &xname, bool xunique, bool xauto_access=false)
Make xname a name for the member with hub id xmbr_hub_id. if xunique, make xname the only name...
void put_buf(const void *xbuf, size_t xub)
Sets the buffer to xbuf.
dof_tuple_record_set & dof_tuple_records()
The dof tuple record set associated with this.
dof_tuple_class_names_type & dof_tuple_class_names()
Dof tuple class names (mutable version).
implicit_crg_interval * interval() const
The implicit interval object for the current member, if any.
poset_table_state * table() const
Table (dof tuples).
Definition: poset_state.cc:260
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. ...
virtual const std::string & class_name() const
The name of this class; provided to satisfy factory template.
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...
virtual pod_type pod(pod_type xid) const
The pod index in this space equivalent to xid in the hub id space.
void initialize_dof_tuple_ids(const block< pod_index_type > &xdof_tuple_ids)
Allocates and initializes dof_tuple_ids() with xdof_tuple_ids.
Abstract implementation of crg_interval for an interval of implicit cover relation graph members...
scoped_index member_ext_id(const scoped_index &xid) const
An id in the member external id space with pod mapped from xid.
void put_member_dof_tuple_id(pod_index_type xmbr_hub_id, pod_index_type xtuple_hub_id, bool xauto_access)
Sets the dof tuple hub id of the member with hub id xmbr_hub_id to xtuple_hub_id. ...
Abstract base class with useful features for all objects.
Definition: any.h:39
A record_set containing records of type member_record.
A record buffer for transferring member data between the kernel and the i/o subsystem.
Definition: member_record.h:54
void put_scope(const index_space_handle &xid_space)
Sets the scope to xid_space.
Definition: scoped_index.h:441
virtual int standard_member_ct() const
The number of standard members automatically allocated by the constructor.
pod_index_type rep_id() const
The representative id in the top id space of this equivalence class.
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.
size_type external_size(const scoped_index &xmbr_id)
The size of the member record in external form.
void externalize(const scoped_index &xmbr_id, hvl_t *xhdf_buffer)
Converts the record from internal to external form.
size_t buf_ub() const
The size of the buffer, in bytes.
void set_ct(size_type xct)
Sets ct() == xct.
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
bool is_internal() const
True if the internal buffer has been initialized.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
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
size_type private_data_size() const
The size of the private data.
virtual void init_row_dof_map(const poset_state_handle *xhost, pod_index_type xschema_mbr_id, int xschema_version)
Initializes this as a map for row dofs in host xhost, with schema member specified by xschema_mbr_id ...
schema_poset_member & external_schema()
The schema of the poset in external namespace (mutable version).
const bool UPPER
Selector for upper cover.
Definition: sheaf.h:72
poset_bounds & row_bounds()
The bounds for the rows in this transaction (mutable version).
bool le(pod_index_type xother_index) const
True if this is less than or equal to the member with index xother_index.
virtual void finalize(poset_state_handle &xhost)
Finialize the initialization of this crg interval in the host xhost.
void insert(pod_type xid, const scoped_index &xhub_id)
Make id xid in this id space equivalent to xhub_id in the hub id space. synonym for insert(xid...
size_type cover_ct(bool xlower, pod_index_type xmbr_index) const
The number of members in the lower (xlower true) or upper (xlower false) cover of the member with ind...
dof_tuple_type
Identifiers for dof tuple types.
void put_is_internal(bool xis_internal)
Sets is_internal to xis_internal.
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
Definition: any.h:97
void insert_cover_member(pod_index_type xother_mbr_index, bool xlower, pod_index_type xmbr_index)
Inserts xother_mbr_index in the lower (xlower true) or upper (xlower false) cover of the member with ...
void all_member_names(pod_index_type xmbr_hub_id, block< std::string > &xresult, bool xauto_access=false) const
All the names for the member with hub id xmbr_hub_id.
void enqueue(pod_index_type xindex)
Inserts xindex at the end of the record queue.
Definition: record_queue.cc:80
bool member_has_name(pod_index_type xmbr_hub_id, const std::string &xname, bool xauto_access=false) const
True if xname is a name for the member with hub id xmbr_hub_id.
member_name_map_type & member_name_map()
External index to member name map (mutable version).
poset_state_handle & structure()
The handle for the poset being transferred. (Name chosen to void name conflict with class poset...
const bool LOWER
Selector for lower cover.
Definition: sheaf.h:67
virtual poset_dof_map & row_dof_map(pod_index_type xtuple_hub_id, bool xrequire_write_access=false) const
The map from row dof client_ids to row dof values for dof tuple hub id xtuple_hub_id.
bool ge(pod_index_type xother_index) const
True if this is greater than or equal to the member with index xother_index.
member_class_names_type & member_class_names()
Member class names (mutable version).
size_type size() const
The number of members in the member interval.
poset_crg_state & crg() const
The cover relation graph.
bool invariant_check() const
True if invariant checking is enabled.
Definition: any.h:79
pod_index_type compute_ext_id(const scoped_index &xtuple_id)
Computes the external id for the dof tuple dof tuple with id xtuple_id.
scoped_index hub_id() const
This mapped to the hub id space.
Definition: scoped_index.h:358
bool has_equivalence_iterator() const
True, if the equivalence iterator is initialized.
virtual void remove_member(pod_index_type xmbr_hub_id)
Removes the member of host() with hub id xmbr_hub_id.
Definition: subposet.cc:1209
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
A handle for a scattered_insertion_index_space_state.
void put_entry(const entry_type &xentry, bool xunique)
Sets (xindex, xname) as an entry in the map. If xunique, deletes all other entries for xindex...
virtual bool is_jim(pod_index_type xmbr_hub_id, bool xin_current_version=true) const
True if the member with hub id xmbr_hub_id is a jim in the current version (xin_current_version == tr...
bool cover_is_explicit(bool xlower, pod_index_type xmbr_index) const
True if and only if the lower (xlower true) or upper (xlower false) cover of the member with index xm...
virtual subposet & jims()
The subset of all jims (mutable version)
void clear_cover(bool xlower, pod_index_type xmbr_index)
Clears the lower (xlower true) or upper (xlower false) cover of the member with index xmbr_index...
virtual pod_index_type new_member_interval(const std::string &xinterval_type, size_type xsize, const block< pod_index_type > &xtuple_hub_ids, const block< pod_index_type > &xdata)
Create a disconnected member interval of type xinterval_type with size xsize, dof tuple ids xtuple_hu...
An iterator over members of an id equivalence class.
virtual dof_tuple_type type_id() const =0
An identifer for the type of dof tuple this is.
bool is_external() const
True if the external buffer has been initialized.
int int_type
The preferred integer type.
Definition: sheaf.h:41
bool bound_contains_member(const poset_bounds &xbounds, bool xis_ub, const scoped_index &xindex) const
True if the upper bound id (xis_ub == true) or the lower bound (xis_ub == false) of xbounds contains ...
unordered::unordered_map< pod_index_type, std::pair< std::string, size_type > > member_class_names_type
Type of member class names map.
void internalize(hvl_t *xhdf_buffer, const scoped_index &xmbr_id)
Converts the record from external to internal form.
void clear()
Remove all items.
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
virtual const std::string & class_name() const
The name of the actual (possibly derived) class of this instance.
bool is_same_type(const any *other) const
True if other is the same type as this.
Definition: any.cc:79
void put_private_data(const block< pod_index_type > &xdata)
Initializes this using private data xdata.
void enable_invariant_check() const
Enable invariant checking.
Definition: any.h:87
A client handle for a poset member which has been prepared for use as a schema.
void release_cover_id_space_iterator(index_space_iterator &xcover_itr) const
Returns xcover_itr to the pool of id space iterators.
virtual bool contains(pod_type xid) const
True if this space contains id xid.
const scoped_index & index() const
The index of this in host() dof tuple table.
pod_type hub_pod() const
The current unglued hub id in the iteration. synonym for unglued_hub_pod().
void put_is_external(bool xis_external)
Sets is_external to xis_external.
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
Definition: scoped_index.h:710
bool is_resident() const
True if and only if member represented by this record is fully resident after read.