SheafSystem  0.0.0.0
sec_rep_descriptor.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 sec_rep_descriptor
19 
20 
21 #include "SheafSystem/sec_rep_descriptor.h"
22 
23 #include "SheafSystem/assert_contract.h"
24 #include "SheafSystem/eval_family.h"
25 #include "SheafSystem/namespace_poset.h"
26 #include "SheafSystem/poset.h"
27 #include "SheafSystem/poset_dof_map.h"
28 #include "SheafSystem/poset_state_handle.h"
29 #include "SheafSystem/postorder_iterator.h"
30 #include "SheafSystem/std_string.h"
31 #include "SheafSystem/std_typeinfo.h"
32 #include "SheafSystem/schema_descriptor.h"
33 #include "SheafSystem/sec_rep_descriptor_poset.h"
34 #include "SheafSystem/sec_rep_space.h"
35 #include "SheafSystem/wsv_block.h"
36 
37 using namespace std;
38 using namespace fiber_bundle; // Workaround for MS C++ bug.
39 
40 // ===========================================================
41 // HOST FACTORY FACET
42 // ===========================================================
43 
44 // PUBLIC MEMBER FUNCTIONS
45 
46 
47 const sheaf::poset_path&
50 {
51  // Preconditions:
52 
53  // Body:
54 
55  static const poset_path result("sec_rep_descriptor_schema", "sec_rep_descriptor_schema");
56 
57  // Postconditions:
58 
59  ensure(result.full());
60 
61  // Exit:
62 
63  return result;
64 }
65 
66 
67 void
70 {
71  // Preconditions:
72 
73  require(xns.state_is_read_write_accessible());
74  require(xns.contains_poset(standard_schema_path(), false));
75  require(xns.member_poset(standard_schema_path(), false).state_is_read_write_accessible());
76  require(!xns.contains_poset_member(standard_schema_path(), false));
77 
78  // Body:
79 
80  string ldof_specs;
81 
82  ldof_specs = "discretization_subposet_name C_STRING false";
83  ldof_specs += " multivalued_subposet_name C_STRING false";
84  ldof_specs += " evaluation_subposet_name C_STRING false";
85  ldof_specs += " evaluator_family_name C_STRING false";
86  ldof_specs += " URL C_STRING false";
87  ldof_specs += " multiplicity INT false";
88 
91 
92  ldof_specs += " eval_is_above_disc SIZE_TYPE false";
93 
94  // Table dofs:
95 
96  ldof_specs += " prototypes_path C_STRING true";
97 
98  schema_poset_member lschema(xns,
99  standard_schema_path().member_name(),
100  poset_path(standard_schema_path().poset_name(), "bottom"),
101  ldof_specs,
102  false);
103 
104  lschema.detach_from_state();
105 
106  // Postconditions:
107 
108  ensure(xns.contains_poset_member(standard_schema_path()));
109 
110  // Exit
111 
112  return;
113 }
114 
115 const sheaf::poset_path&
118 {
119  // cout << endl << "Entering sec_rep_descriptor::standard_host_path." << endl;
120 
121  // Preconditions:
122 
123 
124  // Body:
125 
126  static const poset_path result("sec_rep_descriptors", "");
127 
128  // Postconditions:
129 
130  ensure(!result.empty());
131  ensure(!result.full());
132 
133  // Exit:
134 
135  // cout << "Leaving sec_rep_descriptor::standard_host_path." << endl;
136  return result;
137 }
138 
142  const poset_path& xhost_path,
143  const poset_path& xschema_path,
144  const poset_path& xprototypes_path,
145  bool xauto_access)
146 {
147  // cout << endl << "Entering sec_rep_descriptor::new_host." << endl;
148 
149  // Preconditions:
150 
151  require(xns.state_is_auto_read_write_accessible(xauto_access));
152 
153  require(!xhost_path.empty());
154  require(!xns.contains_path(xhost_path, xauto_access));
155 
156  require(xschema_path.full());
157  require(xns.path_is_auto_read_accessible(xschema_path, xauto_access));
158  require(schema_poset_member::conforms_to(xns, xschema_path, standard_schema_path()));
159 
160  require(!xprototypes_path.empty());
161  require(xns.path_is_auto_read_accessible(xprototypes_path, xauto_access));
162 
163  // Body:
164 
165  host_type& result = host_type::new_table(xns, xhost_path, xschema_path, xprototypes_path, xauto_access);
166 
167  // Postconditions:
168 
169  ensure(xns.owns(result, xauto_access));
170  ensure(result.path(true) == xhost_path);
171  ensure(result.state_is_not_read_accessible());
172  ensure(result.schema(true).path(xauto_access) == xschema_path);
173 
174  ensure(result.prototypes().path(xauto_access) == xprototypes_path);
175 
176  // Exit:
177 
178  // cout << "Leaving sec_rep_descriptor::new_host." << endl;
179  return result;
180 }
181 
184 standard_host(namespace_type& xns, bool xauto_access)
185 {
186  // cout << endl << "Entering sec_rep_descriptor::new_host." << endl;
187 
188  // Preconditions:
189 
190  require(xns.state_is_auto_read_write_accessible(xauto_access));
191 
192  require(xns.path_is_available<host_type>(standard_host_path(), xauto_access));
193 
194  require(xns.path_is_auto_read_accessible(standard_schema_path(), xauto_access));
195 
196  // Body:
197 
198  poset_path lpath(standard_host_path());
199 
200  host_type* result_ptr;
201  if(xns.contains_path(lpath, xauto_access))
202  {
203  result_ptr = &xns.member_poset<host_type>(lpath, xauto_access);
204  }
205  else
206  {
207  poset_path lprototypes_path(base_space_member::prototypes_poset_name());
208  result_ptr = &new_host(xns, lpath, standard_schema_path(), lprototypes_path, xauto_access);
209  }
210 
211  host_type& result = *result_ptr;
212 
213  // Postconditions:
214 
215  ensure(xns.owns(result, xauto_access));
216  ensure(result.path(true) == standard_host_path());
217  ensure(result.state_is_not_read_accessible());
218  ensure(result.schema(true).path(xauto_access) == standard_schema_path());
219 
220  ensure(result.prototypes().path(xauto_access).poset_name() == base_space_member::prototypes_poset_name());
221 
222  // Exit:
223 
224  // cout << "Leaving sec_rep_descriptor::new_host." << endl;
225  return result;
226 }
227 
228 // PROTECTED MEMBER FUNCTIONS
229 
230 // PRIVATE MEMBER FUNCTIONS
231 
232 
233 
234 
238 {
239  // Preconditions:
240 
241  require(is_ancestor_of(&xother));
242 
243  // Body:
244 
245  not_implemented();
246 
247  // Postconditions:
248 
249  ensure(invariant());
250 
251  // Exit
252 
253  return *this;
254 }
255 
259 {
260  // Preconditions:
261 
262  require(is_ancestor_of(&xother));
263 
264  // Body:
265 
266  not_implemented();
267 
268  // Postconditions:
269 
270  ensure(invariant());
271 
272  // Exit
273 
274  return *this;
275 }
276 
277 // PUBLIC MEMBER FUNCTIONS
278 
279 // CANONICAL MEMBERS
280 
281 // Default constructor
284  : _evaluators(0)
285 {
286 
287  // Preconditions:
288 
289 
290  // Body:
291 
292 
293  // Postconditions:
294 
295  ensure(invariant());
296 
297  // Exit:
298 
299  return;
300 }
301 
302 
303 // Copy constructor
305 sec_rep_descriptor(const sec_rep_descriptor& xother, bool xnew_jem)
306  : _evaluators(0)
307 {
308 
309  // Preconditions:
310 
311  require(xnew_jem ? xother.is_attached() : true);
312 
313  // Body:
314 
315  // Note: even though the code here is identical to that in
316  // the copy constructors of all descendants of abstract_poset_member,
317  // this can not just call its base class copy constructor
318  // because it must invoke versions defined in this class of virtual attach_to_state
319  // and virtual attach_handle_data_members (called from new_jem_state).
320 
321  if(xnew_jem)
322  {
323  new_jem_state(const_cast<sec_rep_descriptor*>(&xother), true, true);
324  }
325  else
326  {
327  attach_to_state(&xother);
328  }
329 
330  // postconditions:
331 
332  ensure(invariant());
333  ensure(is_attached() == xother.is_attached() );
334 }
335 
338 clone() const
339 {
340 
341  // Preconditions:
342 
343  // Body:
344 
345  // create new handle of the current class.
346 
347  sec_rep_descriptor *result = new sec_rep_descriptor();
348 
349  // Postconditions:
350 
351  ensure(result != 0);
352  ensure(result->invariant());
353 
354  // Exit:
355 
356  return result;
357 
358 }
359 
360 // Destructor
363 {
364  // Preconditions:
365 
366 
367  // Body:
368 
369  if(_evaluators != 0)
370  {
371  delete _evaluators;
372  }
373 
374  // Postconditions:
375 
376  // Exit:
377 
378  return;
379 }
380 
381 
382 // Class invariant
383 bool
385 invariant() const
386 {
387  bool result = true;
388 
389  // Preconditions:
390 
391  // Body:
392 
393  // Must satisfy total_poset_member class invariant
394 
395  result = result && total_poset_member::invariant();
396 
397  if(invariant_check())
398  {
399  // Prevent recursive calls to invariant
400 
402 
403  // Actual type of dof map is array_poset_dof_map.
404  result = result && ( (state_is_read_accessible() && is_jim()) ? dynamic_cast<const array_poset_dof_map*>(&(total_poset_member::dof_map()))!=0 : true);
405 
406  // Finished, turn invariant checking back on.
407 
409  }
410 
411  // Postconditions:
412 
413  // Exit
414 
415  return result;
416 }
417 
418 bool
420 is_ancestor_of(const any* other) const
421 {
422 
423  // Preconditions:
424 
425  require(other != 0);
426 
427  // Body:
428 
429  // True if other conforms to this
430 
431  bool result = dynamic_cast<const sec_rep_descriptor*>(other) != 0;
432 
433  // Postconditions:
434 
435  return result;
436 
437 }
438 
439 
440 
441 // NEW HANDLE, NEW STATE CONSTRUCTORS
442 
445  const std::string& xdiscretization_subposet_name,
446  const std::string& xmultivalued_subposet_name,
447  const std::string& xevaluation_subposet_name,
448  const std::string& xevaluator_family_name,
449  const std::string& xurl,
450  int xmultiplicity,
451  bool xeval_is_above_disc,
452  bool xauto_access)
453  : _evaluators(0)
454 {
455 
456  // Preconditions:
457 
458  require(precondition_of(new_jim_state(same args)));
459 
460  // Body:
461 
462  new_jim_state(xhost,
463  xdiscretization_subposet_name,
464  xmultivalued_subposet_name,
465  xevaluation_subposet_name,
466  xevaluator_family_name,
467  xurl,
468  xmultiplicity,
469  xeval_is_above_disc,
470  xauto_access);
471 
472  // Postconditions:
473 
474  ensure(postcondition_of(new_jim_state(same args)));
475 
476  // Exit:
477 
478  return;
479 }
480 
481 // NEW HANDLE, EXISTING STATE CONSTRUCTORS
482 
485  : _evaluators(0)
486 {
487 
488  // preconditions:
489 
490  require(xhost != 0);
491  require(xhost->state_is_read_accessible());
492  require(xhost->contains_member(xindex));
493 
494  // body:
495 
496  attach_to_state(xhost, xindex);
497 
498  // postconditions:
499 
500  ensure(invariant());
501  ensure(is_attached());
502  ensure(host() == xhost);
503  ensure(index() == xindex);
504 
505 }
506 
508 sec_rep_descriptor(const poset* xhost, const scoped_index& xindex)
509  : _evaluators(0)
510 {
511 
512  // preconditions:
513 
514  require(xhost != 0);
515  require(xhost->state_is_read_accessible());
516  require(xhost->contains_member(xindex));
517 
518  // body:
519 
520  attach_to_state(xhost, xindex.hub_pod());
521 
522  // postconditions:
523 
524  ensure(invariant());
525  ensure(is_attached());
526  ensure(host() == xhost);
527  ensure(index() ==~ xindex);
528 
529 }
530 
531 // Creates a new handle attached to
532 // the member state with name xname in xhost.
534 sec_rep_descriptor(const poset* xhost, const std::string& xname)
535  : _evaluators(0)
536 {
537 
538  // preconditions:
539 
540  require(xhost != 0);
541  require(xhost->state_is_read_accessible());
542  require(!xname.empty());
543  require(xhost->contains_member(xname));
544 
545  // body:
546 
547  attach_to_state(xhost, xname);
548 
549  // postconditions:
550 
551  ensure(invariant());
552  ensure(is_attached());
553  ensure(host() == xhost);
554  ensure(name() == xname);
555 
556 }
557 
558 
561  const poset_path& xpath,
562  bool xauto_access)
563  : _evaluators(0)
564 {
565 
566  // Preconditions:
567 
568  require(precondition_of(attach_to_state(same args)));
569 
570  // Body:
571 
572  attach_to_state(xnamespace, xpath, xauto_access);
573 
574  // Postconditions:
575 
576  ensure(postcondition_of(attach_to_state(same args)));
577 
578  // Exit:
579 
580  return;
581 }
582 
585  pod_index_type xposet_id,
586  pod_index_type xmember_id,
587  bool xauto_access)
588  : _evaluators(0)
589 {
590 
591  // Preconditions:
592 
593  require(precondition_of(attach_to_state(same args)));
594 
595  // Body:
596 
597  attach_to_state(xnamespace, xposet_id, xmember_id, xauto_access);
598 
599  // Postconditions:
600 
601  ensure(postcondition_of(attach_to_state(same args)));
602 
603  // Exit:
604 
605  return;
606 }
607 
610  const scoped_index& xposet_id,
611  const scoped_index& xmember_id,
612  bool xauto_access)
613  : _evaluators(0)
614 {
615 
616  // Preconditions:
617 
618  require(precondition_of(attach_to_state(same args)));
619 
620  // Body:
621 
622  attach_to_state(xnamespace,
623  xposet_id.hub_pod(),
624  xmember_id.hub_pod(),
625  xauto_access);
626 
627  // Postconditions:
628 
629  ensure(postcondition_of(attach_to_state(same args)));
630 
631  // Exit:
632 
633  return;
634 }
635 
636 void
638 new_jim_state(poset_dof_map* xdof_map, bool xcopy_dof_map, bool xauto_access)
639 {
640  // Preconditions:
641 
642  require(precondition_of(new_jim_state(host(), xdof_map, xcopy_dof_map, xauto_access)));
643 
644  // Body:
645 
646  new_jim_state(host(), xdof_map, xcopy_dof_map, xauto_access);
647 
648  // Postconditions:
649 
650  ensure(postcondition_of(new_jim_state(host(), xdof_map, xcopy_dof_map, xauto_access)));
651 
652  // Exit:
653 
654  return;
655 }
656 
657 void
660  poset_dof_map* xdof_map,
661  bool xcopy_dof_map,
662  bool xauto_access)
663 {
664  // Preconditions:
665 
666  require(precondition_of(total_poset_member::new_jim_state(xhost, xdof_map, xcopy_dof_map, false)));
667 
668  // Body:
669 
670  if(xauto_access)
671  {
672  xhost->begin_jim_edit_mode();
673 
674  if(xdof_map != 0)
675  xdof_map->host()->get_read_access();
676  }
677 
678  poset_dof_map* ldof_map;
679  bool lcopy_dof_map;
680 
681  if(xdof_map == 0)
682  {
683  // Make sure the dofs are properly initialized.
684  // Create and initialize the dof tuple to default values.
685 
686  string lmt_str;
687  row_dof_tuple ltuple(lmt_str, lmt_str, lmt_str, lmt_str, lmt_str, 0, 0);
688 
689  // Create the dof map.
690 
691  ldof_map = new array_poset_dof_map(xhost, false);
692 
693  // Copy the dof tuple into the dof map.
694 
695  ldof_map->put_dof_tuple(&ltuple, sizeof(ltuple));
696 
697  lcopy_dof_map = false;
698  }
699  else
700  {
701  ldof_map = xdof_map;
702  lcopy_dof_map = xcopy_dof_map;
703  }
704 
705  total_poset_member::new_jim_state(xhost, ldof_map, lcopy_dof_map, false);
706 
707  // Postconditions:
708 
709  ensure(postcondition_of(total_poset_member::new_jim_state(xhost, xdof_map, xcopy_dof_map, false)));
710  ensure(invariant());
711  ensure(xdof_map == 0 ? discretization_subposet_name().empty() : true);
712  ensure(xdof_map == 0 ? multivalued_subposet_name().empty() : true);
713  ensure(xdof_map == 0 ? evaluation_subposet_name().empty() : true);
714  ensure(xdof_map == 0 ? evaluator_family_name().empty() : true);
715  ensure(xdof_map == 0 ? url().empty() : true);
716  ensure(xdof_map == 0 ? multiplicity() == 0 : true);
717  ensure(xdof_map == 0 ? !eval_is_above_disc() : true);
718 
719  // Clean-up auto access.
720 
721  if(xauto_access)
722  {
723  xhost->end_jim_edit_mode();
724 
725  if(xdof_map != 0)
726  xdof_map->host()->release_access();
727  }
728 
729  // Exit:
730 
731  return;
732 }
733 
734 void
737  const std::string& xdiscretization_subposet_name,
738  const std::string& xmultivalued_subposet_name,
739  const std::string& xevaluation_subposet_name,
740  const std::string& xevaluator_family_name,
741  const std::string& xurl,
742  int xmultiplicity,
743  bool xeval_is_above_disc,
744  bool xauto_access)
745 {
746 
747  // Preconditions:
748 
749  require(xhost != 0);
750  require(xauto_access || xhost->in_jim_edit_mode());
751  require(xmultiplicity >= 0);
752 
753  // Body:
754 
755  if(xauto_access)
756  xhost->begin_jim_edit_mode();
757 
758  // Create and initialize the dof tuple.
759 
760  row_dof_tuple ltuple(xdiscretization_subposet_name,
761  xmultivalued_subposet_name,
762  xevaluation_subposet_name,
763  xevaluator_family_name,
764  xurl,
765  xmultiplicity,
766  xeval_is_above_disc ? 1 : 0);
767 
768  // Create the dof map.
769 
770  array_poset_dof_map* lmap = new array_poset_dof_map(xhost, false);
771 
772  // Copy the dof tuple into the dof map.
773 
774  lmap->put_dof_tuple(&ltuple, sizeof(ltuple));
775 
776  // Create the new state.
777 
778  new_jim_state(xhost, lmap, false, false);
779 
780  // Postconditions:
781 
782  ensure(invariant());
783  ensure(is_attached());
784  ensure(host() == xhost);
785  ensure(unexecutable(host()->member_ct() == old host->member_ct() + 1));
786  ensure(discretization_subposet_name() == xdiscretization_subposet_name);
787  ensure(multivalued_subposet_name() == xmultivalued_subposet_name);
788  ensure(evaluation_subposet_name() == xevaluation_subposet_name);
789  ensure(evaluator_family_name() == xevaluator_family_name);
790  ensure(url() == xurl);
791  ensure(multiplicity() == xmultiplicity);
792  ensure(eval_is_above_disc() == xeval_is_above_disc);
793 
794  if(xauto_access)
795  xhost->end_jim_edit_mode();
796 
797  // Exit:
798 
799  return;
800 }
801 
802 
803 
806 dof_map(bool xrequire_write_access)
807 {
808  // Preconditions:
809 
810  require(xrequire_write_access ?
813  require(is_jim(false));
814 
815  // Body:
816 
817  // Invariant ensures the cast will succeed.
818 
819  array_poset_dof_map& result =
821 
822  // Postconditions:
823 
824  // Exit:
825 
826  return result;
827 }
828 
831 dof_map(bool xrequire_write_access) const
832 {
833  // Preconditions:
834 
835  require(xrequire_write_access ?
838  require(is_jim(false));
839 
840  // Body:
841 
842  // Invariant ensures the cast will succeed.
843 
844  const array_poset_dof_map& result =
845  dynamic_cast<const array_poset_dof_map&>(total_poset_member::dof_map());
846 
847  // Postconditions:
848 
849  // Exit:
850 
851  return result;
852 }
853 
854 
855 
856 bool
858 dof_map_is_ancestor_of(const poset_dof_map* xdof_map) const
859 {
860  bool result;
861 
862  // Preconditions:
863 
864  require(xdof_map != 0);
865 
866  // Body:
867 
868  result = dynamic_cast<const array_poset_dof_map*>(xdof_map) != 0;
869 
870  // Postconditions:
871 
872  ensure(result == (dynamic_cast<const array_poset_dof_map*>(xdof_map) != 0));
873 
874  // Exit
875 
876  return result;
877 }
878 
879 std::string
882 {
883  string result;
884 
885  // Preconditions:
886 
887  require(state_is_read_accessible());
888 
889  // Body:
890 
891  result = row_dof_tuple_ptr()->discretization_subposet_name;
892 
893  // Postconditions:
894 
895  // Exit
896 
897  return result;
898 }
899 
900 void
902 put_discretization_subposet_name(const std::string& xname)
903 {
904  // Preconditions:
905 
907 
908  // Body:
909 
910  delete [] row_dof_tuple_ptr()->discretization_subposet_name;
911  row_dof_tuple::copy_string_dof(row_dof_tuple_ptr()->discretization_subposet_name, xname);
912 
913  // Postconditions:
914 
915  ensure(discretization_subposet_name() == xname);
916 
917  // Exit
918 
919  return;
920 }
921 
922 
923 std::string
926 {
927  string result;
928 
929  // Preconditions:
930 
931  require(state_is_read_accessible());
932 
933  // Body:
934 
935  result = row_dof_tuple_ptr()->multivalued_subposet_name;
936 
937  // Postconditions:
938 
939  // Exit
940 
941  return result;
942 }
943 
944 void
946 put_multivalued_subposet_name(const std::string& xname)
947 {
948  // Preconditions:
949 
951 
952  // Body:
953 
954  delete [] row_dof_tuple_ptr()->multivalued_subposet_name;
955  row_dof_tuple::copy_string_dof(row_dof_tuple_ptr()->multivalued_subposet_name, xname);
956 
957  // Postconditions:
958 
959  ensure(multivalued_subposet_name() == xname);
960 
961  // Exit
962 
963  return;
964 }
965 
966 
967 std::string
970 {
971  string result;
972 
973  // Preconditions:
974 
975  require(state_is_read_accessible());
976 
977  // Body:
978 
979  result = row_dof_tuple_ptr()->evaluation_subposet_name;
980 
981  // Postconditions:
982 
983  // Exit
984 
985  return result;
986 }
987 
988 void
990 put_evaluation_subposet_name(const std::string& xname)
991 {
992  // Preconditions:
993 
995 
996  // Body:
997 
998  delete [] row_dof_tuple_ptr()->evaluation_subposet_name;
999  row_dof_tuple::copy_string_dof(row_dof_tuple_ptr()->evaluation_subposet_name, xname);
1000 
1001  // Postconditions:
1002 
1003  ensure(evaluation_subposet_name() == xname);
1004 
1005  // Exit
1006 
1007  return;
1008 }
1009 
1010 std::string
1013 {
1014  string result;
1015 
1016  // Preconditions:
1017 
1018  require(state_is_read_accessible());
1019 
1020  // Body:
1021 
1022  result = row_dof_tuple_ptr()->evaluator_family_name;
1023 
1024  // Postconditions:
1025 
1026  // Exit
1027 
1028  return result;
1029 }
1030 
1031 void
1033 put_evaluator_family_name(const std::string& xname)
1034 {
1035  // Preconditions:
1036 
1037  require(state_is_read_write_accessible());
1038 
1039  // Body:
1040 
1041  delete [] row_dof_tuple_ptr()->evaluator_family_name;
1042  row_dof_tuple::copy_string_dof(row_dof_tuple_ptr()->evaluator_family_name, xname);
1043 
1044  // Postconditions:
1045 
1046  ensure(evaluator_family_name() == xname);
1047 
1048  // Exit
1049 
1050  return;
1051 }
1052 
1053 std::string
1055 url() const
1056 {
1057  string result;
1058 
1059  // Preconditions:
1060 
1061  require(state_is_read_accessible());
1062 
1063  // Body:
1064 
1065  result = row_dof_tuple_ptr()->url;
1066 
1067  // Postconditions:
1068 
1069  // Exit
1070 
1071  return result;
1072 }
1073 
1074 void
1076 put_url(const std::string& xurl)
1077 {
1078  // Preconditions:
1079 
1080  require(state_is_read_write_accessible());
1081 
1082  // Body:
1083 
1084  delete [] row_dof_tuple_ptr()->url;
1085  row_dof_tuple::copy_string_dof(row_dof_tuple_ptr()->url, xurl);
1086 
1087  // Postconditions:
1088 
1089  ensure(url() == xurl);
1090 
1091  // Exit
1092 
1093  return;
1094 }
1095 
1096 int
1099 {
1100  int result;
1101 
1102  // Preconditions:
1103 
1104  require(state_is_read_accessible());
1105 
1106  // Body:
1107 
1108  result = row_dof_tuple_ptr()->multiplicity;
1109 
1110  // Postconditions:
1111 
1112  // Exit
1113 
1114  return result;
1115 }
1116 
1117 void
1119 put_multiplicity(int xmultiplicity)
1120 {
1121  // Preconditions:
1122 
1123  require(state_is_read_write_accessible());
1124 
1125  // Body:
1126 
1127  row_dof_tuple_ptr()->multiplicity = xmultiplicity;
1128 
1129  // Postconditions:
1130 
1131  ensure(multiplicity() == xmultiplicity);
1132 
1133  // Exit
1134 
1135  return;
1136 }
1137 
1138 bool
1141 {
1142  bool result;
1143 
1144  // Preconditions:
1145 
1146  require(state_is_read_accessible());
1147 
1148  // Body:
1149 
1150  result = row_dof_tuple_ptr()->eval_is_above_disc;
1151 
1152  // Postconditions:
1153 
1154 
1155  // Exit:
1156 
1157  return result;
1158 }
1159 
1160 void
1163 {
1164  // Preconditions:
1165 
1166  require(state_is_read_write_accessible());
1167 
1168  // Body:
1169 
1170  row_dof_tuple_ptr()->eval_is_above_disc = xvalue ? 1 : 0;
1171 
1172  // Postconditions:
1173 
1174  ensure(eval_is_above_disc() == xvalue);
1175 
1176  // Exit:
1177 
1178  return;
1179 }
1180 
1183 evaluators() const
1184 {
1185  return _evaluators;
1186 }
1187 
1188 // PROTECTED MEMBER FUNCTIONS
1189 
1190 void
1193 {
1194  // Preconditions:
1195 
1196  require(state_is_read_accessible());
1197 
1198  // Body:
1199 
1200  string lnew_name = evaluator_family_name();
1201 
1202  if(_evaluators != 0)
1203  {
1204  delete _evaluators;
1205  _evaluators = 0;
1206  }
1207 
1208  assertion(_evaluators == 0);
1209 
1210  if(!lnew_name.empty())
1211  {
1212  // Handle needs an eval family; create it.
1213 
1214  _evaluators = eval_family::new_family(lnew_name, *name_space());
1215  }
1216 
1217 
1218  // Postconditions:
1219 
1220  ensure(!is_restricted());
1221  ensure(evaluator_family_name().empty() == (evaluators() == 0));
1222 
1223 
1224  // Exit:
1225 
1226  return;
1227 }
1228 
1229 
1230 fiber_bundle::sec_rep_descriptor::row_dof_tuple::
1231 row_dof_tuple(const std::string& xdiscretization_subposet_name,
1232  const std::string& xmultivalued_subposet_name,
1233  const std::string& xevaluation_subposet_name,
1234  const std::string& xevaluator_family_name,
1235  const std::string& xurl,
1236  int xmultiplicity,
1237  size_type xeval_is_above_disc)
1238 {
1239  // Preconditions:
1240 
1241  // Body:
1242 
1243  copy_string_dof(discretization_subposet_name, xdiscretization_subposet_name);
1244  copy_string_dof(multivalued_subposet_name, xmultivalued_subposet_name);
1245  copy_string_dof(evaluation_subposet_name, xevaluation_subposet_name);
1246  copy_string_dof(evaluator_family_name, xevaluator_family_name);
1247  copy_string_dof(url, xurl);
1248  multiplicity = xmultiplicity;
1249  eval_is_above_disc = xeval_is_above_disc;
1250 
1251  // Postconditions:
1252 
1253  ensure(discretization_subposet_name == xdiscretization_subposet_name);
1254  ensure(multivalued_subposet_name == xmultivalued_subposet_name);
1255  ensure(multiplicity == xmultiplicity);
1256  ensure(evaluation_subposet_name == xevaluation_subposet_name);
1257  ensure(evaluator_family_name == xevaluator_family_name);
1258  ensure(url == xurl);
1259  ensure(eval_is_above_disc == xeval_is_above_disc);
1260 
1261  // Exit
1262 
1263  return;
1264 }
1265 
1266 void
1267 fiber_bundle::sec_rep_descriptor::row_dof_tuple::
1268 copy_string_dof(char*& xdof, const std::string& xdof_value)
1269 {
1270  // Preconditions:
1271 
1272  // Body:
1273 
1274  xdof = new char[xdof_value.size()+1];
1275  strcpy(xdof, xdof_value.c_str());
1276 
1277  // Postconditions:
1278 
1279  ensure(strcmp(xdof, xdof_value.c_str()) == 0);
1280 
1281  // Exit
1282 
1283  return;
1284 }
1285 
poset_state_handle * host() const
The poset which this is a handle to a component of.
virtual void attach_handle_data_members()
Initializes handle data members when attaching to a different member of the same host.
eval_family * evaluators() const
The family of evaluators for this rep. /.
virtual bool invariant() const
Class invariant.
virtual poset_path path(bool xauto_access=true) const
The path of this poset.
virtual ~sec_rep_descriptor()
Destructor.
bool state_is_auto_read_write_accessible(bool xauto_access) const
True if state is auto accessible for read and write, that is, if the state is already accessible for ...
virtual bool is_jim(bool xin_current_version=true) const
True if this member is join irreducible in the current version of the host (xin_current_version == tr...
virtual bool invariant() const
Class invariant.
virtual bool is_restricted() const
True if handle is a restriction of the state, that is, if schema() is not the same as host()->schema(...
poset_dof_map * row_dof_tuple(const scoped_index &xindex) const
The row dof tuple associated with xindex.
std::string evaluator_family_name() const
The name of the evaluator family.
bool full() const
True if both poset name and member name are not empty.
Definition: poset_path.cc:311
virtual int member_ct() const
The number of members of this poset.
virtual void new_jim_state(poset_dof_map *xdof_map=0, bool xcopy_dof_map=false, bool xauto_access=true)
Creates a new jim (join-irreducible member) state in host() and attaches this to it. If xdof_map == 0 a new dof map is created. If xdof_map != 0 and xcopy_dof_map == false, xdof_map is used as the dof map. If xdof_map != 0 and xcopy_dof_map is true, a copy of xdof_map is used.
poset_path path(bool xauto_access=true) const
A path to this component.
static const poset_path & standard_host_path()
The standard path for host spaces for this class.
The default name space; a poset which contains other posets as members.
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
bool path_is_auto_read_accessible(const poset_path &xpath, bool xauto_access) const
True if the state referred to xpath exists and is auto read accessible.
The standard fiber bundles name space; extends the standard sheaves namespace by defining base space...
std::string discretization_subposet_name() const
The name of the discretization subposet.
bool contains_poset_member(pod_index_type xposet_hub_id, pod_index_type xmember_hub_id, bool xauto_access=true) const
True if this contains a poset with hub id xposet_hub_id which contains a member with hub id xmember_h...
A client handle for a general, abstract partially order set.
A path defined by a poset name and a member name separated by a forward slash (&#39;/&#39;). For example: "cell_definitions/triangle".
Definition: poset_path.h:48
STL namespace.
static const poset_path & standard_schema_path()
The path of the schema required by this class.
int multiplicity() const
The number of degrees of freedom associated with each (discretization member, fiber_schema member) pa...
poset_state_handle & member_poset(pod_index_type xhub_id, bool xauto_access=true) const
The poset_state_handle object referred to by hub id xhub_id.
virtual namespace_poset * name_space() const
The namespace of host()
const scoped_index & index() const
The index of the component state this handle is attached to.
std::string name() const
A name for this.
The general, abstract map from dof ids to dof values.
Definition: poset_dof_map.h:59
The poset for sec_rep_descriptors.
virtual bool dof_map_is_ancestor_of(const poset_dof_map *xdof_map) const
True if xdof_map conforms to (i.e. is derived from) the type of dof map required by this member...
Abstract base class with useful features for all objects.
Definition: any.h:39
sec_rep_descriptor()
Default constructor.
bool path_is_available(const poset_path &xpath, bool xauto_access) const
True if the state referred to xpath does not exist or exists and conforms to poset type P...
static eval_family * new_family(const std::string &xname)
Creates an instance of the evaluator family associated with name xname.
Definition: eval_family.cc:181
virtual schema_poset_member & schema()
The schema for this poset (mutable version).
const base_space_poset & prototypes() const
The base space members prototypes poset.
void put_discretization_subposet_name(const std::string &xname)
Sets the name of the discretization subposet to xname.
bool eval_is_above_disc() const
True is the evaluation subposet is strictly above the discretization subposet.
void put_eval_is_above_disc(bool xvalue)
Sets eval_is_above_disc to xvalue.
A client handle for a mutable partially ordered set.
Definition: poset.h:40
bool state_is_read_write_accessible() const
True if this is attached and if the state is accessible for read and write or access control is disab...
bool owns(const poset_state_handle &xposet, bool xauto_access) const
True if and only if this contains the poset xposet. synonym for contains_poset(xposet.poset_path(true), xauto_access)
virtual void detach_from_state()
Detach this handle from its state, if any.
void put_evaluation_subposet_name(const std::string &xname)
Sets the name of the evaluation subposet to xname.
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
A family of compatible section evaluators, one for each member of some family of cell types; a map fr...
Definition: eval_family.h:67
virtual bool is_attached() const
True if this handle is attached to a non-void state.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
std::string poset_name() const
The poset name part of the path.
Definition: poset_path.cc:473
bool contains_path(const poset_path &xpath, bool xauto_access=true) const
True if this contains the poset or poset member specified by xpath.
virtual bool contains_member(pod_index_type xmbr_hub_id, bool xauto_access=true) const
True if some version of this poset contains poset member with hub id xmbr_hub_id. ...
virtual array_poset_dof_map & dof_map(bool xrequire_write_access=false)
The map from client_ids to dof values for this poset member (mutable version)
virtual void begin_jim_edit_mode(bool xauto_access=true)
Allow editing of jims and jim order relation.
bool empty() const
True if both poset name and member name are empty.
Definition: poset_path.cc:291
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
Definition: any.h:97
virtual void release_access(bool xall=false) const
Release access. If xall is true, release all levels of access. Otherwise, release one level of access...
bool contains_poset(pod_index_type xhub_id, bool xauto_access=true) const
True if this contains a poset with hub id xhub_id..
void put_evaluator_family_name(const std::string &xname)
Sets the name of the evaluator family to xname.
void put_multivalued_subposet_name(const std::string &xname)
Sets the name of the multivalued subposet to xname.
void put_url(const std::string &xurl)
Sets the url for a description of this representation to xurl.
void put_multiplicity(int xmultiplicity)
Sets the number of degrees of freedom associated with each (discretization member, fiber_schema member) pair.
static void make_standard_schema(namespace_poset &xns)
Creates the standard schema for this class in namespace xns.
virtual void put_dof_tuple(const void *xbuf, size_t xbuflen)
Copies the entire dof tuple from xbuf into internal storage.
virtual poset_state_handle * host() const
The poset which owns this.
bool invariant_check() const
True if invariant checking is enabled.
Definition: any.h:79
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
std::string evaluation_subposet_name() const
The name of the evaluation subposet.
std::string multivalued_subposet_name() const
The name of the multivalued subposet.
static host_type & standard_host(namespace_type &xns, bool xauto_access)
The host with path standard_host_path(). Returns the host if it already exists, otherwise, creates it in namespace xns with schema specified by standard_schema_path() and standard paths for prerequisites, which are also created if needed.
virtual void end_jim_edit_mode(bool xensure_lattice_invariant=true, bool xauto_access=true)
Prevent editing of jims and jim order relation.
Definition: poset.cc:253
virtual void end_jim_edit_mode(bool xensure_lattice_invariant=true, bool xauto_access=true)
Prevent editing of jims and jim order relation.
virtual void put_dof_tuple(const void *xbuf, size_t xbuflen)=0
Copies the entire dof tuple from xbuf into internal storage.
void attach_to_state(const namespace_poset *xns, const poset_path &xpath, bool xauto_access=true)
Attach to the state specified by path xpath in the namespace xns.
virtual void new_jim_state(poset_dof_map *xdof_map=0, bool xcopy_dof_map=false, bool xauto_access=true)
Creates a new jim (join-irreducible member) state in host() and attaches this to it. If xdof_map == 0 a new dof map is created. If xdof_map != 0 and xcopy_dof_map == false, xdof_map is used as the dof map. If xdof_map != 0 and xcopy_dof_map is true, a copy of xdof_map is used.
virtual void get_read_access() const
Get read access to the state associated with this.
An abstract client handle for a member of a poset.
virtual poset_dof_map & dof_map(bool xrequire_write_access=false)
The map from schema member ids or client ids to dof values for this poset member (mutable version) ...
std::string url() const
The url for a description of this representation.
virtual void new_jem_state(abstract_poset_member *xother, bool xgreatest, bool xauto_access)
Creates a new jrm state in host() which is the greatest jem (xgreatest true) or least jem (xgreatest ...
bool in_jim_edit_mode() const
True if editing jims and jim order relation is allowed.
An array representation of abstract class poset_dof_map.
Namespace for the fiber_bundles component of the sheaf system.
virtual sec_rep_descriptor * clone() const
Make a new handle, no state instance of current.
void enable_invariant_check() const
Enable invariant checking.
Definition: any.h:87
bool state_is_not_read_accessible() const
True if this is attached and if the state is accessible for read or if access control is disabled...
A client handle for a poset member which has been prepared for use as a schema.
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
static host_type & new_host(namespace_type &xns, const poset_path &xhost_path, const poset_path &xschema_path, const poset_path &xprototypes_path, bool xauto_access)
Creates a new host table for members of this type. The poset is created in namespace xns with path xh...
A description for a section representation scheme.
virtual sec_rep_descriptor & operator=(const abstract_poset_member &xother)
Assignment operator.
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
Definition: scoped_index.h:710
virtual void begin_jim_edit_mode(bool xauto_access=true)
Allow editing of jims and jim order relation.
Definition: poset.cc:230