SheafSystem  0.0.0.0
interval_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 INTERVAL_INDEX_SPACE_STATE_H
22 #define INTERVAL_INDEX_SPACE_STATE_H
23 
24 #ifndef SHEAF_DLL_SPEC_H
25 #include "SheafSystem/sheaf_dll_spec.h"
26 #endif
27 
28 #ifndef AUTO_BLOCK_H
29 #include "SheafSystem/auto_block.h"
30 #endif
31 
32 #ifndef LIST_POOL_H
33 #include "SheafSystem/list_pool.h"
34 #endif
35 
36 #ifndef SCATTERED_INSERTION_INDEX_SPACE_STATE_H
37 #include "SheafSystem/scattered_insertion_index_space_state.h"
38 #endif
39 
40 #ifndef STD_MAP_H
41 #include "SheafSystem/std_map.h"
42 #endif
43 
44 namespace sheaf
45 {
46 
47 class interval_index_space_handle;
48 class interval_index_space_state;
49 class interval_index_space_iterator;
50 
68 {
69 
70  friend class interval_index_space_iterator;
71  friend class namespace_poset;
72  friend SHEAF_DLL_SPEC size_t deep_size(const interval_index_space_state& xn, bool xinclude_shallow);
73 
74  // ===========================================================
76  // ===========================================================
78 
79 public:
80 
87  static interval_index_space_handle new_space(index_space_family& xid_spaces,
88  const std::string& xname,
89  bool xis_persistent,
90  bool xmerge_mode);
91 
98  static interval_index_space_handle new_space(index_space_family& xid_spaces,
99  pod_type xid,
100  const std::string& xname,
101  bool xis_persistent,
102  bool xmerge_mode);
103 
104 protected:
105 
106 private:
107 
109 
110 
111  // ===========================================================
113  // ===========================================================
115 
116 public:
117 
118 protected:
119 
122  // [xrange_begin, xrange_end] in map xmap.
124  static void insert_map_interval(pod_type xdomain_begin,
125  pod_type xdomain_end,
126  pod_type xrange_begin,
127  pod_type xrange_end,
128  std::map<pod_type, pod_type>& xmap,
129  bool xmerge_mode);
130 
134  static pod_type map_value(pod_type xid, const std::map<pod_type, pod_type>& xmap);
135 
140 
145 
149  virtual ~interval_index_space_state();
150 
151 private:
152 
154 
155 
156  // ===========================================================
158  // ===========================================================
160 
161 public:
162 
168  void insert_interval(pod_type xbegin,
169  pod_type xend,
170  const scoped_index& xhub_begin,
171  const scoped_index& xhub_end);
172 
177  void insert_interval(pod_type xbegin,
178  pod_type xend,
179  pod_type xhub_begin,
180  pod_type xhub_end);
181 
187  void push_interval(const scoped_index& xhub_begin,
188  const scoped_index& xhub_end);
189 
193  void push_interval(pod_type xhub_begin, pod_type xhub_end);
194 
201  size_type remove_interval(const scoped_index& xhub_begin,
202  const scoped_index& xhub_end);
203 
209  size_type remove_hub_interval(pod_type xhub_begin, pod_type xhub_end);
210 
216  size_type remove_interval(pod_type xbegin, pod_type xend);
217 
222  pod_type interval_begin(const scoped_index& xid) const;
223 
227  pod_type interval_begin(pod_type xhub_id) const;
228 
233  pod_type interval_end(const scoped_index& xid) const;
234 
238  pod_type interval_end(pod_type xhub_id) const;
239 
243  bool merge_mode() const;
244 
248  void put_merge_mode(bool xvalue);
249 
250 protected:
251 
256  size_type invalid_entry_ct(pod_type xhub_begin, pod_type xhub_end) const;
257 
258 private:
259 
261 
262  // ===========================================================
264  // ===========================================================
266 
267 public:
268 
269 protected:
270 
271 private:
272 
274 
275  // ===========================================================
277  // ===========================================================
279 
280 public:
281 
283 
287  virtual void update_extrema();
288 
292  virtual void reserve(size_type xcapacity);
293 
297  virtual size_type capacity() const;
298 
299 protected:
300 
301 private:
302 
304 
305 
306  // ===========================================================
308  // ===========================================================
310 
311 public:
312 
316  void print_map_rep(std::ostream& xos) const;
317 
318 protected:
319 
324  void map_rep_insert_interval(pod_type xdomain_begin,
325  pod_type xdomain_end,
326  pod_type xrange_begin,
327  pod_type xrange_end);
328 
334  size_type map_rep_remove_interval(pod_type xbegin,
335  pod_type xend,
336  bool xis_range_id);
337 
341  virtual void map_rep_insert_entry(pod_type xdomain_id, pod_type xrange_id);
342 
346  virtual void map_rep_push_back(pod_type xrange_id);
347 
353  virtual void map_rep_push(index_space_iterator& xitr, pod_type xrange_id);
354 
360  virtual size_type map_rep_remove_entry(pod_type xid, bool xis_range_id);
361 
366  virtual void map_rep_remove_entry(index_space_iterator& xitr);
367 
371  virtual void map_rep_clear();
372 
376  virtual void map_rep_gather();
377 
381  typedef std::map<pod_type, pod_type> map_type;
382 
386  typedef map_type to_domain_type;
387 
391  to_domain_type _to_domain;
392 
396  typedef map_type to_range_type;
397 
401  to_range_type _to_range;
402 
407 
412 
413 private:
414 
416 
417 
418  // ===========================================================
420  // ===========================================================
422 
423 public:
424 
428  virtual bool operator==(const explicit_index_space_state& xother) const;
429 
433  virtual size_type deep_size(bool xinclude_shallow) const;
434 
435 protected:
436 
440  virtual interval_index_space_state& operator=(const explicit_index_space_state& xother);
441 
442 private:
443 
445 
446 
447  // ===========================================================
449  // ===========================================================
451 
452 public:
453 
455 
459  virtual bool contains(pod_type xid) const;
460 
464  virtual bool contains_unglued_hub(pod_type xid) const;
465 
469  virtual pod_type pod(pod_type xid) const;
470 
474  virtual pod_type unglued_hub_pod(pod_type xid) const;
475 
476 protected:
477 
478 private:
479 
481 
482 
483  // ===========================================================
485  // ===========================================================
487 
488 public:
489 
493  static size_type handle_pool_ct();
494 
498  static size_type handle_pool_deep_size();
499 
503  virtual index_space_handle& get_id_space() const;
504 
508  virtual void release_id_space(index_space_handle& xid_space) const;
509 
514  virtual bool allocated_id_space(const index_space_handle& xid_space) const;
515 
516 protected:
517 
518 private:
519 
523  static list_pool<interval_index_space_handle>& handles();
524 
526 
527 
528  // ===========================================================
530  // ===========================================================
532 
533 public:
534 
538  static size_type iterator_pool_ct();
539 
543  static size_type iterator_pool_deep_size();
544 
548  virtual index_space_iterator& get_iterator() const;
549 
553  virtual void release_iterator(index_space_iterator& xitr) const;
554 
559  virtual bool allocated_iterator(const index_space_iterator& xitr) const;
560 
561 protected:
562 
563 private:
564 
568  static list_pool<interval_index_space_iterator>& iterators();
569 
571 
572 
573  // ===========================================================
575  // ===========================================================
577 
578 public:
579 
583  virtual const std::string& class_name() const;
584 
588  virtual interval_index_space_state* clone() const;
589 
590 protected:
591 
592 private:
593 
597  static bool make_prototype();
598 
600 
601 
602  // ===========================================================
604  // ===========================================================
606 
607 public:
608 
612  virtual bool is_ancestor_of(const any *other) const;
613 
617  virtual bool invariant() const;
618 
619 protected:
620 
621 private:
622 
624 
625 };
626 
627 // ===========================================================
628 // NON-MEMBER FUNCTIONS
629 // ===========================================================
630 
634 SHEAF_DLL_SPEC
635 size_t deep_size(const interval_index_space_state& xn, bool xinclude_shallow = true);
636 
637 } // end namespace sheaf
638 
639 #endif // ifndef INTERVAL_INDEX_SPACE_STATE_H
An implementation of class scattered_insertion_index_space_handle that has a interval id space state...
An STL map implementation of class scattered_insertion_index_space_state optimized to efficiently rep...
An abstract iterator over the ids of an id space.
to_range_type _to_range
The representation of the domain id to range id map.
The default name space; a poset which contains other posets as members.
to_domain_type _to_domain
The representation of the range id to domain id map.
An implementation of class explicit_index_space_state that supports either gathered or scattered inse...
interval_index_space_state(const interval_index_space_state &xother)
Copy constructor; disabled.
An abstract handle to a space of alternate integer identifiers (aliases) for a subset of a hub set of...
std::map< pod_type, pod_type > map_type
The type of the id maps.
Abstract base class with useful features for all objects.
Definition: any.h:39
An immutable abstract state for a space of alternate integer identifiers (aliases) for a subset of th...
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
An iterator over an id space in which the equivalence between the ids in the space and the hub id spa...
pod_type _capacity
The capacity of this 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.
virtual bool contains(pod_type xid) const =0
True if this space contains id xid.
pod_index_type pod_type
The "plain old data" index type for this.
map_type to_range_type
The type of the domain id to range id map.
bool _merge_mode
True if and only if compatible intervals should be merged.
Namespace for the sheaves component of the sheaf system.
Factory and container for a family of id spaces.
map_type to_domain_type
The type of the range id to domain id map.
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