SheafSystem  0.0.0.0
abstract_poset_member.h
Go to the documentation of this file.
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
20 
21 #ifndef ABSTRACT_POSET_MEMBER_H
22 #define ABSTRACT_POSET_MEMBER_H
23 
24 #ifndef SHEAF_DLL_SPEC_H
25 #include "SheafSystem/sheaf_dll_spec.h"
26 #endif
27 
28 #ifndef POSET_COMPONENT_H
29 #include "SheafSystem/poset_component.h"
30 #endif
31 
32 #ifndef PRIMITIVE_VALUE_H
33 #include "SheafSystem/primitive_value.h"
34 #endif
35 
36 #ifndef STD_IOSTREAM_H
37 #include "SheafSystem/std_iostream.h"
38 #endif
39 
40 #ifndef STD_STRING_H
41 #include "SheafSystem/std_string.h"
42 #endif
43 
44 
45 namespace sheaf
46 {
47 
48 template <typename T> class block;
49 class poset_dof_map;
50 class poset_member_iterator;
51 class poset_path;
52 class schema_poset_member;
53 class sheaves_namespace;
54 class storage_agent;
55 class subposet;
56 class tern;
57 
58 
59 // ============================================================================
60 // CLASS ABSTRACT_POSET_MEMBER_TABLE_DOFS_TYPE
61 // ============================================================================
62 
67 {
68  // ===========================================================
70  // ===========================================================
72 
73 public:
74 
78  typedef unsigned char dof_type;
79 
84 
88  dof_type& operator[] (size_type xi);
89 
93  const dof_type& operator[] (size_type xi) const;
94 
98  table_dofs_type* clone() const;
99 
100 protected:
101 
102 private:
103 
105 };
106 
107 
108 // ============================================================================
109 // CLASS ABSTRACT_POSET_MEMBER_ROW_DOFS_TYPE
110 // ============================================================================
111 
116 {
117  // ===========================================================
119  // ===========================================================
121 
122 public:
123 
127  typedef unsigned char dof_type;
128 
133 
137  dof_type& operator[] (size_type xi);
138 
142  const dof_type& operator[] (size_type xi) const;
143 
147  row_dofs_type* clone() const;
148 
149 protected:
150 
151 private:
152 
154 };
155 
156 
157 // ============================================================================
158 // CLASS ABSTRACT_POSET_MEMBER
159 // ============================================================================
160 
164 class SHEAF_DLL_SPEC abstract_poset_member : public poset_component
165 {
166 
167  friend class cover_set_iterator;
168  friend class filtered_iterator;
169  friend class poset_dft;
170  friend class poset_joiner;
171  friend class poset_orderer;
172  friend class poset_state_handle;
173  friend class postorder_iterator;
174  friend class subposet_joiner;
175  friend class storage_agent;
176  // friend std::ostream & operator << (std::ostream &os, abstract_poset_member& p);
177 
178 
179  // ===========================================================
181  // ===========================================================
183 
184 public:
185 
186  // Typedefs:
187 
192 
196  typedef poset host_type;
197 
203  static host_type& new_host(namespace_type& xns,
204  const poset_path& xhost_path,
205  const poset_path& xschema_path,
206  bool xauto_access);
207 
208 protected:
209 
210 private:
211 
213 
214  // ===========================================================
216  // ===========================================================
218 
219 public:
220 
221  // Typedefs:
222 
227 
232 
233 
237  virtual abstract_poset_member& operator=(const abstract_poset_member& xother);
238 
242  virtual ~abstract_poset_member();
243 
249  abstract_poset_member* clone(bool xnew_state, bool xauto_access = true) const;
250 
251  // EXISTING HANDLE, NEW STATE "CONSTRUCTORS"
252 
259  virtual void new_jim_state(poset_dof_map* xdof_map = 0,
260  bool xcopy_dof_map = false,
261  bool xauto_access = true);
262 
267  virtual void new_jim_state(pod_index_type xtuple_id, bool xauto_access = true);
268 
273  void new_jim_state(const scoped_index& xtuple_id, bool xauto_access = true);
274 
279  virtual void new_jim_state(poset_state_handle* xhost,
280  poset_dof_map* xdof_map = 0,
281  bool xcopy_dof_map = false,
282  bool xauto_access = true);
283 
288  virtual void new_jim_state(poset_state_handle* xhost,
289  pod_index_type xtuple_id,
290  bool xauto_access = true);
291 
296  void new_jim_state(poset_state_handle* xhost,
297  const scoped_index& xtuple_id,
298  bool xauto_access = true);
299 
304  virtual void new_jrm_state(bool xauto_access = true);
305 
310  virtual void new_jrm_state(poset_state_handle* xhost, bool xauto_access = true);
311 
319  virtual void new_jrm_state(const scoped_index* xexpansion,
320  int xexpansion_ct,
321  const tern& xgreatest,
322  bool xauto_access = true);
323 
331  virtual void new_jrm_state(poset_state_handle* xhost,
332  const scoped_index* xexpansion,
333  int xexpansion_ct,
334  const tern& xgreatest,
335  bool xauto_access = true);
336 
337 
342  virtual void new_jem_state(abstract_poset_member* xother,
343  bool xgreatest,
344  bool xauto_access);
345 
350  virtual void new_jem_state(poset_state_handle* xhost,
351  pod_index_type xhub_id,
352  bool xgreatest,
353  bool xauto_access);
354 
359  void new_jem_state(poset_state_handle* xhost,
360  const scoped_index& xid,
361  bool xgreatest,
362  bool xauto_access);
363 
364 protected:
369 
375  virtual void attach_handle_data_members();
376 
380  char* table_dof_ptr(bool xrequire_write_access = false) const;
381 
385  char* row_dof_ptr(bool xrequire_write_access = false);
386 
387 private:
388 
390 
391 
392 
393  // ===========================================================
395  // ===========================================================
397 
398 public:
399 
405  virtual bool is_jim(bool xin_current_version = true) const;
406 
410  virtual bool is_atom() const;
411 
412 protected:
413 
414 private:
415 
417 
418 
419  // ===========================================================
421  // ===========================================================
423 
424 public:
425 
429  virtual schema_poset_member& schema();
430 
434  virtual const schema_poset_member& schema() const;
435 
439  schema_poset_member& schema(bool xauto_access);
440 
444  const schema_poset_member& schema(bool xauto_access) const;
445 
449  virtual schema_poset_member& unrestricted_schema();
450 
454  virtual const schema_poset_member& unrestricted_schema() const;
455 
459  bool schema_is(const std::string& xschema_name) const;
460 
464  bool same_schema(const abstract_poset_member* xother) const;
465 
466 protected:
467 
468 private:
469 
471 
472 
473  // ===========================================================
475  // ===========================================================
477 
478 public:
479 
484  virtual bool is_restricted() const;
485 
490  virtual bool is_same_restriction(const abstract_poset_member* xother) const;
491 
492 protected:
493 
494 private:
495 
497 
498 
499  // ===========================================================
501  // ===========================================================
503 
504 public:
505 
509  virtual int dof_ct() const = 0;
510 
515  virtual poset_dof_map& dof_map(bool xrequire_write_access = false);
516 
521  virtual const poset_dof_map& dof_map(bool xrequire_write_access = false) const;
522 
527  virtual bool dof_map_is_ancestor_of(const poset_dof_map* xdof_map) const;
528 
532  void dof_tuple(const void* xbuf, size_t xbuflen) const;
533 
537  void put_dof_tuple(const void* xbuf, size_t xbuflen);
538 
542  pod_index_type dof_tuple_id(bool xauto_access) const;
543 
547  void dof_tuple_id(scoped_index& result, bool xauto_access) const;
548 
552  void put_dof_tuple_id(pod_index_type xtuple_index, bool xauto_access);
553 
557  void put_dof_tuple_id(const scoped_index& xtuple_index, bool xauto_access);
558 
562  void* table_dofs();
563 
567  const void* table_dofs() const;
568 
572  void* table_dofs(bool xauto_access);
573 
577  const void* table_dofs(bool xauto_access) const;
578 
582  void* row_dofs();
583 
587  const void* row_dofs() const;
588 
592  void* row_dofs(bool xauto_access);
593 
597  const void* row_dofs(bool xauto_access) const;
598 
599 protected:
600 
601 private:
602 
604 
605 
606  // ===========================================================
608  // ===========================================================
610 
611 public:
612 
616  primitive_value dof(pod_index_type xdof_id) const;
617 
621  primitive_value dof(const scoped_index& xdof_id, bool xauto_access) const;
622 
626  void put_dof(pod_index_type xdof_id, const primitive_value& xdof);
627 
631  void put_dof(const scoped_index& xdof_id, const primitive_value& xdof, bool xauto_access);
632 
636  void get_dof(pod_index_type xdof_id, void* xdof, size_type xdof_size) const;
637 
641  void get_dof(const scoped_index& xdof_id, void* xdof, size_type xdof_size, bool xauto_access) const;
642 
646  void put_dof(pod_index_type xdof_id, const void* xdof, size_type xdof_size);
647 
651  void put_dof(const scoped_index& xdof_id, const void* xdof, size_type xdof_size, bool xauto_access);
652 
653 protected:
654 
655 private:
656 
658 
659 
660  // ===========================================================
662  // ===========================================================
664 
665 public:
666 
671  bool le(pod_index_type xother_index) const;
672 
677  bool le(const scoped_index& xother_index) const;
678 
682  bool le(const abstract_poset_member* other) const ;
683 
688  bool leqv(pod_index_type xother_index) const;
689 
694  bool leqv(const scoped_index& xother_index) const;
695 
700  bool lt(pod_index_type xother_index) const;
701 
706  bool lt(const scoped_index& xother_index) const;
707 
711  bool lt(const abstract_poset_member* other) const;
712 
717  bool ge(pod_index_type xother_index) const;
718 
723  bool ge(const scoped_index& xother_index) const;
724 
728  bool ge(const abstract_poset_member* other) const;
729 
734  bool geqv(pod_index_type xother_index) const;
735 
740  bool geqv(const scoped_index& xother_index) const;
741 
746  bool gt(pod_index_type xother_index) const;
747 
752  bool gt(const scoped_index& xother_index) const;
753 
757  bool gt(const abstract_poset_member* other) const;
758 
762  bool is_jem(const abstract_poset_member* xother) const;
763 
767  abstract_poset_member* greatest_jem() const;
768 
772  void greatest_jem_pa( abstract_poset_member* result) const;
773 
777  abstract_poset_member* least_jem() const;
778 
782  void least_jem_pa( abstract_poset_member* result) const;
783 
788  virtual void merge_jem(const abstract_poset_member* xjem);
789 
790 protected:
791 
792 private:
793 
795 
796 
797  // ===========================================================
799  // ===========================================================
801 
802 public:
803 
807  bool covers(const abstract_poset_member* xother) const;
808 
812  bool covers(pod_index_type xhub_id) const;
813 
817  bool covers(const scoped_index& xid) const;
818 
822  virtual void create_cover_link(abstract_poset_member* xlesser);
823 
827  virtual void delete_cover_link(abstract_poset_member* lesser);
828 
833  index_space_handle& get_cover_id_space(bool xlower) const;
834 
838  void release_cover_id_space(index_space_handle& xcover_id_space) const;
839 
844  index_space_iterator& get_cover_id_space_iterator(bool xlower) const;
845 
849  void release_cover_id_space_iterator(index_space_iterator& xcover_itr) const;
850 
855  bool cover_contains_iterator(bool xlower, const index_space_iterator& xitr) const;
856 
861  bool cover_is_empty(bool xlower) const;
862 
867  bool cover_is_singleton(bool xlower) const;
868 
873  virtual size_type cover_ct(bool lower) const;
874 
879  bool cover_contains_member(bool xlower, pod_index_type xother_mbr_index) const;
880 
885  bool cover_contains_member(bool xlower, const scoped_index& xother_mbr_index) const;
886 
893  bool cover_is_equal(bool xlower, pod_index_type xother_mbr_index) const;
894 
901  bool cover_is_equal(bool xlower, const scoped_index& xother_mbr_index) const;
902 
907  pod_index_type first_cover_member(bool xlower) const;
908 
913  void first_cover_member(bool xlower, scoped_index& result) const;
914 
919  void insert_cover_member(pod_index_type xother_mbr_index, bool xlower);
920 
925  void insert_cover_member(const scoped_index& xother_mbr_index, bool xlower);
926 
931  void remove_cover_member(pod_index_type xother_mbr_index, bool xlower);
932 
939  void remove_cover_member(const scoped_index& xother_mbr_index, bool xlower);
940 
945  void remove_cover_member(index_space_iterator& xitr, bool xlower);
946 
951  void clear_cover(bool xlower);
952 
957  void copy_cover(bool xlower, pod_index_type xother_mbr_index);
958 
963  void copy_cover(bool xlower, const scoped_index& xother_mbr_index);
964 
965 protected:
966 
967 private:
968 
970 
971 
972  // ===========================================================
974  // ===========================================================
976 
977 public:
978 
982  int down_ct() const;
983 
988  virtual int down_ct(pod_index_type xfilter_index) const;
989 
994  int down_ct(const scoped_index& xfilter_index) const;
995 
999  virtual subposet* down() const;
1000 
1004  virtual void down_pa(subposet* result) const;
1005 
1010  void delete_down(bool xdelete_exterior = false,
1011  bool xenter_jim_edit_mode = true);
1012 
1016  int up_ct() const;
1017 
1022  virtual int up_ct(pod_index_type xfilter_index) const;
1023 
1028  int up_ct(const scoped_index& xfilter_index) const;
1029 
1033  virtual subposet* up() const;
1034 
1038  virtual void up_pa(subposet* result) const;
1039 
1044  virtual int jim_ct() const;
1045 
1049  virtual subposet* jims();
1050 
1054  virtual void jims_pa(subposet* result);
1055 
1060  virtual int maximal_jim_ct() const;
1061 
1066  virtual subposet* maximal_jims();
1067 
1072  virtual void maximal_jims_pa(subposet* result) const;
1073 
1078  virtual int atom_ct() const;
1079 
1083  virtual subposet* atoms() const;
1084 
1088  virtual void atoms_pa(subposet* result) const;
1089 
1090 protected:
1091 
1092 private:
1093 
1095 
1096 
1097  // ===========================================================
1099  // ===========================================================
1101 
1102 public:
1103 
1108  abstract_poset_member* p_join(abstract_poset_member* other) const;
1109 
1114  virtual void p_join_pa(abstract_poset_member* other, abstract_poset_member* result) const;
1115 
1120  void p_join_sa(abstract_poset_member* other);
1121 
1127 
1132  virtual void p_meet_pa(abstract_poset_member* other, abstract_poset_member* result);
1133 
1138  void p_meet_sa(abstract_poset_member* other);
1139 
1140 protected:
1141 
1142 private:
1143 
1145 
1146 
1147  // ===========================================================
1149  // ===========================================================
1151 
1152 public:
1153 
1159  abstract_poset_member* l_join(abstract_poset_member* other, bool xnew_jem = true);
1160 
1166  void l_join_pa(abstract_poset_member* other, abstract_poset_member* result, bool xnew_jem = true);
1167 
1173  void l_join_sa(abstract_poset_member* other, bool xnew_jem = true);
1174 
1180  abstract_poset_member* l_meet(abstract_poset_member* other, bool xnew_jem = true);
1181 
1187  void l_meet_pa(abstract_poset_member* other, abstract_poset_member* result, bool xnew_jem = true);
1188 
1194  void l_meet_sa(abstract_poset_member* other, bool xnew_jem = true);
1195 
1201  abstract_poset_member* l_not(bool xnew_jem = true) const;
1202 
1203 
1209  void l_not_pa(abstract_poset_member* result, bool xnew_jem = true) const;
1210 
1216  void l_not_sa(bool xnew_jem = true) const;
1217 
1218 protected:
1219 
1220 private:
1221 
1223 
1224 
1225  // ===========================================================
1227  // ===========================================================
1229 
1230 public:
1231 
1233 
1238  virtual bool is_valid_index(const poset_state_handle* xhost,
1239  pod_index_type xhub_id,
1240  int xversion = CURRENT_HOST_VERSION) const;
1241 
1246  bool is_valid_index(const poset_state_handle* xhost,
1247  const scoped_index& xid,
1248  int xversion = CURRENT_HOST_VERSION) const;
1249 
1253  const index_space_family& id_spaces() const;
1254 
1256 
1260  virtual const hub_index_space_handle& hub_id_space() const;
1261 
1266  virtual const scoped_index& hub_id() const;
1267 
1271  virtual scoped_index hub_id(pod_index_type xid) const;
1272 
1276  virtual pod_index_type get_index_from_name(const poset_state_handle* xhost,
1277  const std::string& xname) const;
1278 
1282  virtual void get_index_from_name(const poset_state_handle* xhost,
1283  const std::string& xname,
1284  scoped_index& result) const;
1285 
1286 protected:
1287 
1288 private:
1289 
1291 
1292 
1293  // ===========================================================
1295  // ===========================================================
1297 
1298 public:
1299 
1301 
1302  // using poset_component::name;
1303 
1307  std::string name() const
1308  {
1309  return poset_component::name();
1310  };
1311 
1315  virtual std::string name(bool xauto_access) const;
1316 
1320  virtual void all_names(block<std::string>& xresult, bool xauto_access = false) const;
1321 
1325  virtual size_type name_ct(bool xauto_access) const;
1326 
1330  virtual bool has_name(const std::string& xname, bool xauto_access = false) const;
1331 
1335  virtual void put_name(const std::string& xname, bool xunique, bool xauto_access);
1336 
1340  virtual void delete_name(const std::string& xname, bool xauto_access = false);
1341 
1345  virtual void delete_all_names(bool xauto_access = false);
1346 
1347 protected:
1348 
1349 private:
1350 
1352 
1353 
1354  // ===========================================================
1356  // ===========================================================
1358 
1359 public:
1360 
1362 
1366  void attach_to_state(const namespace_poset* xns,
1367  const poset_path& xpath,
1368  bool xauto_access = true);
1369 
1374  void attach_to_state(const namespace_poset* xnamespace,
1375  pod_index_type xposet_index,
1376  pod_index_type xmember_index,
1377  bool xauto_access = true);
1378 
1383  void attach_to_state(const namespace_poset* xnamespace,
1384  const scoped_index& xposet_index,
1385  const scoped_index& xmember_index,
1386  bool xauto_access = true);
1387 
1391  virtual void delete_state(bool xauto_access = false);
1392 
1393 protected:
1394 
1395 private:
1396 
1398 
1399 
1400  // ===========================================================
1402  // ===========================================================
1404 
1405 public:
1406 
1410  virtual bool is_ancestor_of(const any* other) const;
1411 
1415  virtual abstract_poset_member* clone() const = 0;
1416 
1420  virtual bool invariant() const;
1421 
1422 protected:
1423 
1424 private:
1425 
1427 
1428 
1429  // ===========================================================
1431  // ===========================================================
1433 
1434 public:
1435 
1439  virtual void to_stream(std::ostream& xos = std::cout) const;
1440 
1441 protected:
1442 
1443 private:
1444 
1446 };
1447 
1448 
1449 // ===========================================================
1450 // NONMEMBER FUNCTIONS
1451 // ===========================================================
1452 
1456 template <typename T>
1457 typename T::table_dofs_type& table_dofs(T& x0);
1458 
1462 template <typename T>
1463 const typename T::table_dofs_type& table_dofs(const T& x0);
1464 
1468 template <typename T>
1469 typename T::table_dofs_type& table_dofs(T& x0, bool xauto_access);
1470 
1474 template <typename T>
1475 const typename T::table_dofs_type& table_dofs(const T& x0, bool xauto_access);
1476 
1480 template <typename T>
1481 typename T::row_dofs_type& row_dofs(T& x0);
1482 
1486 template <typename T>
1487 const typename T::row_dofs_type& row_dofs(const T& x0);
1488 
1492 template <typename T>
1493 typename T::row_dofs_type& row_dofs(T& x0, bool xauto_access);
1494 
1498 template <typename T>
1499 const typename T::row_dofs_type& row_dofs(const T& x0, bool xauto_access);
1500 
1504 SHEAF_DLL_SPEC
1505 std::ostream& operator << (std::ostream &os, const abstract_poset_member& p);
1506 
1507 SHEAF_DLL_SPEC
1508 std::ostream& operator << (std::ostream &os, const abstract_poset_member* p);
1509 
1510 } // namespace sheaf
1511 
1512 #endif // ABSTRACT_POSET_MEMBER_H
SHEAF_DLL_SPEC void lower(const met &xmetric, const ed &xvector, ed &xresult, bool xauto_access)
Lower vector (pre-allocated version for persistent type).
Definition: met.cc:943
A client handle for a subposet.
Definition: subposet.h:86
poset host_type
The type of host poset for this type of member.
An abstract iterator over the ids of an id space.
The default name space; a poset which contains other posets as members.
namespace_poset namespace_type
The type of namespace for this type of member.
A three state "bool". Does not provide the operations of ternary logic and is intended for use mostly...
Definition: tern.h:45
A client handle for a general, abstract partially order set.
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
An abstract handle to a space of alternate integer identifiers (aliases) for a subset of a hub set of...
abstract_poset_member_row_dofs_type row_dofs_type
The type of the row dofs.
Features shared by poset_member and subposet. Subposet and poset_member objects can be attached...
std::string name() const
A name for this.
The general, abstract map from dof ids to dof values.
Definition: poset_dof_map.h:59
Dperecated. Use postorder_itr. Specialization of the filtered depth-first iterator which exposes the ...
An implementation of class sum_index_space_handle that has a primary sum id space state...
T::row_dofs_type & row_dofs(T &x0)
The row dofs pod type for x0 (mutable version).
void attach_to_state(const poset_state_handle *xhost, pod_index_type xhub_id)
Attach this handle to the state with hub id xhub_id in the current version of host xhost...
Abstract base class with useful features for all objects.
Definition: any.h:39
abstract_poset_member_table_dofs_type table_dofs_type
The type of the table dofs.
abstract_poset_member_row_dofs_type row_dofs_type
The type of the row dofs (type of this).
A client handle for a mutable partially ordered set.
Definition: poset.h:40
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
unsigned char dof_type
The type of the dofs.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
Row dofs type for class abstract_poset_member.
abstract_poset_member_table_dofs_type table_dofs_type
The type of the table dofs (type of this).
T::table_dofs_type & table_dofs(T &x0)
The table dofs pod type for x0 (mutable version).
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
std::string name() const
OBSOLETE: use name(bool xauto_access). A name for this.
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.
unsigned char dof_type
The type of the dofs.
Abstract object wrapper for an instance of a primitive type.
An abstract client handle for a member of a poset.
Factory and container for a family of id spaces.
Traverser to ensure validity of order relation.
Definition: poset_orderer.h:46
Computes the join of given poset members.
Definition: poset_joiner.h:43
Abstract traverser (internal iterator) for poset which traverses the cover relation graph in depth fi...
Definition: poset_dft.h:44
A client handle for a poset member which has been prepared for use as a schema.
Table dofs type for class abstract_poset_member.
Agent responsible for importing and exporting posets from an external name space which resides on dis...
Definition: storage_agent.h:74