SheafSystem  0.0.0.0
primary_sum_index_space_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 PRIMARY_SUM_INDEX_SPACE_STATE_H
22 #define PRIMARY_SUM_INDEX_SPACE_STATE_H
23 
24 #ifndef SHEAF_DLL_SPEC_H
25 #include "SheafSystem/sheaf_dll_spec.h"
26 #endif
27 
28 #ifndef SUM_INDEX_SPACE_STATE_H
29 #include "SheafSystem/sum_index_space_state.h"
30 #endif
31 
32 #ifndef LIST_POOL_H
33 #include "SheafSystem/list_pool.h"
34 #endif
35 
36 #ifndef INTERVAL_INDEX_SPACE_HANDLE_H
37 #include "SheafSystem/interval_index_space_handle.h"
38 #endif
39 
40 #ifndef INTERVAL_SET_H
41 #include "SheafSystem/interval_set.h"
42 #endif
43 
44 #ifndef RESERVED_PRIMARY_INDEX_SPACE_HANDLE_H
45 #include "SheafSystem/reserved_primary_index_space_handle.h"
46 #endif
47 
48 #ifndef STD_UNORDERED_MAP_H
49 #include "SheafSystem/std_unordered_map.h"
50 #endif
51 
52 #ifndef STD_UNORDERED_SET_H
53 #include "SheafSystem/std_unordered_set.h"
54 #endif
55 
56 namespace sheaf
57 {
58 
59 class interval_index_space_handle;
60 class primary_index_space_handle;
61 class hub_index_space_iterator;
62 
87 {
88 
89  friend class hub_index_space_iterator;
90  friend class namespace_poset;
91  friend SHEAF_DLL_SPEC size_t deep_size(const primary_sum_index_space_state& xn, bool xinclude_shallow);
92 
93  // ===========================================================
95  // ===========================================================
97 
98 public:
99 
105  static hub_index_space_handle new_space(index_space_family& xid_spaces,
106  const std::string& xname);
107 
113  static hub_index_space_handle new_space(index_space_family& xid_spaces,
114  pod_type xid,
115  const std::string& xname);
116 
117 protected:
118 
119 private:
120 
122 
123 
124  // ===========================================================
126  // ===========================================================
128 
129 public:
130 
131 protected:
132 
137 
142 
147 
148 private:
149 
151 
152 
153  // ===========================================================
155  // ===========================================================
157 
158 public:
159 
163  pod_type new_id();
164 
168  pod_type new_id(pod_type xid);
169 
173  void delete_id(pod_type xid);
174 
179  bool is_valid_reserved_id(pod_type xid) const;
180 
184  pod_type next_id() const;
185 
190  pod_type new_primary_term(size_type xct);
191 
196  pod_type new_primary_term(pod_type xid, size_type xct);
197 
201  void remove_term(pod_type xi);
202 
206  void extend_last_term(size_type xct);
207 
211  bool interval_is_full(pod_type xbegin, pod_type xend) const;
212 
216  bool interval_is_empty(pod_type xbegin, pod_type xend) const;
217 
221  bool interval_is_available(pod_type xbegin, pod_type xend) const;
222 
223 protected:
224 
227  static const std::string& term_prefix();
228 
232  std::string next_term_name();
233 
238  pod_type new_reserved_term();
239 
244  pod_type new_reserved_term(pod_type xid);
245 
249  void add_term(pod_type xterm_id, pod_type xbegin, pod_type xend);
250 
254  bool reserved_interval_is_available(pod_type xid) const;
255 
259  void update_extrema();
260 
265 
270 
275 
279  unordered::unordered_set<pod_type> _reserved_term_ids;
280 
281 private:
282 
284 
285 
286  // ===========================================================
288  // ===========================================================
290 
291 public:
292 
297  void glue(pod_type xid, pod_type xrep);
298 
302  void unglue(pod_type xid);
303 
309  void unglue_all(pod_type xrep_id);
310 
314  bool has_gluing() const;
315 
316 protected:
317 
318 private:
319 
321 
322 
323  // ===========================================================
325  // ===========================================================
327 
328 public:
329 
334  const index_space_handle& new_gathered_id_space(bool xexclude_bottom);
335 
339  void update_gathered_id_space();
340 
344  const index_space_handle& gathered_id_space() const;
345 
349  bool has_gathered_id_space() const;
350 
354  bool gathered_id_space_excludes_bottom() const;
355 
359  static const std::string& gathered_hub_id_space_name();
360 
361 protected:
362 
367  void update_gathered_id_space(bool xexclude_bottom);
368 
373 
374 private:
375 
377 
378 
379  // ===========================================================
381  // ===========================================================
383 
384 public:
385 
389  void update_standard_ids();
390 
394  bool has_only_standard_ids() const;
395 
399  void clear_ids();
400 
401 protected:
402 
407 
408 private:
409 
411 
412 
413  // ===========================================================
415  // ===========================================================
417 
418 public:
419 
424  virtual bool contains_rep(pod_type xhub_id) const;
425 
429  virtual pod_type rep(pod_type xhub_id) const;
430 
435  virtual pod_type host_rep(pod_type xhub_id) const;
436 
440  virtual pod_type term_id_begin() const;
441 
445  virtual pod_type term_id_end() const;
446 
450  virtual bool contains_term_id(pod_type xi) const;
451 
455  virtual void clear();
456 
457 protected:
458 
462  typedef unordered::unordered_map<pod_type, pod_type> rem_type;
463 
467  rem_type _rem;
468 
473 
478 
479 private:
480 
482 
483 
484  // ===========================================================
486  // ===========================================================
488 
489 public:
490 
494  virtual bool operator==(const explicit_index_space_state& xother) const;
495 
499  virtual size_type deep_size(bool xinclude_shallow) const;
500 
501 protected:
502 
506  virtual primary_sum_index_space_state& operator=(const explicit_index_space_state& xother);
507 
508 private:
509 
511 
512 
513  // ===========================================================
515  // ===========================================================
517 
518 public:
519 
523  virtual bool contains(pod_type xid) const;
524 
528  virtual bool contains_unglued_hub(pod_type xid) const;
529 
533  virtual bool contains_glued_hub(pod_type xid) const;
534 
538  virtual pod_type pod(pod_type xid) const;
539 
543  virtual pod_type unglued_hub_pod(pod_type xid) const;
544 
548  virtual pod_type glued_hub_pod(pod_type xid) const;
549 
550 protected:
551 
552 private:
553 
555 
556 
557  // ===========================================================
559  // ===========================================================
561 
562 public:
563 
567  static size_type handle_pool_ct();
568 
572  static size_type handle_pool_deep_size();
573 
577  virtual index_space_handle& get_id_space() const;
578 
582  virtual void release_id_space(index_space_handle& xid_space) const;
583 
588  virtual bool allocated_id_space(const index_space_handle& xid_space) const;
589 
590 protected:
591 
592 private:
593 
597  static list_pool<hub_index_space_handle>& handles();
598 
600 
601 
602  // ===========================================================
604  // ===========================================================
606 
607 public:
608 
612  static size_type iterator_pool_ct();
613 
617  static size_type iterator_pool_deep_size();
618 
622  virtual index_space_iterator& get_iterator() const;
623 
627  virtual void release_iterator(index_space_iterator& xitr) const;
628 
633  virtual bool allocated_iterator(const index_space_iterator& xitr) const;
634 
635 protected:
636 
637 private:
638 
642  static list_pool<hub_index_space_iterator>& iterators();
643 
645 
646 
647  // ===========================================================
649  // ===========================================================
651 
652 public:
653 
657  virtual const std::string& class_name() const;
658 
662  virtual primary_sum_index_space_state* clone() const;
663 
664 protected:
665 
666 private:
667 
671  static bool make_prototype();
672 
674 
675 
676  // ===========================================================
678  // ===========================================================
680 
681 public:
682 
686  virtual bool is_ancestor_of(const any *other) const;
687 
691  virtual bool invariant() const;
692 
693 protected:
694 
695 private:
696 
698 
699 };
700 
701 // ===========================================================
702 // NON-MEMBER FUNCTIONS
703 // ===========================================================
704 
708 SHEAF_DLL_SPEC
709 size_t deep_size(const primary_sum_index_space_state& xn, bool xinclude_shallow = true);
710 
711 } // end namespace sheaf
712 
713 #endif // ifndef PRIMARY_SUM_INDEX_SPACE_STATE_H
An implementation of class scattered_insertion_index_space_handle that has a interval id space state...
pod_type _term_id_end
Ending index of the terms in this sum.
Set of integers optimized for when the integers are concentrated in closed intervals.
Definition: interval_set.h:70
An abstract iterator over the ids of an id space.
rem_type _rem
The reflexive reduction of the rem map.
primary_sum_index_space_state(const primary_sum_index_space_state &xother)
Copy constructor; disabled.
pod_type _standard_id_end
The end id of the standard ids.
pod_type _term_id_begin
Beginning index of the terms in this sum.
The default name space; a poset which contains other posets as members.
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_index_space_handle _gathered_id_space
The gathered id space.
Abstract base class with useful features for all objects.
Definition: any.h:39
interval_set _members
Set of members in the domain of this map.
An immutable abstract state for a space of alternate integer identifiers (aliases) for a subset of th...
An abstract id space of alternate integer identifiers which is the sum (disjoint union) of two or mor...
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
reserved_primary_index_space_handle _reserved_term
The current reserved term.
unordered::unordered_map< pod_type, pod_type > rem_type
The type of rem map.
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.
pod_index_type pod_type
The "plain old data" index type for this.
An implementation of class primary_index_space_handle that has a reserved primary id space state...
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.
An iterator over an id space which is the sum of the primary id spaces.
unordered::unordered_set< pod_type > _reserved_term_ids
The set of reserved term ids.
A reallocated pool of objects of type T. Objects in the pool are either allocated or stored in a free...
Definition: list_pool.h:42