21 #include "SheafSystem/primary_sum_index_space_state.h" 22 #include "SheafSystem/assert_contract.h" 23 #include "SheafSystem/deep_size.h" 24 #include "SheafSystem/index_space_family.h" 25 #include "SheafSystem/interval_index_space_state.h" 26 #include "SheafSystem/poset_path.h" 27 #include "SheafSystem/primary_index_space_handle.h" 28 #include "SheafSystem/primitive_value.h" 29 #include "SheafSystem/hub_index_space_iterator.h" 30 #include "SheafSystem/reserved_primary_index_space_state.h" 31 #include "SheafSystem/std_sstream.h" 44 const std::string& xname)
48 require(!xname.empty());
49 require(!xid_spaces.
contains(xname));
54 lstate->new_state(xid_spaces, xname,
false);
60 ensure(&result.
id_spaces() == &xid_spaces);
64 ensure(result.
name() == xname);
76 const std::string& xname)
82 require(!xname.empty());
83 require(!xid_spaces.
contains(xname));
88 lstate->new_state(xid_spaces, xid, xname,
false);
94 ensure(&result.
id_spaces() == &xid_spaces);
98 ensure(result.
index() == xid);
99 ensure(result.
name() == xname);
294 if(dynamic_cast<reserved_primary_index_space_handle*>(lterm) != 0)
316 ensure(is_basic_query);
335 ensure(is_basic_query);
364 ensure(
ct() == old_ct + xct);
365 ensure(
next_id() == old_next_id + xct);
414 ensure(
ct() == old_ct + xct);
505 ensure(
ct() <= old_ct);
535 pod_type new_last_term_end = old_last_term_begin + xct;
543 _term_end[last_term_id] = new_last_term_end;
547 _ct += (xct - old_last_term_ct);
560 ensure(
ct() == (old_ct - old_last_term_ct + xct));
575 require(xbegin < xend);
583 ensure(is_basic_query);
596 require(xbegin < xend);
604 ensure(is_basic_query);
617 require(xbegin < xend);
632 ensure(is_basic_query);
649 static const std::string result(
"__hub_term_");
653 ensure(!result.empty());
670 std::stringstream lstr;
676 ensure(!result.empty());
817 pod_type lbegin = (xid/lsize)*lsize;
880 _rem_inv.insert(rem_inv_type::value_type(xrep, xid));
916 typedef rem_inv_type::iterator itr_type;
917 pair<itr_type, itr_type> lrange =
_rem_inv.equal_range(lrep_id);
919 for(itr_type litr = lrange.first; litr != lrange.second; ++litr)
921 if(litr->second == xid)
953 typedef rem_inv_type::iterator itr_type;
954 pair<itr_type, itr_type> lrange =
_rem_inv.equal_range(xrep_id);
956 for(itr_type litr = lrange.first; litr != lrange.second; ++litr)
958 _rem.erase(litr->second);
985 bool result = !
_rem.empty();
989 ensure(is_basic_query);
1068 ensure(is_basic_query);
1087 ensure(is_basic_query);
1106 ensure(is_basic_query);
1125 ensure(is_basic_query);
1166 lhub_end = litr->first;
1168 if(!xexclude_bottom || lhub_begin > BOTTOM_INDEX || lhub_end < BOTTOM_INDEX)
1172 else if(lhub_begin == BOTTOM_INDEX)
1176 else if(lhub_end == BOTTOM_INDEX)
1189 lhub_begin = litr->first + 1;
1246 ensure(is_basic_query);
1319 (
_rem.find(xhub_id) ==
_rem.end());
1342 rem_type::const_iterator litr =
_rem.find(xhub_id);
1343 if(litr !=
_rem.end())
1347 result = litr->second;
1358 ensure(is_basic_query);
1400 ensure(is_basic_query);
1419 ensure(is_basic_query);
1440 ensure(is_basic_query);
1526 ensure(result >= 0);
1556 (void) sum_index_space_state::operator=(xother);
1561 ensure((*
this) == xother);
1589 ensure(is_basic_query);
1608 ensure(is_basic_query);
1631 (
_rem.find(xhub_id) ==
_rem.end());
1635 ensure(is_basic_query);
1704 rem_type::const_iterator litr =
_rem.find(xid);
1705 if(litr !=
_rem.end())
1709 result = litr->second;
1758 ensure(result >= 0);
1777 ensure(result >= 0);
1820 handles().release(reinterpret_cast<hub_index_space_handle&>(xid_space));
1824 ensure(is_basic_query);
1842 bool result = (lid_space != 0) && handles().allocated(*lid_space);
1846 ensure(is_basic_query);
1858 sheaf::primary_sum_index_space_state::
1869 ensure(is_basic_query);
1895 ensure(result >= 0);
1914 ensure(result >= 0);
1957 iterators().release(reinterpret_cast<hub_index_space_iterator&>(xitr));
1961 ensure(is_basic_query);
1979 bool result = (litr != 0) && iterators().allocated(*litr);
1983 ensure(is_basic_query);
1995 sheaf::primary_sum_index_space_state::
2006 ensure(is_basic_query);
2024 static const std::string result(
"primary_sum_index_space_state");
2041 ensure(result != 0);
2054 sheaf::primary_sum_index_space_state::
2086 require(other != 0);
2146 size_t result = xinclude_shallow ?
sizeof(xn) : 0;
2156 result += deep_size<pod_index_type, pod_index_type, rem_policy_type>(xn.
_rem,
false);
2164 ensure(result >= 0);
pod_type _term_id_end
Ending index of the terms in this sum.
std::string next_term_name()
Name of the next term id space.
const size_type RESERVED_TERM_SIZE
Size of reserved term in top id space.
bool contains_hub(pod_type xid) const
True if this space contains an id equivalent to xid in the unglued hub id space. synonym for contains...
bool contains_member(pod_type xmbr) const
True, if the integer xmbr is in this set.
virtual pod_type unglued_hub_pod(pod_type xid) const
The pod index in the unglued hub id space equivalent to xid in this id space.
virtual pod_type pod(pod_type xid) const
The pod index in this space equivalent to xid in the hub id space.
size_type ct() const
The number of members.
virtual index_space_handle & get_id_space() const
The id space handle with this state.
virtual void attach_to(pod_type xindex)
Attach to the state with index xindex in the id space family id_spaces().
virtual pod_type index() const
Index of this space.
void clear_ids()
Deallocate all non-standard ids.
void unglue_all(pod_type xrep_id)
Unglue all ids glued to representative xrep_id; makes each id in the equivalence class of xrep_id its...
static const std::string & term_prefix()
Prefix of the term id spaces.
const map_type & interval_map() const
Map that defines the intervals of this set.
bool is_empty() const
True if there are no ids in the space.
pod_type term_id(pod_type xid) const
The id of the term containing id xid.
void put_hub_term_id(pod_type xhub_term_id)
Sets hub_term_id() to xhub_term_id.
An abstract iterator over the ids of an id space.
rem_type _rem
The reflexive reduction of the rem map.
void release_id_space(index_space_handle &xid_space) const
Returns the id space handle xid_space to the handle pool.
static size_type iterator_pool_deep_size()
The deep size of the iterator pool.
pod_type _standard_id_end
The end id of the standard ids.
pod_type end() const
Ending id of this space.
pod_type next_id() const
The next available id.
virtual bool contains_glued_hub(pod_type xid) const
True if this space contains an id equivalent to xid in the glued hub id space.
pod_type new_id()
Allocate the next available id in this space. Returns the allocated id in the hub id space...
pod_type _term_id_begin
Beginning index of the terms in this sum.
void add_term(pod_type xterm_id, pod_type xbegin, pod_type xend)
Insert term with id xterm_id into the interval .
static hub_index_space_handle new_space(index_space_family &xid_spaces, const std::string &xname)
Create a new primary sum id space in the id space family xid_space at the next available id space ind...
bool reserved_interval_is_available(pod_type xid) const
True if the reserved interval for id xid is available for allocation.
bool is_valid_reserved_id(pod_type xid) const
True if and only if the reserved term containing xid is already a reserved term or is available for a...
virtual pod_type term_id_end() const
Ending index of the terms in this sum.
virtual bool is_persistent() const
True if this id space should be written to disk.
bool interval_is_empty(pod_type xbegin, pod_type xend) const
True if all ids in the interval [xbegin, xend) are not in this space.
index_space_handle & get_id_space(const std::string &xname) const
Allocates an id space handle from the handle pool attached to state with name xname.
virtual bool invariant() const
Class invariant.
static interval_index_space_handle new_space(index_space_family &xid_spaces, const std::string &xname, bool xis_persistent, bool xmerge_mode)
Create a new interval id space in the id space family xid_space at the next available id space index ...
bool contains_hub(pod_type xid) const
True if this space contains an id equivalent to xid in the unglued hub id space. synonym for contains...
virtual bool contains_rep(pod_type xhub_id) const
True if and only if hub id xhub_id is the representative member of its equivalence class...
virtual void release_iterator(index_space_iterator &xitr) const
Returns the id space iterator xitr to the iterator pool.
void force_item(index_type xindex, const_reference_type xitem)
Puts the item xitem at index xindex, resizing if necessary; any other new storage allocated is uninit...
void clear()
Delete all ids.
virtual void detach()=0
Detach this handle form its state, if any.
virtual bool operator==(const explicit_index_space_state &xother) const
True if this is equivalent to xother.
bool is_gathered() const
True if begin() == 0 and end() == ct().
void update_gathered_id_space()
Update the gathered id space.
An abstract handle to a space of alternate integer identifiers (aliases) for a subset of a hub set of...
virtual const index_space_family & id_spaces() const
The id space family for this (const version).
virtual pod_type term_id_begin() const
Beginning index of the terms in this sum.
bool interval_is_full(pod_type xbegin, pod_type xend) const
True if all ids in the interval [xbegin, xend) are in this space.
const index_space_family & id_spaces() const
The id space family for this (const version).
bool interval_is_empty(pod_type xbegin, pod_type xend) const
True, if there are no members in this set for the interval [xbegin, xend].
block< pod_type > _term_end
The end of the interval in the sum id space for each term.
virtual bool operator==(const explicit_index_space_state &xother) const
True if this is equivalent to xother.
virtual void detach()=0
Detach this handle form its state, if any.
An implementation of class sum_index_space_handle that has a primary sum id space state...
const index_space_handle & term(pod_type xi) const
The xi-th term.
void attach(explicit_index_space_handle &xid_space) const
Attach the id space handle xid_space to this state.
pod_type _end
Ending id of this space.
An implementation of class explicit_index_space_handle that has a primary id space state...
interval_index_space_handle _gathered_id_space
The gathered id space.
virtual bool allocated_id_space(const index_space_handle &xid_space) const
True if and only if id space handle xid_space was allocated by the handle pool.
Abstract base class with useful features for all objects.
bool is_next_id_available() const
True if and only if the next id is available for allocation.
static size_type iterator_pool_ct()
The number of iterators in the pool.
bool interval_is_available(pod_type xbegin, pod_type xend) const
True if the ids in the interval [xbegin, xend) are available in this space.
pod_type new_primary_term(size_type xct)
Create a new primary term [next_id(), next_id()+xct). Returns the index of the term created...
primary_sum_index_space_state()
Default constructor.
const index_space_handle & new_gathered_id_space(bool xexclude_bottom)
Construct a gathered id space from this id space. If xexclude_bottom, construct the id space without ...
interval_set _members
Set of members in the domain of this map.
virtual const std::string & class_name() const
The name of this class.
pod_type _next_id
The next available id.
An immutable abstract state for a space of alternate integer identifiers (aliases) for a subset of th...
void glue(pod_type xid, pod_type xrep)
Glues xid to xrep; adds xid to the equivalence class with representative member xrep.
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
void extend_last_term(size_type xct)
Extends the last term to ct() == xct.
void delete_id(pod_type xid)
Deallocate the id xid in this space.
void unglue(pod_type xid)
Unglues xid; makes xid its own representative.
std::string name() const
Name of this space.
Do not call deep_size on either the key or value.
static primary_index_space_handle new_space(index_space_family &xid_spaces, const std::string &xname, pod_type xoffset, size_type xct)
Create a new primary id space in the id space family xid_space at the next available id space index w...
bool gathered_id_space_excludes_bottom() const
True, if the gathered id space excludes BOTTOM_INDEX.
virtual bool is_attached() const
True if this handle is attached to a state.
An abstract id space of alternate integer identifiers which is the sum (disjoint union) of two or mor...
const index_space_handle & term_of(pod_type xid) const
The term containing id xid.
void invalidate_extrema()
Invalidate the extrema.
pod_type begin() const
The first member in this set.
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.
terms_type _terms
The terms of this sum.
static reserved_primary_index_space_handle new_space(index_space_family &xid_spaces, const std::string &xname, pod_type xoffset, size_type xct)
Create a new reserved primary id space in the id space family xid_space at the next available id spac...
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
bool interval_is_full(pod_type xbegin, pod_type xend) const
True, if there is a continuous interval of members [xbegin, xend] in this set.
virtual pod_type host_rep(pod_type xhub_id) const
The host id associated with the representative member of the equivalence class of hub id xhub_id...
static std::string reserved_prefix()
Prefix for identifying member names reserved by the sheaf system.
const index_space_handle & last_term() const
The last term.
bool is_explicit_interval(pod_type xid)
True, if and only if the id space interval that contains index xid is an explicit interval...
virtual primary_sum_index_space_state & operator=(const explicit_index_space_state &xother)
Assignment operator.
virtual pod_type rep(pod_type xhub_id) const
The representative member of the equivalence class of hub id xhub_id.
bool has_only_standard_ids() const
True if and only if there are only standard ids.
void push_interval(const scoped_index &xhub_begin, const scoped_index &xhub_end)
Push the closed interval [xhub_begin.hub_pod(), xhub_end.hub_pod()] to the end of this space...
pod_type term_end(pod_type xi) const
Ending id of the xi-th term.
reserved_primary_index_space_handle _reserved_term
The current reserved term.
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
virtual pod_type glued_hub_pod(pod_type xid) const
The pod index in the glued primary sum id space equivalent to xid in this id space.
size_type member_ct(pod_type xbegin, pod_type xend) const
The number of members in the interval [xbegin, xend].
pod_type new_id()
Allocate the next available id in this space.
pod_type end() const
The last member in this set.
static size_type handle_pool_deep_size()
The deep size of the handle pool.
size_type _ct
The number of members.
bool contains_unique_rep(pod_type xhub_id) const
True if and only if hub id xhub_id is the only member of its equivalence class.
void insert_interval(pod_type xbegin, pod_type xend)
Insert an interval of members [xbegin, xend] into this set.
bool invariant_check() const
True if invariant checking is enabled.
pod_index_type pod_type
The "plain old data" index type for this.
static const std::string & gathered_hub_id_space_name()
Name of the gathered id space.
bool has_gathered_id_space() const
True, if the gathered id space exists.
An implementation of class primary_index_space_handle that has a reserved primary id space state...
block< pod_type > _term_begin
The beginning of the interval in the sum id space for each term.
int_type pod_index_type
The plain old data index type.
void remove_term(pod_type xi)
Remove xi-th term of this sum.
virtual void clear()
Deletes all entries.
sum_to_term_type _sum_to_term_map
The term id corresponding to each sum id.
bool contains(pod_type xid) const
True, if this contains an id space with id xid.
pod_type new_reserved_term()
Creates a new reserved term starting above next_hub_id(). Returns the index of the term created...
virtual bool conforms_to_state(const index_space_collection &xhost, pod_type xlocal_id) const
True if this conforms to the handle type required by the state with local scope id xlocal_id in the h...
void update_standard_ids()
Make end() the standard id end.
virtual bool contains_unglued_hub(pod_type xid) const
True if this space contains an id equivalent to xid in the unglued hub id space.
void clear()
Clear this set.
virtual void clear()
Deletes all entries.
virtual size_type ct() const
The number of members.
virtual void release_id_space(index_space_handle &xid_space) const
Release the id space handle xid_space.
virtual bool invariant() const
Class invariant.
An implementation of class sum_index_space_state intended for use as the sum of the primary id spaces...
bool is_empty() const
True if there are no ids in the space.
virtual bool allocated_iterator(const index_space_iterator &xitr) const
True if and only if id space iterator xitr was allocated by the iterator pool.
Factory and container for a family of id spaces.
An iterator over an id space which is the sum of the primary id spaces.
virtual ~primary_sum_index_space_state()
Destructor.
virtual primary_sum_index_space_state * clone() const
Virtual constructor; create a new instance of the same type at this.
pod_type offset() const
The offset into the hub id space.
static size_type handle_pool_ct()
The number of handles in the pool.
rem_inv_type _rem_inv
The inverse rem map.
SHEAF_DLL_SPEC bool is_valid(pod_index_type xpod_index)
True if an only if xpod_index is valid.
static factory< explicit_index_space_state > & id_space_factory()
A factory for making descendants of this class.
virtual bool contains_term_id(pod_type xi) const
True if this map contains the xi-th term.
const index_space_handle & gathered_id_space() const
The gathered id space.
bool has_gluing() const
Ture if there is any gluing.
pod_type _begin
Beginning id of this space.
void remove_interval(pod_type xbegin, pod_type xend)
Remove an interval of members [xbegin, xend] from this set.
SHEAF_DLL_SPEC pod_index_type invalid_pod_index()
The invalid pod index value.
bool is_same_type(const any *other) const
True if other is the same type as this.
void enable_invariant_check() const
Enable invariant checking.
virtual bool is_attached() const
True if this iterator is attached to a state.
void insert_member(pod_type xmbr)
Insert xmbr into this set.
pod_type hub_pod(pod_type xid) const
The pod index in the unglued hub id space equivalent to xid in this id space. synonym for unglued_hub...
A reallocated pool of objects of type T. Objects in the pool are either allocated or stored in a free...
virtual bool contains(pod_type xid) const
True if this space contains id xid.
map_type::const_iterator map_iterator_type
The type of the interval map iterator.
friend SHEAF_DLL_SPEC size_t deep_size(const primary_sum_index_space_state &xn, bool xinclude_shallow)
The deep size of primary_sum_index_space_state& xn.
virtual index_space_iterator & get_iterator() const
Allocates an id space iterator from the iterator pool.
void remove_member(pod_type xmbr)
Remove xmbr from this set.
void update_extrema()
Update the id extrema.
void extend(size_type xct)
Extend this id space to have ct() == xct.