SheafSystem  0.0.0.0
poset_crg_state.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 POSET_CRG_STATE_H
22 #define POSET_CRG_STATE_H
23 
24 #ifndef SHEAF_DLL_SPEC_H
25 #include "SheafSystem/sheaf_dll_spec.h"
26 #endif
27 
28 #ifndef ANY_H
29 #include "SheafSystem/any.h"
30 #endif
31 
32 #ifndef INDEX_SPACE_FAMILY_H
33 #include "SheafSystem/index_space_family.h"
34 #endif
35 
36 #ifndef NAME_MULTIMAP_H
37 #include "SheafSystem/name_multimap.h"
38 #endif
39 
40 #ifndef POOL_H
41 #include "SheafSystem/pool.h"
42 #endif
43 
44 #ifndef SCOPED_INDEX_H
45 #include "SheafSystem/scoped_index.h"
46 #endif
47 
48 #ifndef STD_UNORDERED_MAP_H
49 #include "SheafSystem/std_unordered_map.h"
50 #endif
51 
52 #ifndef STD_SET_H
53 #include "SheafSystem/std_set.h"
54 #endif
55 
56 #ifndef STD_STRING_H
57 #include "SheafSystem/std_string.h"
58 #endif
59 
60 #ifndef ZN_TO_BOOL_H
61 #include "SheafSystem/zn_to_bool.h"
62 #endif
63 
64 namespace sheaf
65 {
66 
67 class scattered_insertion_index_space_handle;
68 class index_space_family;
69 class crg_interval;
70 class implicit_crg_interval;
71 class index_space_handle;
72 class poset_crg_state;
73 SHEAF_DLL_SPEC size_t deep_size(const poset_crg_state& xp, bool xinclude_shallow, size_t xresults[2]);
74 
78 class SHEAF_DLL_SPEC poset_crg_state : public any
79 {
80 
81  friend SHEAF_DLL_SPEC size_t deep_size(const poset_crg_state& xp, bool xinclude_shallow, size_t xresults[2]);
82  friend class poset_state_handle;
83  friend class poset_state;
84  friend class crg_interval; // cover_name
85  friend class member_record_set; // explicit_down_set_members
86 
87  // ===========================================================
89  // ===========================================================
91 
92 public:
93 
98 
102  ~poset_crg_state();
103 
104 protected:
105 
106 private:
107 
109 
110 
111  // ===========================================================
113  // ===========================================================
115 
116 public:
117 
121  pod_index_type new_member();
122 
127  void new_member(pod_index_type xid);
128 
135  void new_standard_member_hack(standard_member_index xid);
136 
140  pod_index_type new_member_interval(const std::string& xinterval_type, size_type xsize);
141 
146  void new_member_interval(pod_index_type xid,
147  const std::string& xinterval_type,
148  size_type xsize);
149 
153  void delete_member(pod_index_type xid);
154 
159  void delete_interval(pod_index_type xid);
160 
164  size_type member_ct() const;
165 
170  size_type standard_member_ct();
171 
176  size_type standard_member_ct() const;
177 
182  void put_standard_member_ct(size_type xct);
183 
188  const scoped_index& begin() const;
189 
194  const scoped_index& end() const;
195 
199  bool contains_member(pod_index_type xid) const;
200 
206  bool contains_implicit_member(pod_index_type xid) const;
207 
213  bool contains_explicit_member(pod_index_type xid) const;
214 
218  const crg_interval& interval(pod_index_type xid) const;
219 
223  crg_interval& interval(pod_index_type xid);
224 
231  implicit_crg_interval* implicit_member(pod_index_type xid) const;
232 
233 protected:
234 
243  void initialize_member_covers(pod_index_type xid, bool xstandard_member_hack = false);
244 
245 private:
246 
250  scoped_index _begin;
251 
255  scoped_index _end;
256 
260  size_type _member_ct;
261 
266  size_type _standard_member_ct;
267 
269 
270 
271  // ===========================================================
273  // ===========================================================
275 
276 public:
277 
281  const index_space_family& id_spaces() const;
282 
286  const hub_index_space_handle& hub_id_space() const;
287 
293  const scoped_index& hub_id() const;
294 
298  scoped_index hub_id(pod_index_type xid) const;
299 
304  const index_space_handle& new_gathered_hub_id_space(bool xexclude_bottom);
305 
309  void update_gathered_hub_id_space();
310 
314  const index_space_handle& gathered_hub_id_space() const;
315 
319  bool has_gathered_hub_id_space() const;
320 
324  bool gathered_hub_id_space_excludes_bottom() const;
325 
326 protected:
327 
328 private:
329 
333  index_space_family _id_spaces;
334 
336 
337 
338  // ===========================================================
340  // ===========================================================
342 
343 public:
344 
349 
353  member_name_map_type& member_name_map();
354 
358  const member_name_map_type& member_name_map() const;
359 
360 protected:
361 
362 private:
363 
367  member_name_map_type _member_name_map;
368 
370 
371 
372  // ===========================================================
374  // ===========================================================
376 
377 public:
378 
382  bool jim_edit_mode() const;
383 
387  void request_jim_edit_mode();
388 
392  void release_jim_edit_mode();
393 
397  int jim_edit_depth() const;
398 
399 protected:
400 
401 private:
402 
406  int _jim_edit_depth;
407 
409 
410 
411  // ===========================================================
413  // ===========================================================
415 
416 public:
417 
422  bool cover_is_explicit(bool xlower, pod_index_type xmbr_index) const;
423 
429  bool cover_is_implicit(bool xlower, pod_index_type xmbr_index) const;
430 
435  pod_index_type cover_id_space_id(bool xlower, pod_index_type xmbr_index) const;
436 
441  index_space_handle& get_cover_id_space(bool xlower, pod_index_type xmbr_index) const;
442 
448  template <typename handle_type>
449  handle_type& get_cover_id_space(bool xlower, pod_index_type xmbr_index) const;
450 
455  template<typename handle_type>
456  bool cover_id_space_handle_conforms_to(bool xlower, pod_index_type xmbr_index) const;
457 
461  void release_cover_id_space(index_space_handle& xcover_id_space) const;
462 
468  index_space_iterator& get_cover_id_space_iterator(bool xlower, pod_index_type xmbr_index) const;
469 
473  void release_cover_id_space_iterator(index_space_iterator& xcover_itr) const;
474 
482  bool cover_contains_iterator(bool xlower,
483  pod_index_type xmbr_index,
484  const index_space_iterator& xitr) const;
485 
493  bool cover_is_empty(bool xlower, pod_index_type xmbr_index) const;
494 
502  bool cover_is_singleton(bool xlower, pod_index_type xmbr_index) const;
503 
511  size_type cover_ct(bool xlower, pod_index_type xmbr_index) const;
512 
519  bool cover_contains_member(bool xlower,
520  pod_index_type xmbr_index,
521  pod_index_type xother_mbr_index) const;
522 
532  bool cover_is_equal(bool xlower,
533  pod_index_type xmbr_index,
534  pod_index_type xother_mbr_index) const;
535 
542  pod_index_type first_cover_member(bool xlower, pod_index_type xmbr_index) const;
543 
550  void insert_cover_member(pod_index_type xother_mbr_index,
551  bool xlower,
552  pod_index_type xmbr_index);
553 
562  void insert_cover_member(pod_index_type xother_mbr_index,
563  bool xlower,
564  pod_index_type xmbr_index,
565  index_space_iterator& xitr);
566 
573  void remove_cover_member(pod_index_type xother_mbr_index,
574  bool xlower,
575  pod_index_type xmbr_index);
576 
585  void remove_cover_member(index_space_iterator& xitr,
586  bool xlower,
587  pod_index_type xmbr_index);
588 
596  template <typename filter_type>
597  void remove_cover_members(const filter_type& xfilter,
598  bool xlower,
599  pod_index_type xmbr_index);
600 
607  void replace_cover_member(pod_index_type xold_other_mbr_index,
608  pod_index_type xnew_other_mbr_index,
609  bool xlower,
610  pod_index_type xmbr_index);
611 
618  void clear_cover(bool xlower, pod_index_type xmbr_index);
619 
627  void copy_cover(bool xlower,
628  pod_index_type xmbr_index,
629  pod_index_type xother_mbr_index);
630 
636  void append_upper_cover_of_bottom(pod_index_type xmbr_begin,
637  pod_index_type xmbr_end);
638 
639 protected:
640 
648  pod_index_type force_explicit_cover(bool xlower,
649  pod_index_type xmbr_index,
650  bool xinitialize = true);
651 
652 private:
653 
657  typedef unordered::unordered_map<pod_index_type, pod_index_type> explicit_dof_tuple_map_type;
658 
662  explicit_dof_tuple_map_type _explicit_dof_tuple_map;
663 
667  typedef std::map<pod_index_type, crg_interval*> interval_map_type;
668 
672  interval_map_type _interval_map;
673 
675 
676 
677  // ===========================================================
679  // ===========================================================
681 
682 public:
683 
688  pod_index_type member_dof_tuple_id(pod_index_type xmbr_index) const;
689 
694  void put_member_dof_tuple_id(pod_index_type xmbr_index,
695  pod_index_type xdof_tuple_id);
696 
697 protected:
698 
699 private:
700 
702 
703 
704  // ===========================================================
706  // ===========================================================
708 
709 public:
710 
714  void clean_cover(bool xlower, pod_index_type xmbr_index);
715 
719  void explicit_down_set_members(const implicit_crg_interval& xinterval,
720  std::set<pod_index_type>& result) const;
721 
722 protected:
723 
727  void explicit_down_set_members(pod_index_type xmbr_index,
728  std::set<pod_index_type>& result) const;
729 
730 private:
731 
733 
734 
735  // ===========================================================
737  // ===========================================================
739 
740 public:
741 
745  virtual bool is_ancestor_of(const any* other) const;
746 
750  virtual poset_crg_state* clone() const;
751 
755  virtual bool invariant() const;
756 
757 protected:
758 
759 private:
760 
762 
763 };
764 
765 // ===========================================================
766 // NON-MEMBER FUNCTIONS
767 // ===========================================================
768 
772 SHEAF_DLL_SPEC std::ostream & operator << (std::ostream &os, const poset_crg_state& p);
773 
778 SHEAF_DLL_SPEC size_t deep_size(const sheaf::poset_crg_state& xp, bool xinclude_shallow = true, size_t xresults[2] = 0);
779 
780 } // namespace sheaf
781 
782 
783 
784 #endif // ifndef POSET_CRG_STATE_H
785 
The data structure representing the cover relation graph of a poset.
The private state of a partially ordered set.
Definition: poset_state.h:49
An abstract iterator over the ids of an id space.
standard_member_index
Ids for standard poset members.
A client handle for a general, abstract partially order set.
name_multimap member_name_map_type
The type of the member_name_map.
A partial multi-valued relation with total injective inverse between names and indices of type index_...
Definition: name_multimap.h:63
An abstract handle to a space of alternate integer identifiers (aliases) for a subset of a hub set of...
An implementation of class sum_index_space_handle that has a primary sum id space state...
Abstract implementation of crg_interval for an interval of implicit cover relation graph members...
Abstract base class with useful features for all objects.
Definition: any.h:39
A record_set containing records of type member_record.
Abstract emulator for an interval of cover relation graph members.
Definition: crg_interval.h:70
Struct representing the closed interval [_begin, _end].
Definition: interval_set.h:48
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.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
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.
Factory and container for a family of id spaces.