SheafSystem  0.0.0.0
poset_path.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 poset_path
19 
20 #include "SheafSystem/poset_path.h"
21 
22 #include "SheafSystem/assert_contract.h"
23 #include "SheafSystem/namespace_poset.h"
24 #include "SheafSystem/primitive_value.h"
25 #include "SheafSystem/schema_poset_member.h"
26 #include "SheafSystem/std_iostream.h"
27 #include "SheafSystem/std_sstream.h"
28 
29 using namespace sheaf;
30 using namespace std;
31 
32 //#define DIAGNOSTIC_OUTPUT
33 
37 {
38  // Preconditions:
39 
40  // Body:
41 
42  // Nothing to do.
43 
44  // Postconditions:
45 
46  ensure(empty());
47 
48  // Exit:
49 
50  return;
51 }
52 
55 poset_path(const poset_path& xposet_path)
56 {
57 
58  // Preconditions:
59 
60  // Body:
61 
62  *this = xposet_path;
63 
64  // Postconditions:
65 
66  ensure(*this == xposet_path);
67 
68  // Exit:
69 
70  return;
71 }
72 
75 poset_path(const std::string& xposet_name, const std::string& xmember_name)
76 {
77  // Preconditions:
78 
79  require(!xposet_name.empty());
80  require(is_valid_path(xposet_name + delimiter() + xmember_name));
81 
82  // Body:
83 
84  *this = xposet_name + delimiter() + xmember_name;
85 
86  // Postconditions:
87 
88  ensure(poset_name() == xposet_name);
89  ensure(member_name() == xmember_name);
90 
91  // Exit:
92 
93  return;
94 }
95 
99 {
100 
101  // Preconditions:
102 
103 
104  // Body:
105 
106  // Nothing to do.
107 
108  // Postconditions:
109 
110  // Exit:
111 
112  return;
113 }
114 
117 poset_path(const std::string& xpath)
118 {
119  // Preconditions:
120 
121  require(is_valid_path(xpath));
122 
123  // Body:
124 
125  *this = xpath;
126 
127  // Postconditions:
128 
129  ensure(*this == xpath);
130 
131  // Exit:
132 
133  return;
134 }
135 
138 poset_path(const char* xpath)
139 {
140  // Preconditions:
141 
142  require(xpath != 0);
143  require(is_valid_path(xpath));
144 
145  // Body:
146 
147  *this = xpath;
148 
149 
150  // Postconditions:
151 
152  ensure((*this) == xpath);
153 }
154 
158 {
159  // Preconditions:
160 
161  require(xpath.id() == C_STRING);
162  require(is_valid_path(xpath.value().c_string_primitive));
163 
164  // Body:
165 
166  *this = xpath;
167 
168 
169  // Postconditions:
170 
171  ensure((*this) == xpath);
172 }
173 
174 #ifndef DOXYGEN_SHOULD_SKIP_THIS
175 // $$SCRIBBLE kabuch: Warning: member `operator sheaf::primitive_value' of class `poset_path' cannot be found
176 
178 sheaf::poset_path::
179 operator sheaf::primitive_value() const
180 {
181  // Preconditions:
182 
183  // Body:
184 
185  primitive_value result = path().c_str();
186 
187  // Postconditions:
188 
189  ensure(result.id() == C_STRING);
190  ensure(string(result) == path());
191 
192  // Exit:
193 
194  return result;
195 }
196 #endif // ifndef DOXYGEN_SHOULD_SKIP_THIS
197 
201 operator=(const poset_path& xposet_path)
202 {
203  // Preconditions:
204 
205  // Body:
206 
207  _poset_name = xposet_path._poset_name;
208  _member_name = xposet_path._member_name;
209 
210 
211  // Postconditions:
212 
213  ensure(*this == xposet_path);
214 
215  // Exit:
216 
217  return *this;
218 }
219 
220 
224 operator=(const std::string& xpath)
225 {
226  // Preconditions:
227 
228  require(is_valid_path(xpath));
229 
230  // Body:
231 
232  string ldelimiter;
233  parse_path(xpath, _poset_name, ldelimiter, _member_name);
234 
235  // Postconditions:
236 
237  ensure(*this == xpath);
238 
239  // Exit:
240 
241  return *this;
242 }
243 
247 operator=(const char* cpath)
248 {
249  // Preconditions:
250 
251  require(cpath != 0);
252  require(is_valid_path(cpath));
253 
254  // Body:
255 
256  string ldelimiter;
257  parse_path(cpath, _poset_name, ldelimiter, _member_name);
258 
259  // Postconditions:
260 
261  ensure(*this == cpath);
262 
263  // Exit:
264 
265  return *this;
266 }
267 
271 operator=(const primitive_value& xposet_path)
272 {
273  // Preconditions:
274 
275  // Body:
276 
277  *this = xposet_path.value().c_string_primitive;
278 
279  // Postconditions:
280 
281  ensure(*this == xposet_path);
282 
283  // Exit:
284 
285  return *this;
286 }
287 
289 bool
291 empty() const
292 {
293  bool result;
294 
295  // Preconditions:
296 
297  // Body:
298 
299  result = _poset_name.empty() && _member_name.empty();
300 
301  // Postconditions:
302 
303  // Exit
304 
305  return result;
306 }
307 
309 bool
311 full() const
312 {
313  bool result;
314 
315  // Preconditions:
316 
317  // Body:
318 
319  result = !_poset_name.empty() && !_member_name.empty();
320 
321  // Postconditions:
322 
323  // Exit
324 
325  return result;
326 }
327 
329 bool
331 is_valid_name(const std::string& xname)
332 {
333  bool result;
334 
335  // Preconditions:
336 
337  // Body:
338 
339  // result = (!xname.empty() && contains_legal_characters(xname, name_legal_characters()));
340  result = (!xname.empty() && (xname.find_first_not_of(name_legal_characters()) == string::npos));
341 
342  // Postconditions:
343 
344  // ensure(result == (!xname.empty() && contains_legal_characters(xname, name_legal_characters())));
345  ensure(result == (!xname.empty() && (xname.find_first_not_of(name_legal_characters()) == string::npos)));
346 
347  // Exit
348 
349  return result;
350 }
351 
353 bool
355 is_valid_path(const std::string& xpath)
356 {
357 
358  // Preconditions:
359 
360  // Body:
361 
362  bool result = (xpath.find_first_not_of(path_legal_characters()) == string::npos);
363 
364  if(result)
365  {
366  string lposet_name, ldelimiter, lmember_name;
367  parse_path(xpath, lposet_name, ldelimiter, lmember_name);
368  result =
369  lposet_name.empty() ? (ldelimiter.empty() && lmember_name.empty()) : true;
370  }
371 
372  // Postconditions:
373 
374  ensure(result == ((xpath.find_first_not_of(path_legal_characters()) == string::npos) &&
375  (!poset_name(xpath).empty() || (delimiter(xpath).empty() && member_name(xpath).empty()))));
376 
377  // Exit
378 
379  return result;
380 }
381 
383 bool
385 operator==(const poset_path& xother) const
386 {
387  bool result;
388 
389  // Preconditions:
390 
391  // Body:
392 
393  result =
394  (_poset_name == xother._poset_name) && (_member_name == xother._member_name);
395 
396  // Postconditions:
397 
398  return result;
399 }
400 
401 
403 bool
405 operator==(const std::string& xother) const
406 {
407  bool result;
408 
409  // Preconditions:
410 
411  // Body:
412 
413  string lposet_name, ldelimiter, lmember_name;
414  parse_path(xother, lposet_name, ldelimiter, lmember_name);
415  result =
416  (_poset_name == lposet_name) && (_member_name == lmember_name);
417 
418 
419  // Postconditions:
420 
421  return result;
422 }
423 
424 
426 bool
428 operator==(const char* xother) const
429 {
430  bool result;
431 
432  // Preconditions:
433 
434  require(xother != 0);
435 
436  // Body:
437 
438  string lother(xother);
439  result = operator==(lother);
440 
441  // Postconditions:
442 
443  return result;
444 }
445 
446 
448 std::string
450 path() const
451 {
452  // Preconditions:
453 
454  // Body:
455 
456  string result = _poset_name;
457  if(!_member_name.empty())
458  {
459  result += delimiter() + _member_name;
460  }
461 
462  // Postconditions:
463 
464  //ensure(is_valid_path(result));
465 
466  return result;
467 }
468 
469 
471 std::string
473 poset_name() const
474 {
475  // Preconditions:
476 
477  // Body:
478 
479  // Postconditions:
480 
481  // Exit:
482 
483  return _poset_name;
484 }
485 
487 void
489 put_poset_name(const std::string& xname)
490 {
491  // Preconditions:
492 
493  require(is_valid_name(xname));
494 
495  // Body:
496 
497  _poset_name = xname;
498 
499  // Postconditions:
500 
501  ensure(poset_name() == xname);
502 
503  // Exit:
504 
505  return;
506 }
507 
509 std::string
511 member_name() const
512 {
513  // Preconditions:
514 
515  // Body:
516 
517  // Postconditions:
518 
519  return _member_name;
520 
521 }
522 
524 void
526 put_member_name(const std::string& xname)
527 {
528  // Preconditions:
529 
530  require(is_valid_name(xname));
531 
532  // Body:
533 
534  _member_name = xname;
535 
536  // Postconditions:
537 
538  ensure(member_name() == xname);
539 
540  // Exit:
541 
542  return;
543 }
544 
545 const std::string&
548 {
549  // cout << endl << "Entering poset_path::name_legal_characters." << endl;
550 
551  // Preconditions:
552 
553 
554  // Body:
555 
556  // @hack temporarily allow characters other than [A-Za-z0-9_] in
557  // poset and poset member names, until we get a chance to purge all
558  // the offending names in the standard name spaces and examples.
559 
560  static const string result("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_ -,.=+()*:?");
561 
562  // Postconditions:
563 
564  ensure(result == "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_ -,.=+()*:?");
565 
566  // Exit:
567 
568  // cout << "Leaving poset_path::name_legal_characters." << endl;
569  return result;
570 }
571 
572 
573 char
576 {
577  // cout << endl << "Entering poset_path::delimiter." << endl;
578 
579  // Preconditions:
580 
581 
582  // Body:
583 
584  char result = '/';
585 
586  // Postconditions:
587 
588  ensure(result == '/');
589 
590  // Exit:
591 
592  // cout << "Leaving poset_path::delimiter." << endl;
593  return result;
594 }
595 
596 const std::string&
599 {
600  // cout << endl << "Entering poset_path::path_legal_characters." << endl;
601 
602  // Preconditions:
603 
604 
605  // Body:
606 
607  static const string result(name_legal_characters() + delimiter());
608 
609  // Postconditions:
610 
611  ensure(result == (name_legal_characters() + delimiter()));
612 
613  // Exit:
614 
615  // cout << "Leaving poset_path::path_legal_characters." << endl;
616  return result;
617 }
618 
619 std::string
621 poset_name(const std::string& xpath)
622 {
623  // cout << endl << "Entering poset_path::poset_name." << endl;
624 
625  // Preconditions:
626 
627 
628  // Body:
629 
630  string result, ldelim, lmbr_name;
631 
632  parse_path(xpath, result, ldelim, lmbr_name);
633 
634  // Postconditions:
635 
636 
637  // Exit:
638 
639  // cout << "Leaving poset_path::poset_name." << endl;
640  return result;
641 }
642 
643 std::string
645 delimiter(const std::string& xpath)
646 {
647  // cout << endl << "Entering poset_path::delimiter." << endl;
648 
649  // Preconditions:
650 
651 
652  // Body:
653 
654  string lposet_name, result, lmbr_name;
655 
656  parse_path(xpath, lposet_name, result, lmbr_name);
657 
658  // Postconditions:
659 
660 
661  // Exit:
662 
663  // cout << "Leaving poset_path::delimiter." << endl;
664  return result;
665 }
666 
667 
668 std::string
670 member_name(const std::string& xpath)
671 {
672  // cout << endl << "Entering poset_path::member_name." << endl;
673 
674  // Preconditions:
675 
676 
677  // Body:
678 
679  string lposet_name, ldelim, result;
680 
681  parse_path(xpath, lposet_name, ldelim, result);
682 
683  // Postconditions:
684 
685  ensure(delimiter(xpath).empty() ? result.empty() : true);
686 
687  // Exit:
688 
689  // cout << "Leaving poset_path::member_name." << endl;
690  return result;
691 }
692 
693 
695 void
697 to_stream(ostream& xos) const
698 {
699  xos << *this;
700 }
701 
703 std::string
705 make_name(const std::string& xprefix, int xindex, const std::string& xsuffix)
706 {
707  string result;
708 
709  // Preconditions:
710 
711 
712  // Body:
713 
714  stringstream lname_stream;
715  lname_stream << xprefix << xindex << xsuffix;
716  lname_stream >> result;
717 
718  // Postconditions:
719 
720  ensure(!result.empty());
721  ensure(!xprefix.empty() ? result.find(xprefix) == 0 : true);
722  ensure(!xsuffix.empty() ?
723  (result.find(xsuffix) + xsuffix.size()) == result.size() : true);
724 
725  // Exit:
726 
727  return result;
728 }
729 
731 std::string
733 make_reserved_name(const std::string& xprefix, const size_t& xindex, const std::string& xsuffix)
734 {
735  // Preconditions:
736 
737  // Body:
738 
739  // Postconditions:
740 
741  ensure(postcondition_of(make_name(reserved_prefix()+xprefix, xindex, xsuffix)));
742 
743  // Exit:
744 
745  return make_name(reserved_prefix()+xprefix, xindex, xsuffix);
746 }
747 
749 std::string
751 block_name(const size_t& xindex)
752 {
753  string result;
754 
755  // Preconditions:
756 
757  require(index_traits<size_t>::is_valid(xindex));
758 
759  // Body:
760 
761  result = make_name(block_prefix(), xindex, "");
762 
763  // Postconditions:
764 
765  ensure(!result.empty());
766  ensure(result.find(block_prefix()) == 0);
767 
768  // Exit:
769 
770  return result;
771 }
772 
773 
774 
776 std::string
778 block_name(const std::string& xneighborhood_name)
779 {
780  string result;
781 
782  // Preconditions:
783 
784  require(xneighborhood_name.find(neighborhood_prefix()) != string::npos);
785 
786  // Body:
787 
788  result = xneighborhood_name.substr(neighborhood_prefix().size());
789 
790  // Postconditions:
791 
792  ensure(!result.empty());
793  ensure(result.find(block_prefix()) == 0);
794 
795  // Exit:
796 
797  return result;
798 }
799 
800 
801 
803 std::string
805 block_neighborhood_name(const size_t& xindex)
806 {
807  string result;
808 
809  // Preconditions:
810 
811  require(index_traits<size_t>::is_valid(xindex));
812 
813  // Body:
814 
815  result = neighborhood_prefix() + block_name(xindex);
816 
817  // Postconditions:
818 
819  ensure(!result.empty());
820  ensure(result.find(neighborhood_prefix()) == 0);
821 
822  // Exit:
823 
824  return result;
825 }
826 
827 
828 
830 std::string
832 block_neighborhood_name(const std::string& xblock_name)
833 {
834  string result;
835 
836  // Preconditions:
837 
838  ensure(xblock_name.find(block_prefix()) == 0);
839 
840  // Body:
841 
842  result = neighborhood_prefix() + xblock_name;
843 
844  // Postconditions:
845 
846  ensure(!result.empty());
847  ensure(result.find(neighborhood_prefix()) == 0);
848 
849  // Exit:
850 
851  return result;
852 }
853 
855 size_t
857 block_id(const std::string& xname)
858 {
859  size_t result;
860 
861  // Preconditions:
862 
863  require(xname.find(block_prefix()) != string::npos);
864 
865  // Body:
866 
867  stringstream lname_stream;
868  string lblock_prefix = block_prefix();
869  lname_stream << xname.substr(xname.find(lblock_prefix) + lblock_prefix.size());
870  lname_stream >> result;
871 
872  // Postconditions:
873 
874  // Exit:
875 
876  return result;
877 }
878 
879 
881 std::string
884 {
885 
886  // Preconditions:
887 
888 
889  // Body:
890 
891  string result("__");
892 
893  // Postconditions:
894 
895 
896  // Exit:
897 
898  return result;
899 }
900 
901 
902 
904 std::string
907 {
908 
909  // Preconditions:
910 
911 
912  // Body:
913 
914  string result(reserved_prefix() + "bdy_of_");
915 
916  // Postconditions:
917 
918 
919  // Exit:
920 
921  return result;
922 }
923 
925 std::string
927 boundary_name(const std::string& xmbr_name)
928 {
929  string result;
930 
931  // Preconditions:
932 
933  // Body:
934 
935  result = boundary_prefix() + xmbr_name;
936 
937  // Postconditions:
938 
939  ensure(!result.empty());
940  ensure(result.find(boundary_prefix()) == 0);
941 
942  // Exit:
943 
944  return result;
945 }
946 
948 std::string
951 {
952 
953  // Preconditions:
954 
955 
956  // Body:
957 
958  string result(reserved_prefix() + "block_");
959 
960  // Postconditions:
961 
962 
963  // Exit:
964 
965  return result;
966 }
967 
968 
969 
971 std::string
974 {
975 
976  // Preconditions:
977 
978 
979  // Body:
980 
981  string result(reserved_prefix() + "neighborhood_of_");
982 
983  // Postconditions:
984 
985 
986  // Exit:
987 
988  return result;
989 }
990 
995 {
996  namespace_poset* result;
997 
998  // Preconditions:
999 
1000  // Body:
1001 
1003 
1004  // Postconditions:
1005 
1006  ensure(result == namespace_poset::current_namespace());
1007 
1008  // Exit:
1009 
1010  return result;
1011 }
1012 
1013 
1015 bool
1017 state_exists(bool xauto_access) const
1018 {
1019  bool result;
1020 
1021  // Preconditions:
1022 
1023  require(current_namespace() != 0);
1024  require(xauto_access || current_namespace()->state_is_read_accessible());
1025 
1026  // Body:
1027 
1028  result = !_poset_name.empty();
1029  if(result)
1030  {
1031  if(!_member_name.empty())
1032  {
1033  result = current_namespace()->contains_poset_member(*this, xauto_access);
1034  }
1035  else
1036  {
1037  result = current_namespace()->contains_poset(*this, xauto_access);
1038  }
1039  }
1040 
1041  // Postconditions:
1042 
1043 
1044  // Exit:
1045 
1046  return result;
1047 }
1048 
1049 
1051 bool
1053 poset_exists(bool xauto_access) const
1054 {
1055  bool result;
1056 
1057  // Preconditions:
1058 
1059  require(current_namespace() != 0);
1060  require(xauto_access || current_namespace()->state_is_read_accessible());
1061 
1062  // Body:
1063 
1064  result = !empty() && state_exists(xauto_access);
1065 
1066  // Postconditions:
1067 
1068 
1069  // Exit:
1070 
1071  return result;
1072 }
1073 
1074 
1075 
1077 bool
1079 member_exists(bool xauto_access) const
1080 {
1081  bool result;
1082 
1083  // Preconditions:
1084 
1085  require(current_namespace() != 0);
1086  require(xauto_access || current_namespace()->state_is_read_accessible());
1087 
1088  // Body:
1089 
1090  result = full() && state_exists(xauto_access);
1091 
1092  // Postconditions:
1093 
1094 
1095  // Exit:
1096 
1097  return result;
1098 }
1099 
1101 bool
1103 state_is_read_accessible(bool xauto_access) const
1104 {
1105  bool result;
1106 
1107  // Preconditions:
1108 
1109  require(current_namespace() != 0);
1110  require(xauto_access || current_namespace()->state_is_read_accessible());
1111  require(state_exists(xauto_access));
1112 
1113  // Body:
1114 
1115  result =
1116  current_namespace()->member_poset(*this, xauto_access).state_is_read_accessible();
1117 
1118  // Postconditions:
1119 
1120 
1121  // Exit:
1122 
1123  return result;
1124 }
1125 
1127 bool
1129 state_is_read_write_accessible(bool xauto_access) const
1130 {
1131  bool result;
1132 
1133  // Preconditions:
1134 
1135  require(current_namespace() != 0);
1136  require(xauto_access || current_namespace()->state_is_read_accessible());
1137  require(state_exists(xauto_access));
1138 
1139  // Body:
1140 
1141  result =
1142  current_namespace()->member_poset(*this, xauto_access).state_is_read_write_accessible();
1143 
1144  // Postconditions:
1145 
1146 
1147  // Exit:
1148 
1149  return result;
1150 }
1151 
1153 bool
1155 conforms_to(const poset_path& xother, bool xauto_access) const
1156 {
1157  bool result;
1158 
1159  // Preconditions:
1160 
1161  require(current_namespace() != 0);
1162  require(xauto_access || current_namespace()->state_is_read_accessible());
1163  require(state_exists(xauto_access));
1164  require(xauto_access || state_is_read_accessible(xauto_access));
1165  require(xother.state_exists(xauto_access));
1166  require(xauto_access || xother.state_is_read_accessible(xauto_access));
1167 
1168  // Body:
1169 
1170  result = poset_name() == xother.poset_name();
1171 
1172  if(result)
1173  {
1174 
1175  schema_poset_member lthis_schema(current_namespace(), *this, xauto_access);
1176  schema_poset_member lother_schema(current_namespace(), *this, xauto_access);
1177 
1178  if(xauto_access)
1179  {
1180  lthis_schema.get_read_access();
1181  }
1182 
1183  result = lthis_schema.conforms_to(lother_schema);
1184 
1185  if(xauto_access)
1186  {
1187  lthis_schema.release_access();
1188  }
1189 
1190  lthis_schema.detach_from_state();
1191  lother_schema.detach_from_state();
1192  }
1193 
1194  // Postconditions:
1195 
1196 
1197  // Exit:
1198 
1199  return result;
1200 }
1201 
1203 bool
1205 conforms_to(const namespace_poset& xns, const poset_path& xother, bool xauto_access) const
1206 {
1207  bool result;
1208 
1209  // Preconditions:
1210 
1211  require(xns.state_is_auto_read_accessible(xauto_access));
1212  require(xns.contains_path(*this, xauto_access));
1213  require(xns.member_poset(*this, xauto_access).state_is_auto_read_accessible(xauto_access));
1214  require(xns.contains_path(xother, xauto_access));
1215  require(xns.member_poset(xother, xauto_access).state_is_auto_read_accessible(xauto_access));
1216 
1217  // Body:
1218 
1219  result = schema_poset_member::conforms_to(xns, *this, xother, xauto_access);
1220 
1221  // Postconditions:
1222 
1223 
1224  // Exit:
1225 
1226  return result;
1227 }
1228 
1229 
1230 // ===========================================================
1231 // PRIVATE MEMBER FUNCTIONS
1232 // ===========================================================
1233 
1234 // bool
1235 // sheaf::poset_path::
1236 // contains_legal_characters(const std::string& xname, const std::string& xlegal_chars)
1237 // {
1238 // bool result;
1239 
1240 // // Preconditions:
1241 
1242 // // Body:
1243 
1244 // string::size_type lindex = xname.find_first_not_of(xlegal_chars);
1245 
1246 // #ifdef DIAGNOSTIC_OUTPUT
1247 // if(lindex != string::npos)
1248 // {
1249 // cout << "poset_path::contains_name_legal_characters illegal char in name:" << xname
1250 // << " position: " << lindex
1251 // << " char '" << xname[lindex] << "'"
1252 // << endl;
1253 // }
1254 // #endif
1255 
1256 // result = (lindex == string::npos);
1257 
1258 // // Postconditions:
1259 
1260 // ensure(result == (xname.find_first_not_of(xlegal_chars) == string::npos));
1261 
1262 // // Exit
1263 
1264 // return result;
1265 // }
1266 
1268 void
1269 sheaf::poset_path::
1270 parse_path(const std::string& xpath,
1271  std::string& xposet_name,
1272  std::string& xdelimiter,
1273  std::string& xmember_name)
1274 {
1275 
1276  // Preconditions:
1277 
1278  // Body:
1279 
1280  xposet_name.clear();
1281  xmember_name.clear();
1282 
1283  string::const_iterator itr = xpath.begin();
1284  while((itr != xpath.end()))
1285  {
1286  char c = *itr;
1287  ++itr;
1288  if(c == delimiter())
1289  {
1290  xdelimiter = c;
1291  break;
1292  }
1293  else
1294  {
1295  xposet_name.push_back(c);
1296  }
1297  }
1298 
1299  while((itr != xpath.end()))
1300  {
1301  xmember_name.push_back(*itr);
1302  ++itr;
1303  }
1304 
1305  // Postconditions:
1306 
1307  ensure(xdelimiter.empty() ? xmember_name.empty() : true);
1308 
1309  // Exit
1310 
1311  return;
1312 }
1313 
1314 
1315 // ===========================================================
1316 // NON-MEMBER FUNCTIONS
1317 // ===========================================================
1318 
1319 std::ostream&
1320 sheaf::
1321 operator << (std::ostream& xos, const poset_path& xpp)
1322 {
1323  xos << xpp.path();
1324 
1325  return xos;
1326 }
1327 
1328 bool
1329 sheaf::
1330 operator==(const poset_path& xpath, const primitive_value& xprim)
1331 {
1332  require(xprim.id() == C_STRING);
1333  return xpath.path() == xprim.value().c_string_primitive;
1334 }
1335 
1336 bool
1337 sheaf::
1338 operator==(const primitive_value& xprim, const poset_path& xpath)
1339 {
1340  require(xprim.id() == C_STRING);
1341  return xpath.path() == xprim.value().c_string_primitive;
1342 }
1343 
1344 size_t
1345 sheaf::
1346 deep_size(const poset_path& xpath, bool xinclude_shallow)
1347 {
1348  size_t result;
1349 
1350  // Preconditions:
1351 
1352  // Body:
1353 
1356 
1357  result = 0;
1358 
1359  // Postconditions:
1360 
1361  ensure(result == 0);
1362  //ensure(result >= 0);
1363 
1364  // Exit
1365 
1366  return result;
1367 }
1368 
static std::string block_prefix()
Prefix for identifying blocks.
Definition: poset_path.cc:950
poset_path & operator=(const poset_path &xposet_path)
Assignment from poset_path.
Definition: poset_path.cc:201
bool full() const
True if both poset name and member name are not empty.
Definition: poset_path.cc:311
bool state_is_read_accessible(bool xauto_access) const
Definition: poset_path.cc:1103
static std::string make_name(const std::string &xprefix, int xindex, const std::string &xsuffix)
Creates a string xprefix_xindex_xsuffix.
Definition: poset_path.cc:705
static std::string boundary_name(const std::string &xmbr_name)
Creates the standard boundary name associated with the member with name xmbr_name.
Definition: poset_path.cc:927
bool conforms_to(const schema_poset_member &xother) const
True if the dofs defined by this agree in type and in order with the dofs defined by xother...
~poset_path()
Destructor.
Definition: poset_path.cc:98
The default name space; a poset which contains other posets as members.
static char delimiter()
The path delimiter; used to separate poset name from member name.
Definition: poset_path.cc:575
bool state_is_auto_read_accessible(bool xauto_access) const
True if the state is auto accessible for read, that is, if the state is already accessible for read o...
static const std::string & name_legal_characters()
The characters a name is allowed to contain.
Definition: poset_path.cc:547
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
static std::string block_neighborhood_name(const size_t &xindex)
Creates the standard name for the neighborhood of the block with index xindex.
Definition: poset_path.cc:805
STL namespace.
virtual void get_read_access() const
Get read access to the state associated with this.
poset_state_handle & member_poset(pod_index_type xhub_id, bool xauto_access=true) const
The poset_state_handle object referred to by hub id xhub_id.
static namespace_poset * current_namespace()
The current default namespace.
Features describing T as an index type.
Definition: index_traits.h:38
namespace_poset * current_namespace() const
Definition: poset_path.cc:994
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 state_is_read_write_accessible(bool xauto_access) const
Definition: poset_path.cc:1129
bool conforms_to(const poset_path &xother, bool xauto_access) const
True if the schema member this refers to conforms to the schema member xother refers to in the curren...
Definition: poset_path.cc:1155
void put_member_name(const std::string &xname)
Sets member_name() to xname.
Definition: poset_path.cc:526
virtual void detach_from_state()
Detach this handle from its state, if any.
SHEAF_DLL_SPEC size_t deep_size(const dof_descriptor_array &xp, bool xinclude_shallow=true)
The deep size of the referenced object of type dof_descriptor_array.
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.
static std::string boundary_prefix()
Prefix for identifying boundary members.
Definition: poset_path.cc:906
static size_t block_id(const std::string &xname)
Extracts the index from a block name or block neighborhood name.
Definition: poset_path.cc:857
bool state_exists(bool xauto_access) const
Definition: poset_path.cc:1017
static std::string reserved_prefix()
Prefix for identifying member names reserved by the sheaf system.
Definition: poset_path.cc:883
static bool is_valid_path(const std::string &xpath)
True if xpath is empty, or if not empty, contains only legal characters and contains just a poset nam...
Definition: poset_path.cc:355
void to_stream(std::ostream &xos=std::cout) const
Write instance information to an ostream (default = stdout).
Definition: poset_path.cc:697
bool empty() const
True if both poset name and member name are empty.
Definition: poset_path.cc:291
void put_poset_name(const std::string &xname)
Sets poset_name() to xname.
Definition: poset_path.cc:489
bool operator==(const poset_path &xother) const
True if this specifies the same poset and member as xother.
Definition: poset_path.cc:385
primitive_buffer_type & value()
The value of this.
bool member_exists(bool xauto_access) const
Definition: poset_path.cc:1079
bool operator==(const singly_linked_list< T, Alloc > &lhs, const singly_linked_list< T, Alloc > &rhs)
Checks if the contents of lhs and rhs are equal, that is, whether lhs.size() == rhs.size() and each element in lhs compares equal with the element in rhs at the same position.
primitive_type & id()
Type id of the primitive type.
bool poset_exists(bool xauto_access) const
Definition: poset_path.cc:1053
std::string member_name() const
The member name part of the path.
Definition: poset_path.cc:511
SHEAF_DLL_SPEC std::ostream & operator<<(std::ostream &os, const dof_descriptor_array &p)
Insert dof_descriptor_array& p into ostream& os.
Namespace for the sheaves component of the sheaf system.
poset_path()
Default constructor.
Definition: poset_path.cc:36
static bool is_valid_name(const std::string &xname)
True if xname is not empty and contains only name legal characters.
Definition: poset_path.cc:331
Abstract object wrapper for an instance of a primitive type.
std::string path() const
The full path as a string.
Definition: poset_path.cc:450
static std::string neighborhood_prefix()
Prefix for identifying neighborhoods.
Definition: poset_path.cc:973
static const std::string & path_legal_characters()
The characters a path is allowed to contain.
Definition: poset_path.cc:598
static std::string block_name(const size_t &xindex)
Creates the standard name for the block with index xindex.
Definition: poset_path.cc:751
A client handle for a poset member which has been prepared for use as a schema.
static std::string make_reserved_name(const std::string &xprefix, const size_t &xindex, const std::string &xsuffix)
Creates a string reserved_prefix()_xprefix_xindex_xsuffix.
Definition: poset_path.cc:733