21 #include "SheafSystem/array_index_space_state.h" 22 #include "SheafSystem/assert_contract.h" 23 #include "SheafSystem/array_index_space_handle.h" 24 #include "SheafSystem/array_index_space_iterator.h" 25 #include "SheafSystem/deep_size.h" 26 #include "SheafSystem/index_space_family.h" 27 #include "SheafSystem/hub_index_space_handle.h" 41 const std::string& xname,
47 require(!xname.empty());
48 require(!xid_spaces.
contains(xname));
49 require(xcapacity >= 0);
54 lstate->
new_state(xid_spaces, xname, xis_persistent);
62 ensure(&result.
id_spaces() == &xid_spaces);
67 ensure(result.
name() == xname);
69 ensure(result.
capacity() >= xcapacity);
80 const std::string& xname,
88 require(!xname.empty());
89 require(!xid_spaces.
contains(xname));
90 require(xcapacity >= 0);
95 lstate->
new_state(xid_spaces, xid, xname, xis_persistent);
103 ensure(&result.
id_spaces() == &xid_spaces);
107 ensure(result.
index() == xid);
109 ensure(result.
name() == xname);
111 ensure(result.
capacity() >= xcapacity);
187 to_domain_type::const_iterator itr =
_to_domain.begin();
192 _end = itr->second + 1;
253 ensure(is_basic_query);
357 ensure(
contains(xdomain_id, xrange_id));
383 ensure(
contains(old_next_id, xrange_id));
401 define_old_variable(
pod_type old_itr_pod = xitr.
pod());
412 ensure(
contains(old_itr_pod, xrange_id));
413 ensure(xitr.
pod() == old_itr_pod+1);
414 ensure(xitr.
hub_pod() == old_itr_hub_pod);
442 to_domain_type::iterator itr =
_to_domain.find(xid);
506 define_old_variable(
pod_type old_itr_id = xitr.
pod());
517 ensure(xitr.
is_done() || xitr.
pod() > old_itr_id);
540 ensure(unexecutable(
"map rep is empty"));
584 assertion(ldomain_id ==
_ct);
594 ensure(unexecutable(
"map rep is gathered"));
679 (void) scattered_insertion_index_space_state::operator=(xother);
684 ensure((*
this) == xother);
713 ensure(is_basic_query);
732 ensure(is_basic_query);
753 ensure(is_basic_query);
768 to_domain_type::const_iterator itr =
_to_domain.find(xhub_id);
894 handles().release(reinterpret_cast<array_index_space_handle&>(xid_space));
898 ensure(is_basic_query);
916 bool result = (lid_space != 0) && handles().allocated(*lid_space);
920 ensure(is_basic_query);
932 sheaf::array_index_space_state::
943 ensure(is_basic_query);
1031 iterators().release(reinterpret_cast<array_index_space_iterator&>(xitr));
1035 ensure(is_basic_query);
1053 bool result = (litr != 0) && iterators().allocated(*litr);
1057 ensure(is_basic_query);
1069 sheaf::array_index_space_state::
1080 ensure(is_basic_query);
1098 static const std::string result(
"array_index_space_state");
1114 ensure(result != 0);
1127 sheaf::array_index_space_state::
1158 require(other != 0);
1218 size_t result = xinclude_shallow ?
sizeof(xn) : 0;
1229 result += deep_size<pod_type, pod_type, to_domain_policy_type>(xn.
_to_domain,
false);
1237 ensure(result >= 0);
virtual void reserve(size_type xcapacity)
Reserve enough memory for xcapacity number of ids.
static size_type handle_pool_deep_size()
The deep size of the handle pool.
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 array_index_space_state & operator=(const explicit_index_space_state &xother)
Assignment operator.
virtual void map_rep_gather()
Gathers the map representation into an interval.
index_type ub() const
The upper bound on the storage array. The number of items current allocated in the storage array...
virtual pod_type index() const
Index of this space.
An abstract iterator over the ids of an id space.
virtual index_space_iterator & get_iterator() const
Allocates an id space iterator from the iterator pool.
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.
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.
pod_type pod() const
The current id in the iteration.
virtual bool invariant() const
Class invariant.
virtual size_type map_rep_remove_entry(pod_type xid, bool xis_range_id)
Removes the entry containing range id xid (xis_range_id true) or domain id xid (xis_range_id false) f...
virtual bool is_persistent() const
True if this id space should be written to disk.
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...
virtual void map_rep_push_back(pod_type xrange_id)
Inserts entry (next_id(), xrange_id) into the map representation.
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 reserve(index_type xub)
Makes ub() at least xub; if new storage is allocated, it is uninitialized.
virtual void detach()=0
Detach this handle form its state, if any.
An implementation of class explicit_index_space_state that supports either gathered or scattered inse...
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 ~array_index_space_state()
Destructor.
void initialize(index_type xindex)
Invokes the initialization policy on the item at xindex.
An array implementation of class scattered_insertion_index_space_state. This representation is intend...
virtual size_type capacity() const
The number of ids reserved in memory.
static size_type handle_pool_ct()
The number of handles in the pool.
virtual void detach()=0
Detach this handle form its state, if any.
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.
to_range_type _to_range
The representation of the domain id to range id map.
virtual bool invariant() const
Class invariant.
Abstract base class with useful features for all objects.
virtual void map_rep_clear()
Removes all entrires from the map representation.
bool is_done() const
True if iteration is finished.
An immutable abstract state for a space of alternate integer identifiers (aliases) for a subset of th...
virtual pod_type pod(pod_type xid) const
The pod index in this space equivalent to xid in the hub id space.
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
virtual void map_rep_push(index_space_iterator &xitr, pod_type xrange_id)
Inserts entry (xitr.pod(), xrange_id) into the map representation. Increments all domain ids greater ...
std::string name() const
Name of this space.
Do not call deep_size on either the key or value.
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.
virtual bool is_attached() const
True if this handle is attached to a state.
void invalidate_extrema()
Invalidate the extrema.
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.
An array implementation of class scattered_insertion_index_space_handle. This representation is inten...
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
virtual void map_rep_insert_entry(pod_type xdomain_id, pod_type xrange_id)
Inserts entry (xdomain_id, xrange_id) into the map representation.
const hub_index_space_handle & hub_id_space() const
The hub id space.
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 bool contains_unglued_hub(pod_type xid) const
True if this space contains an id equivalent to xid in the unglued hub id space.
static size_type iterator_pool_ct()
The number of iterators in the pool.
virtual void update_extrema_after_remove()
Update the id extrema after a remove operation.
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
void new_state(index_space_family &xid_spaces, const std::string &xname, bool xis_persistent)
Create a new id space state in the id space family xid_spaces at the next available id space index wi...
virtual void release_id_space(index_space_handle &xid_space) const
Release the id space handle xid_space.
virtual bool operator==(const explicit_index_space_state &xother) const
True if this is equivalent to xother.
virtual bool operator==(const explicit_index_space_state &xother) const
True if this is equivalent to xother.
size_type capacity() const
The number of ids reserved in memory.
virtual void update_extrema()
Update the id extrema.
size_type _ct
The number of members.
virtual bool contains(pod_type xid) const
True if this space contains id xid.
bool invariant_check() const
True if invariant checking is enabled.
An iterator over an id space in which the equivalence between the ids in the space and the hub id spa...
pod_index_type pod_type
The "plain old data" index type for this.
int_type pod_index_type
The plain old data index type.
virtual index_space_handle & get_id_space() const
The id space handle with this state.
virtual const std::string & class_name() const
The name of this class.
virtual void release_iterator(index_space_iterator &xitr) const
Returns the id space iterator xitr to the iterator pool.
bool contains(pod_type xid) const
True, if this contains an id space with id xid.
static array_index_space_handle new_space(index_space_family &xid_spaces, const std::string &xname, bool xis_persistent, size_type xcapacity)
Create a new array id space in the id space family xid_spaces at the next available id space index wi...
array_index_space_state()
Default constructor.
friend SHEAF_DLL_SPEC size_t deep_size(const array_index_space_state &xn, bool xinclude_shallow)
The deep size of array_index_space_state& xn.
bool is_empty() const
True if there are no ids in the space.
Factory and container for a family of id spaces.
void clear()
Remove all items.
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.
pod_type _begin
Beginning id of this space.
SHEAF_DLL_SPEC pod_index_type invalid_pod_index()
The invalid pod index value.
pod_type next_id() const
The id inserted by the next call to push_back.
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.
A reallocated pool of objects of type T. Objects in the pool are either allocated or stored in a free...
static size_type iterator_pool_deep_size()
The deep size of the iterator pool.
to_domain_type _to_domain
The representation of the range id to domain id map.
virtual array_index_space_state * clone() const
Virtual constructor; create a new instance of the same type at this.
pod_type hub_pod() const
The current unglued hub id in the iteration. synonym for unglued_hub_pod().