SheafSystem  0.0.0.0
subposet.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 SUBPOSET_H
22 #define SUBPOSET_H
23 
24 #ifndef SHEAF_DLL_SPEC_H
25 #include "SheafSystem/sheaf_dll_spec.h"
26 #endif
27 
28 #ifndef SCATTERED_INSERTION_INDEX_SPACE_HANDLE_H
29 #include "SheafSystem/scattered_insertion_index_space_handle.h"
30 #endif
31 
32 #ifndef STD_UNORDERED_SET_H
33 #include "SheafSystem/std_unordered_set.h"
34 #endif
35 
36 #ifndef POSET_COMPONENT_H
37 #include "SheafSystem/poset_component.h"
38 #endif
39 
40 #ifndef STD_STRING_H
41 #include "SheafSystem/std_string.h"
42 #endif
43 
44 #ifndef STD_IOSTREAM_H
45 #include "SheafSystem/std_iostream.h"
46 #endif
47 
48 #ifndef SUBPOSET_STATE_H
49 #include "SheafSystem/subposet_state.h"
50 #endif
51 
52 #ifndef ZN_TO_BOOL_H
53 #include "SheafSystem/zn_to_bool.h"
54 #endif
55 
56 namespace sheaf
57 {
58 
59 template <typename T> class block;
60 template <typename T> class depth_first_itr;
61 class abstract_poset_member;
62 class depth_first_iterator;
63 class dof_descriptor_array;
64 class index_iterator;
65 class poset;
66 class poset_member;
67 class poset_member_iterator;
68 class primitives_poset_schema;
69 class section_space_schema_subposet;
70 class storage_agent;
71 class subposet_member_iterator;
72 
86 class SHEAF_DLL_SPEC subposet : public poset_component
87 {
88 
89  friend class abstract_poset_member;
90  friend class depth_first_iterator;
91  template<typename T>
92  friend class depth_first_itr; // needs members()
93  friend class filtered_depth_first_iterator;
94  friend class poset_state_handle;
95  friend class postorder_iterator;
96  friend class preorder_iterator;
97  friend class primitives_poset_schema;
98  friend class section_space_schema_subposet;
99  friend class storage_agent;
100  friend class subposet_names_record;
101  friend class id_space_names_record;
102  friend class subposet_member_iterator;
103  friend SHEAF_DLL_SPEC std::ostream & operator << (std::ostream &os, const subposet& s);
104 
105  // ===========================================================
107  // ===========================================================
109 
110 public:
111 
115  subposet();
116 
122  subposet(const subposet& xother, bool xdeep_copy = false);
123 
124  // NEW HANDLE, NEW STATE CONSTRUCTORS
125 
132  explicit subposet(poset_state_handle* xhost,
133  const block<pod_index_type>* xmembers = 0,
134  bool xauto_access = true);
135 
143  const block<scoped_index>& xmembers,
144  bool xauto_access);
145 
146  // NEW HANDLE, EXISTING STATE CONSTRUCTORS
147 
152  subposet(const poset_state_handle* xhost, pod_index_type xhub_id);
153 
158  subposet(const poset_state_handle* xhost, const scoped_index& xid);
159 
164  subposet(const poset_state_handle* xhost, const std::string& xname);
165 
169  ~subposet();
170 
174  virtual subposet& operator=(const subposet& xother);
175 
176  // EXISTING HANDLE, NEW STATE "CONSTRUCTORS"
177 
183  virtual void new_state(bool xinitialize = true, bool xauto_access = true);
184 
189  virtual void new_state(const block<pod_index_type>& xmembers, bool xauto_access = true);
190 
195  virtual void new_state(const block<scoped_index>& xmembers, bool xauto_access = true);
196 
202  virtual void new_state(poset_state_handle* xhost,
203  bool xinitialize = true,
204  bool xauto_access = true);
205 
210  virtual void new_state(poset_state_handle* xhost,
211  const block<pod_index_type>& xmembers,
212  bool xauto_access = true);
213 
218  virtual void new_state(poset_state_handle* xhost,
219  const block<scoped_index>& xmembers,
220  bool xauto_access = true);
221 
222 protected:
223 
224 private:
225 
227 
228 
229  // ===========================================================
231  // ===========================================================
233 
234 public:
235 
239  const scattered_insertion_index_space_handle& id_space() const;
240 
245 
249  virtual scattered_insertion_index_space_handle& new_id_space(const std::string& xstate_class_name);
250 
254  virtual bool has_id_space() const;
255 
259  bool is_persistent() const;
260 
264  void put_is_persistent(bool xvalue);
265 
266 protected:
267 
271  virtual std::string id_space_name() const;
272 
276  void attach_id_space();
277 
278 private:
279 
281 
282 
283  // ===========================================================
285  // ===========================================================
287 
288 public:
289 
293  virtual bool is_dof_subposet() const;
294 
298  virtual void put_is_dof_subposet(bool xis_dof_subposet);
299 
304  virtual int dof_ct() const;
305 
310  virtual void put_dof_ct(int xct);
311 
315  virtual dof_descriptor_array* dof_descriptors() const;
316 
320  virtual void put_dof_descriptors(const dof_descriptor_array* xoffsets);
321 
322 protected:
323 
324 private:
325 
327 
328 
329  // ===========================================================
331  // ===========================================================
333 
334 public:
335 
339  int member_ct() const;
340 
344  subposet_member_iterator* member_iterator() const;
345 
349  virtual index_iterator indexed_member_iterator() const;
350 
354  virtual bool contains_member(pod_index_type xmbr_hub_id) const;
355 
359  bool contains_member(const scoped_index& xmbr_id) const;
360 
364  bool contains_member(const std::string& xname) const;
365 
369  bool contains_members(const block<pod_index_type>& xmbr_hub_ids) const;
370 
374  bool contains_members(const block<scoped_index>& xmbr_ids) const;
375 
379  bool contains_member(const abstract_poset_member* xmbr) const;
380 
384  virtual void insert_member(pod_index_type xmbr_hub_id);
385 
389  void insert_member(const scoped_index& xmbr_id);
390 
394  virtual void insert_members(const block<pod_index_type>& xmbr_hub_ids);
395 
399  virtual void insert_members(const block<scoped_index>& xmbr_ids);
400 
404  virtual void insert_member(const abstract_poset_member* xmbr);
405 
409  virtual void remove_member(pod_index_type xmbr_hub_id);
410 
414  void remove_member(const scoped_index& xmbr_id);
415 
419  virtual void remove_member(const abstract_poset_member* xmbr);
420 
421 protected:
422 
426  zn_to_bool* members() const;
427 
431  zn_to_bool::word_t* membership() const;
432 
433 // ///
434 // /// True if all the members of other are also members of this.
435 // ///
436 // bool includes(const list_cover_set* other) const;
437 
438 private:
439 
441 
442 
443  // ===========================================================
445  // ===========================================================
447 
448 public:
449 
453  bool is_empty() const;
454 
458  void make_empty();
459 
463  bool is_equal_to(const subposet* other) const;
464 
468  void make_equal_to(const subposet* other);
469 
473  bool includes(const subposet* other) const;
474 
478  subposet* p_union(const subposet* other);
479 
483  void p_union_pa(const subposet* other, subposet* result);
484 
488  void p_union_sa(const subposet* other);
489 
493  subposet* p_intersection(const subposet* other);
494 
498  void p_intersection_pa(const subposet* other, subposet* result);
499 
503  void p_intersection_sa(const subposet* other);
504 
508  subposet* p_minus(const subposet* other);
509 
513  void p_minus_pa(const subposet* other, subposet* result);
514 
518  void p_minus_sa(const subposet* other);
519 
523  subposet* p_not();
524 
528  void p_not_pa(subposet* result);
529 
533  void p_not_sa();
534 
535 protected:
536 
537 private:
538 
540 
541 
542  // ===========================================================
544  // ===========================================================
546 
547 public:
548 
552  subposet* extremals(bool xmaximals);
553 
557  void extremals_pa(bool xmaximals, subposet* result);
558 
562  subposet* maximals();
563 
567  void maximals_pa(subposet* result);
568 
572  subposet* minimals();
573 
577  void minimals_pa(subposet* result);
578 
582  subposet* down() const;
583 
587  void down_pa(subposet* result) const;
588 
589  // The down set of this subposet, self-allocated
590  // void down_sa();
591 
595  subposet* up() const;
596 
600  void up_pa(subposet* result) const;
601 
602  // The up set of this subposet, self-allocated
603  // void up_sa();
604 
608  subposet* jims();
609 
613  void jims_pa(subposet* result);
614 
619  subposet* maximal_jims();
620 
625  void maximal_jims_pa(subposet* result);
626 
631  subposet* minimal_jims();
632 
637  void minimal_jims_pa(subposet* result);
638 
643  poset_member* p_join();
644 
649  void p_join_pa(abstract_poset_member* result);
650 
655  poset_member* p_meet();
656 
661  void p_meet_pa(abstract_poset_member* result);
662 
663 protected:
664 
665 private:
666 
668 
669 
670  // ===========================================================
672  // ===========================================================
674 
675 public:
676 
682  poset_member* l_join(bool xnew_jem = true);
683 
689  void l_join_pa(abstract_poset_member* result, bool xnew_jem = true);
690 
695  poset_member* l_join_jims(bool xnew_jem = true);
696 
701  void l_join_jims_pa(abstract_poset_member* result, bool xnew_jem = true);
702 
708  poset_member* l_meet(bool xnew_jem = true);
709 
715  void l_meet_pa(abstract_poset_member* result, bool xnew_jem = true);
716 
717 protected:
718 
719 private:
720 
722 
723 
724  // ===========================================================
726  // ===========================================================
728 
729 public:
730 
732 
737  virtual bool is_valid_index(const poset_state_handle* xhost,
738  pod_index_type xhub_id,
739  int xversion = CURRENT_HOST_VERSION) const;
740 
745  bool is_valid_index(const poset_state_handle* xhost,
746  const scoped_index& xid,
747  int xversion = CURRENT_HOST_VERSION) const;
748 
752  virtual const hub_index_space_handle& hub_id_space() const;
753 
758  virtual const scoped_index& hub_id() const;
759 
763  virtual scoped_index hub_id(pod_index_type xid) const;
764 
768  virtual pod_index_type get_index_from_name(const poset_state_handle* xhost,
769  const std::string& xname) const;
770 
774  virtual void get_index_from_name(const poset_state_handle* xhost,
775  const std::string& xname,
776  scoped_index& result) const;
777 
778 protected:
779 
780 private:
781 
783 
784 
785  // ===========================================================
787  // ===========================================================
789 
790 public:
791 
793 
794  // using poset_component::name;
795 
796  std::string name() const
797  {
798  return poset_component::name();
799  };
800 
804  virtual std::string name(bool xauto_access) const;
805 
809  virtual void all_names(block<std::string>& xresult, bool xauto_access = false) const;
810 
814  virtual size_type name_ct(bool xauto_access) const;
815 
819  virtual bool has_name(const std::string& xname, bool xauto_access = false) const;
820 
824  virtual void put_name(const std::string& xname, bool xunique, bool xauto_access);
825 
829  virtual void delete_name(const std::string& xname, bool xauto_access = false);
830 
834  virtual void delete_all_names(bool xauto_access = false);
835 
836 protected:
837 
838 private:
839 
841 
842 
843  // ===========================================================
845  // ===========================================================
847 
848 public:
849 
853  virtual void delete_state(bool xauto_access = false);
854 
855 protected:
856 
857 private:
858 
860 
861 
862  // ===========================================================
864  // ===========================================================
866 
867 public:
868 
872  virtual bool is_ancestor_of(const any* other) const;
873 
878  virtual subposet* clone() const;
879 
883  virtual bool invariant() const;
884 
885 protected:
886 
887 private:
888 
890 
891 
892  // ===========================================================
894  // ===========================================================
896 
897 public:
898 
902  void to_stream(std::ostream& os = std::cout);
903 
907  std::string to_string();
908 
909 protected:
910 
911 private:
912 
914 };
915 
916 
917 // ===========================================================
918 // NON-MEMBER FUNCTIONS
919 // ===========================================================
920 
924 SHEAF_DLL_SPEC
925 std::ostream & operator << (std::ostream &os, const subposet& s);
926 
931 size_t
932 SHEAF_DLL_SPEC
933 deep_size(const subposet& xsp, bool xinclude_shallow = true);
934 
935 
936 } // namespace sheaf
937 
938 #endif // ifndef SUBPOSET_H
std::string name() const
Definition: subposet.h:796
A client handle for a subposet.
Definition: subposet.h:86
A client handle for a general, abstract partially order set.
A wrapper/adapter for the subposet names record. Intended for transferring subposet name data between...
unsigned int word_t
The type of the private, internal representation used for bits; Unsigned int is the type used in the ...
Definition: zn_to_bool.h:160
Features shared by poset_member and subposet. Subposet and poset_member objects can be attached...
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...
Abstract base class with useful features for all objects.
Definition: any.h:39
A map from Zn (the integers mod n) to bools. A characteristic function used to represent subsets of Z...
Definition: zn_to_bool.h:52
The general depth-first iterator over the intersection of a poset member anchor&#39;s whole with its down...
A client handle for a restrictable member of a poset. A poset_member is a poset_member which can ...
Definition: poset_member.h:59
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
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.
A wrapper/adapter for the id space names record. Intended for transferring id map data between the ke...
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
The schema poset for the primitives.
An array for storing structs which describe the size, alignment, and offset of dofs within a dof tupl...
Iterates over the subset of Zn defined by the characteristic function host().
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.
A handle for a scattered_insertion_index_space_state.
Namespace for the sheaves component of the sheaf system.
An abstract client handle for a member of a poset.
Agent responsible for importing and exporting posets from an external name space which resides on dis...
Definition: storage_agent.h:74