SheafSystem  0.0.0.0
index_space_family.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 INDEX_SPACE_FAMILY_H
22 #define INDEX_SPACE_FAMILY_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 EXPLICIT_INDEX_SPACE_COLLECTION_H
33 #include "SheafSystem/explicit_index_space_collection.h"
34 #endif
35 
36 #ifndef HUB_INDEX_SPACE_HANDLE_H
37 #include "SheafSystem/hub_index_space_handle.h"
38 #endif
39 
40 #ifndef INTERVAL_INDEX_SPACE_HANDLE_H
41 #include "SheafSystem/interval_index_space_handle.h"
42 #endif
43 
44 #ifndef NAME_MULTIMAP_H
45 #include "SheafSystem/name_multimap.h"
46 #endif
47 
48 #ifndef POD_TYPES_H
49 #include "SheafSystem/pod_types.h"
50 #endif
51 
52 #ifndef STD_UNORDERED_SET_H
53 #include "SheafSystem/std_unordered_set.h"
54 #endif
55 
56 #ifndef STD_MAP_H
57 #include "SheafSystem/std_map.h"
58 #endif
59 
60 namespace sheaf
61 {
62 
63 class arg_list;
64 class explicit_index_space_interval;
65 class index_space_family;
66 class index_space_family_iterator;
67 class index_space_interval;
68 class index_space_iterator;
69 class index_space_state;
70 class scattered_insertion_index_space_handle;
71 class primary_sum_index_space_state;
72 class scoped_index;
73 
77 class SHEAF_DLL_SPEC index_space_family : public any
78 {
79  friend class explicit_index_space_handle;
80  friend class explicit_index_space_iterator;
81  friend class explicit_index_space_state;
82  friend class forwarding_index_space_handle;
83  friend class id_space_names_record;
84  friend class implicit_index_space_iterator;
85  friend class index_space_family_iterator;
86  friend class index_space_handle;
87  friend class index_space_interval;
88  friend class index_space_iterator;
89  friend class poset_state_handle; // Uses new_primary_state
90  friend class poset_crg_state; // Uses new_primary_state
91  friend class primary_sum_index_space_state;
92  friend SHEAF_DLL_SPEC size_t deep_size(const index_space_family& xfamily, bool xinclude_shallow);
93 
94  // ===========================================================
96  // ===========================================================
98 
99 public:
100 
105 
110 
114  virtual ~index_space_family();
115 
119  std::string name(pod_type xid) const;
120 
122 
126  pod_type index(const std::string& xname) const;
127 
131  void put_name(pod_type xid, const std::string& xname);
132 
136  bool contains(pod_type xid) const;
137 
141  bool contains(const std::string& xname) const;
142 
146  pod_type begin() const;
147 
151  pod_type end() const;
152 
156  bool has_only_standard_id_spaces() const;
157 
161  void update_standard_id_spaces();
162 
166  void clear_id_spaces();
167 
172  static size_type& max_rep_ids();
173 
174 protected:
175 
180 
184  name_multimap _name_to_index;
185 
189  pod_type _end;
190 
194  pod_type _standard_end;
195 
196 private:
197 
199 
200 
201  // ===========================================================
203  // ===========================================================
205 
206 public:
207 
211  void delete_space(pod_type xid);
212 
216  void delete_space(const std::string& xname);
217 
222  bool is_explicit_interval(pod_type xid);
223 
224 protected:
225 
230  pod_type new_primary_state(size_type xct);
231 
236  pod_type new_primary_state(pod_type xid, size_type xct);
237 
241  void delete_primary_state(pod_type xid);
242 
247  void new_state(const std::string& xname, const std::string& xstate_class_name);
248 
252  void delete_state(pod_type xid);
253 
257  void insert_interval(index_space_interval& xinterval);
258 
262  void delete_interval(pod_type xid);
263 
267  const index_space_collection* collection(pod_type xid) const;
268 
272  index_space_collection* collection(pod_type xid);
273 
277  pod_type reserve_next_explicit_id();
278 
282  static size_type explicit_interval_size();
283 
287  typedef std::map<pod_type, index_space_interval*> interval_map_type;
288 
292  typedef interval_map_type::iterator interval_iterator_type;
293 
297  typedef interval_map_type::const_iterator const_interval_iterator_type;
298 
302  interval_map_type _intervals;
303 
308 
313 
314 private:
315 
317 
318 
319  // ===========================================================
321  // ===========================================================
323 
324 public:
325 
329  pod_type new_id();
330 
334  pod_type new_id(pod_type xid);
335 
339  void delete_id(pod_type xid);
340 
344  const hub_index_space_handle& hub_id_space() const;
345 
350  const index_space_handle& new_gathered_hub_id_space(bool xexclude_bottom);
351 
355  void update_gathered_hub_id_space();
356 
360  const index_space_handle& gathered_hub_id_space() const;
361 
365  bool has_gathered_hub_id_space() const;
366 
370  bool gathered_hub_id_space_excludes_bottom() const;
371 
375  static const std::string& hub_id_space_name();
376 
381  bool is_valid_reserved_id(pod_type xid) const;
382 
386  const index_space_handle& term_of(pod_type xid) const;
387 
391  const index_space_handle& term_of(const scoped_index& xid) const;
392 
396  const index_space_handle& last_term() const;
397 
404  void extend_last_term(size_type xct);
405 
406 protected:
407 
412 
417 
418 private:
419 
421 
422 
423  // ===========================================================
425  // ===========================================================
427 
428 public:
429 
433  size_type ct(const std::string& xname) const;
434 
438  size_type ct(pod_type xspace_id) const;
439 
443  bool is_empty(const std::string& xname) const;
444 
448  bool is_empty(pod_type xspace_id) const;
449 
453  pod_type begin(const std::string& xname) const;
454 
458  pod_type begin(pod_type xspace_id) const;
459 
463  pod_type end(const std::string& xname) const;
464 
468  pod_type end(pod_type xspace_id) const;
469 
473  pod_type hub_begin(const std::string& xname) const;
474 
478  pod_type hub_begin(pod_type xspace_id) const;
479 
483  bool is_gathered(const std::string& xname) const;
484 
488  bool is_gathered(pod_type xspace_id) const;
489 
493  bool contains(const std::string& xname, pod_type xid) const;
494 
498  bool contains(pod_type xspace_id, pod_type xid) const;
499 
504  bool contains(const std::string& xname, const scoped_index& xid) const;
505 
510  bool contains(pod_type xspace_id, const scoped_index& xid) const;
511 
517  bool contains_hub(const std::string& xname, pod_type xid) const;
518 
524  bool contains_hub(pod_type xspace_id, pod_type xid) const;
525 
530  bool contains_unglued_hub(const std::string& xname, pod_type xid) const;
531 
536  bool contains_unglued_hub(pod_type xspace_id, pod_type xid) const;
537 
542  bool contains_glued_hub(const std::string& xname, pod_type xid) const;
543 
548  bool contains_glued_hub(pod_type xspace_id, pod_type xid) const;
549 
555  bool contains(const std::string& xname, pod_type xid, const scoped_index& xhub_id) const;
556 
562  bool contains(pod_type xspace_id, pod_type xid, const scoped_index& xhub_id) const;
563 
568  bool contains(const std::string& xname, pod_type xid, pod_type xhub_id) const;
569 
574  bool contains(pod_type xspace_id, pod_type xid, pod_type xhub_id) const;
575 
580  pod_type pod(const std::string& xname, pod_type xid) const;
581 
586  pod_type pod(pod_type xspace_id, pod_type xid) const;
587 
592  pod_type pod(const std::string& xname, const scoped_index& xid) const;
593 
598  pod_type pod(pod_type xspace_id, const scoped_index& xid) const;
599 
605  pod_type hub_pod(const std::string& xname, pod_type xid) const;
606 
612  pod_type hub_pod(pod_type xspace_id, pod_type xid) const;
613 
618  pod_type unglued_hub_pod(const std::string& xname, pod_type xid) const;
619 
624  pod_type unglued_hub_pod(pod_type xspace_id, pod_type xid) const;
625 
630  pod_type glued_hub_pod(const std::string& xname, pod_type xid) const;
631 
636  pod_type glued_hub_pod(pod_type xspace_id, pod_type xid) const;
637 
641  bool is_persistent(const std::string& xname) const;
642 
646  bool is_persistent(pod_type xspace_id) const;
647 
648 protected:
649 
650 private:
651 
653 
654 
655  // ===========================================================
657  // ===========================================================
659 
660 public:
661 
666  void glue(pod_type xid, pod_type xrep);
667 
671  void unglue(pod_type xid);
672 
678  void unglue_all(pod_type xrep_id);
679 
683  bool has_gluing() const;
684 
685 protected:
686 
687 private:
688 
690 
691 
692  // ===========================================================
694  // ===========================================================
696 
697 public:
698 
703  void new_product_structure(const std::string& xname,
704  const abstract_product_structure& xproduct);
705 
710  void new_product_structure(pod_type xspace_id,
711  const abstract_product_structure& xproduct);
712 
716  void delete_product_structure(const std::string& xname);
717 
721  void delete_product_structure(pod_type xspace_id);
722 
726  const abstract_product_structure& product_structure(const std::string& xname) const;
727 
731  const abstract_product_structure& product_structure(pod_type xspace_id) const;
732 
736  abstract_product_structure& product_structure(const std::string& xname);
737 
741  abstract_product_structure& product_structure(pod_type xspace_id);
742 
746  template<typename T>
747  const T& product_structure(const std::string& xname) const;
748 
752  template<typename T>
753  const T& product_structure(pod_type xspace_id) const;
754 
758  template<typename T>
759  T& product_structure(const std::string& xname);
760 
764  template<typename T>
765  T& product_structure(pod_type xspace_id);
766 
770  bool has_product_structure(const std::string& xname) const;
771 
775  bool has_product_structure(pod_type xspace_id) const;
776 
781  template<typename T>
782  bool product_structure_conforms_to(const std::string& xname) const;
783 
788  template<typename T>
789  bool product_structure_conforms_to(pod_type xspace_id) const;
790 
791 protected:
792 
793 private:
794 
796 
797 
798  // ===========================================================
800  // ===========================================================
802 
803 public:
804 
809  index_space_handle& get_id_space(const std::string& xname) const;
810 
815  index_space_handle& get_id_space(pod_type xspace_id) const;
816 
821  template<typename T>
822  T& get_id_space(const std::string& xname) const;
823 
828  template<typename T>
829  T& get_id_space(pod_type xspace_id) const;
830 
834  template<typename T>
835  bool handle_conforms_to_state(const std::string& xname) const;
836 
840  template<typename T>
841  bool handle_conforms_to_state(pod_type xspace_id) const;
842 
846  void release_id_space(index_space_handle& xid_space) const;
847 
852  bool allocated_id_space(const index_space_handle& xid_space) const;
853 
854 protected:
855 
856 private:
857 
859 
860 
861  // ===========================================================
863  // ===========================================================
865 
866 public:
867 
872  index_space_iterator& get_id_space_iterator(const std::string& xname) const;
873 
878  index_space_iterator& get_id_space_iterator(pod_type xspace_id) const;
879 
883  void release_id_space_iterator(index_space_iterator& xitr) const;
884 
889  bool allocated_id_space_iterator(const index_space_iterator& xitr) const;
890 
891 protected:
892 
893 private:
894 
896 
897 
898  // ===========================================================
900  // ===========================================================
902 
903 public:
904 
908  virtual bool is_ancestor_of(const any *other) const;
909 
913  virtual bool invariant() const;
914 
915 protected:
916 
917 private:
918 
920 
921 };
922 
923 // ===========================================================
924 // NON-MEMBER FUNCTIONS
925 // ===========================================================
926 
930 SHEAF_DLL_SPEC
931 std::ostream&
932 operator << (std::ostream &xos, const index_space_family& xfamily);
933 
937 SHEAF_DLL_SPEC
938 size_t deep_size(const index_space_family& xfamily, bool xinclude_shallow = true);
939 
940 } // end namespace sheaf
941 
942 #endif // ifndef INDEX_SPACE_FAMILY_H
An implementation of class scattered_insertion_index_space_handle that has a interval id space state...
The data structure representing the cover relation graph of a poset.
An abstract class that defines the product structure for an id space.
An abstract iterator over the ids of an id space.
hub_index_space_handle _hub_id_space
The hub id space.
A client handle for a general, abstract partially order set.
interval_map_type::const_iterator const_interval_iterator_type
Type of interval map iterator.
A partial multi-valued relation with total injective inverse between names and indices of type index_...
Definition: name_multimap.h:63
pod_type _standard_end
Ending index of the standard id spaces.
pod_type _end
Ending index of the id spaces.
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...
interval_map_type::iterator interval_iterator_type
Type of interval map iterator.
An abstract iterator over the id spaces of a interval.
Abstract base class with useful features for all objects.
Definition: any.h:39
An implemenation of index_space_collection that adds an interface for the interval [begin()...
An immutable abstract state for a space of alternate integer identifiers (aliases) for a subset of th...
An implementation of class index_space_handle for an explicit_index_space_state.
An implementation of class index_space_handle for an forwarding_index_space_state.
std::map< pod_type, index_space_interval * > interval_map_type
Type of interval map.
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
pod_index_type pod_type
The "plain old data" index type for this.
An implementation of class index_space_iterator for id spaces that are implicitly represtented...
interval_map_type _intervals
Map from id to id space interval.
index_space_family(const index_space_family &xother)
Copy constructor; disabled.
A collection of id space states. This is a virtual class with provides an interface for accessing the...
An implementation of index_space_interval for an interval of explicit id spaces.
pod_type _next_explicit_id
The next available id for an explicit index space.
explicit_index_space_interval * _explicit_interval
The current explicit id space interval.
An implementation of class index_space_iterator for an explicit_index_space_state.
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.
An implementation of class sum_index_space_state intended for use as the sum of the primary id spaces...
Factory and container for a family of id spaces.
interval_index_space_handle _gathered_hub_id_space
The gathered hub id space.