20 #include "SheafSystem/namespace_poset_dof_map.h" 22 #include "SheafSystem/assert_contract.h" 23 #include "SheafSystem/error_message.h" 24 #include "SheafSystem/dof_map_factory.h" 25 #include "SheafSystem/index_space_iterator.h" 26 #include "SheafSystem/namespace_poset.h" 27 #include "SheafSystem/namespace_poset_schema.h" 28 #include "SheafSystem/poset_type.h" 29 #include "SheafSystem/primitive_type.h" 30 #include "SheafSystem/std_string.h" 46 const string& result = static_class_name();
50 ensure(!result.empty());
65 static const string result(
"namespace_poset_dof_map");
69 ensure(!result.empty());
70 ensure(result ==
"namespace_poset_dof_map");
92 _dofs.type_id = NOT_A_POSET_TYPE;
114 ensure(
dof_ct() == NAMESPACE_SCHEMA_DOF_CT);
159 _dofs = xother._dofs;
160 _storage_map = xother._storage_map;
205 _dofs = xother._dofs;
271 _dofs.type_id = NOT_A_POSET_TYPE;
272 _dofs.class_name = 0;
287 ensure(
host() == xhost);
291 ensure(
dof_ct() == NAMESPACE_SCHEMA_DOF_CT);
317 require(
schema().state_is_read_accessible());
319 require(unexecutable(
"xdof points to buffer of size xdof_size"));
320 require(unexecutable(
"xdof must be aligned for the given data type"));
335 *reinterpret_cast<int*>(xdof) = _dofs.type_id;
338 *
reinterpret_cast<const char**
>(xdof) = _dofs.class_name;
341 *reinterpret_cast<int*>(xdof) = _dofs.prereq_ids[0];
344 *
reinterpret_cast<int*
>(xdof) = _dofs.prereq_ids[1];
347 *reinterpret_cast<int*>(xdof) = _dofs.prereq_ids[2];
350 *
reinterpret_cast<int*
>(xdof) = _dofs.prereq_ids[3];
353 *reinterpret_cast<int*>(xdof) = _dofs.prereq_ids[4];
356 post_fatal_error_message(
"invalid dof id in call to namespace_poset_dof_map::get_dof");
372 require(
schema().state_is_read_accessible());
374 require(unexecutable(
"xdof points to buffer of size xdof_size"));
375 require(unexecutable(
"xdof must be aligned for the given data type"));
393 _dofs.type_id = *
reinterpret_cast<int*
>(
const_cast<void*
>(xdof));
396 _dofs.class_name = *
reinterpret_cast<char**
>(
const_cast<void*
>(xdof));
399 _dofs.prereq_ids[0] = *
reinterpret_cast<int*
>(
const_cast<void*
>(xdof));
402 _dofs.prereq_ids[1] = *
reinterpret_cast<int*
>(
const_cast<void*
>(xdof));
405 _dofs.prereq_ids[2] = *
reinterpret_cast<int*
>(
const_cast<void*
>(xdof));
408 _dofs.prereq_ids[3] = *
reinterpret_cast<int*
>(
const_cast<void*
>(xdof));
411 _dofs.prereq_ids[4] = *
reinterpret_cast<int*
>(
const_cast<void*
>(xdof));
414 post_fatal_error_message(
"invalid dof id in call to namespace_poset_dof_map::put_dof");
477 require(unexecutable(xbuf points to buffer of size xbuflen));
478 require(xbuflen >=
sizeof(
void*));
482 *
reinterpret_cast<dof_struct*
>(xbuf) = _dofs;
486 ensure(unexecutable(
dof tuple copied to xbuf));
501 require(unexecutable(xbuf points to buffer of size xbuflen));
502 require(xbuflen >=
sizeof(
void*));
506 _dofs = *
reinterpret_cast<const dof_struct*
>(xbuf);
510 ensure(unexecutable(xbuf copied to
dof tuple));
528 result = _dofs.pointer;
568 result = _dofs.class_name;
595 result = _dofs.prereq_ids[xi];
624 _storage_map.
clear();
666 _dofs.type_id = xtype_id;
685 _dofs.class_name = xclass;
709 _dofs.prereq_ids[xi] = xid;
735 _dofs.type_id = NOT_A_POSET_TYPE;
736 _dofs.class_name = 0;
738 _storage_map.
clear();
751 _storage_map[litr.
pod()] = lstorage_id;
771 sheaf::namespace_poset_dof_map::
SHEAF_DLL_SPEC poset_type poset_type_id(int xi)
The poset type associated with int xi; converts int to poset type.
virtual const index_space_handle & client_id_space() const
The map from library ids to clients ids for the schema this is defined on.
const char * poset_class() const
The class of the poset associated with this namespace member.
bool is_table_dof_map() const
True if this is a table dof map.
virtual void put_dof_tuple(const void *xbuf, size_t xbuflen)
Copies the entire dof tuple from xbuf into internal storage.
namespace_poset_dof_map & operator=(const namespace_poset_dof_map &xother)
Assignment operator.
virtual void * dof_tuple()
The dof tuple (mutable version).
abstract_poset_member & top()
The top member of the poset (mutable version)
An abstract iterator over the ids of an id space.
static const std::string & static_class_name()
The name of this class.
const index_space_handle & dof_id_space(bool xis_table_dofs) const
The table dof (xis_table_dof true) or row dof id space for the schema defined by this.
virtual namespace_poset_dof_map * copy() const
Virtual copy constructor.
pod_type pod() const
The current id in the iteration.
The default name space; a poset which contains other posets as members.
const int NAMESPACE_SCHEMA_DOF_CT
The number of dofs defined by the namespace schema.
poset_type
Identifiers for poset types.
poset_type poset_type_id() const
The type id of the poset associated with this namespace member.
virtual schema_poset_member & schema()
The schema on which this is allocated (mutable version).
primitive_value dof(pod_index_type xdof_id) const
The dof referred to by xdof_id.
A client handle for a general, abstract partially order set.
virtual bool invariant() const
The class invariant.
bool _is_table_dof_map
True if this is a table dof map.
void put_poset_type_id(poset_type xtype_id)
Set the type id of the poset associated with this namespace member to xtype_id.
bool is_initialized() const
True if this has been initialized, that is, if the schema has been set and the dof map storage alloca...
void reserve(index_type xub)
Makes ub() at least xub; if new storage is allocated, it is uninitialized.
An abstract handle to a space of alternate integer identifiers (aliases) for a subset of a hub set of...
poset_state_handle * poset_pointer() const
The pointer to the poset associated with this namespace member.
poset_dof_map & operator=(const poset_dof_map &xother)
Assignment operator.
virtual void next()=0
Makes id() the next id in the iteration.
int poset_prereq_id(int xi) const
The id of the xi-th prerequisite poset for the poset associated with this namespace member...
The general, abstract map from dof ids to dof values.
void put_poset_class(const char *xclass)
Set the class of the poset associated with this namespace member to xclass.
virtual void get_dof_tuple(void *xbuf, size_t xbuflen) const
Copies the entire dof tuple from xbuf into internal storage.
size_t _dof_tuple_ub
The size of the dof tuple.
void extend_to_top()
Extends the schema from member io to member top. /.
static dof_map_factory & factory()
The dof map factory.
void put_poset_pointer(const poset_state_handle *xposet)
Set the pointer to the poset associated with this namespace member to xposet.
bool is_done() const
True if iteration is finished.
virtual bool invariant() const
The class invariant.
void put_poset_prereq_id(int xi, int xid)
Set the id of the xi-th prerequisite poset for the poset associated with this namespace member...
virtual void release_iterator(index_space_iterator &xitr) const =0
Returns the id space iterator xitr to the iterator pool.
virtual namespace_poset_dof_map * clone() const
Virtual default constructor.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
namespace_poset_dof_map()
Default constructor.
dof_tuple_type
Identifiers for dof tuple types.
static int row_dof_ct(const namespace_poset &xns, const poset_path &xpath, bool xauto_access=true)
The number of row dofs defined by the schema specified by xns and xpath. Synonym for dof_ct(xns...
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
virtual pod_type pod(pod_type xid) const =0
The pod index in this space equivalent to xid in the hub id space.
virtual index_space_iterator & get_iterator() const =0
Allocates an id space iterator from the iterator pool.
int _dof_ct
The number of dofs in this map.
virtual schema_poset_member & schema()
The schema for this poset member (mutable version).
int dof_ct() const
The number of dofs in this map.
virtual void allocate_dofs()
Allocates dof storage.
virtual poset_state_handle * host() const
The poset which owns this.
size_t row_dof_tuple_ub() const
The size in bytes of the row dof tuple defined by this schema. Synonym for dof_tuple_ub(false).
bool invariant_check() const
True if invariant checking is enabled.
schema_poset_member * _schema
The schema on which this is instantiated.
virtual void get_dof(pod_index_type xdof_id, void *xdof, size_type xdof_size) const
Copies the dof referred to by xdof_id into xdof.
virtual const std::string & class_name() const
The name of the actual (possibly derived) class of this instance.
int_type pod_index_type
The plain old data index type.
void tuple(pod_index_type x, size_type xj_ub, pod_index_type &xi, pod_index_type &xj)
Ordinal to 2-tuple conversion.
void attach_to_state(const namespace_poset *xns, const poset_path &xpath, bool xauto_access=true)
Attach to the state specified by path xpath in the namespace xns.
poset_state_handle * _host
The host of the poset member for which this stores the dofs.
A map from schema poset member ids to dof values for namespace_poset members.
void insert_prototype(const poset_dof_map *xprototype)
Sets xprototype as the prototype for its client class.
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.
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 ~namespace_poset_dof_map()
Destructor.
unsigned int ref_ct() const
The number of references to this map.
const scoped_index & index() const
The index of this in host() dof tuple table.
pod_type hub_pod() const
The current unglued hub id in the iteration. synonym for unglued_hub_pod().
virtual void put_dof(pod_index_type xdof_id, const void *xdof, size_type xdof_size)
Sets the dof referred to by xdof_id to the value at xdof.
const int PREREQ_IDS_UB
Number of prerequisites ids. Must be consistent with PREREQ_ID_*_INDEX below.