20 #include "SheafSystem/array_poset_dof_map.h" 22 #include "SheafSystem/arg_list.h" 23 #include "SheafSystem/assert_contract.h" 24 #include "SheafSystem/error_message.h" 25 #include "SheafSystem/dof_descriptor_array.h" 26 #include "SheafSystem/dof_map_factory.h" 27 #include "SheafSystem/poset_state_handle.h" 28 #include "SheafSystem/std_string.h" 48 const string& result = static_class_name();
52 ensure(!result.empty());
68 static const string result(
"array_poset_dof_map");
72 ensure(!result.empty());
73 ensure(result ==
"array_poset_dof_map");
95 _this_owns_dofs =
false;
145 _dof_descriptors = 0;
146 _this_owns_dofs =
false;
199 if(_dof_descriptors != 0)
202 if((_dofs != 0) && _this_owns_dofs)
205 if(xother._dofs != 0)
209 _dof_descriptors = xother._dof_descriptors;
215 _this_owns_dofs = xother._this_owns_dofs;
224 _dofs = xother._dofs;
230 _dof_descriptors = 0;
231 _this_owns_dofs =
false;
255 if(_dof_descriptors != 0)
296 result = result && ( _dof_descriptors != 0 ?
dof_tuple_ub() == (*_dof_descriptors)[
dof_ct()].offset :
true);
316 bool xis_table_dof_map,
326 require((xdofs != 0) ? xdofs_ub >= xhost->
schema().
dof_tuple_ub(xis_table_dof_map):
true);
327 require(unexecutable(
"if xdofs != 0 it points to buffer of length xdofs_ub"));
345 ensure(((
dof_ct() != 0) && (xdofs != 0)) ?
dof_tuple() == xdofs :
true);
356 require(xschema != 0);
394 result = ARRAY_POSET_DOF_TUPLE_ID;
398 ensure(result == ARRAY_POSET_DOF_TUPLE_ID);
418 require(
schema().state_is_read_accessible());
420 require(unexecutable(
"xdof points to buffer of size xdof_size"));
430 char* ldof = _dofs+ldesc.offset;
438 memcpy(xdof, ldof, ldesc.size);
453 require(
schema().state_is_read_accessible());
455 require(unexecutable(
"xdof points to buffer of size xdof_size"));
465 char* ldof = _dofs+ldesc.offset;
473 memcpy(ldof, xdof, ldesc.size);
502 ensure((result != 0) == (
dof_ct() != 0));
525 ensure((result != 0) == (
dof_ct() != 0));
545 memcpy(xbuf, static_cast<void*>(_dofs),
dof_tuple_ub());
550 ensure(unexecutable(
dof tuple copied to xbuf));
571 memcpy(static_cast<void*>(_dofs), xbuf,
dof_tuple_ub());
576 ensure(unexecutable(xbuf copied to
dof tuple));
592 require(
schema().contains_row_dof(xschema_mbr));
617 require((0 <= xclient_id) && (xclient_id <
dof_ct()));
621 size_t ldof_offset = (*_dof_descriptors)[xclient_id].offset;
622 result = _dofs+ldof_offset;
649 _this_owns_dofs =
true;
653 _dofs =
static_cast<char*
>(xdofs);
654 _this_owns_dofs =
false;
659 _this_owns_dofs =
false;
665 ensure((
dof_ct() != 0) == (_dofs != 0));
666 ensure(unexecutable(size of _dofs array ==
dof_tuple_ub()));
715 #ifdef DIAGNOSTIC_OUTPUT 716 cout <<
" xdof_id: " << xdof_id
717 <<
" offset: " << loffset
718 <<
" size: " << lsize
721 <<
" result: " << boolalpha << result << noboolalpha
727 post_fatal_error_message(
"dof_in_bounds check failed");
740 sheaf::array_poset_dof_map::
virtual const index_space_handle & client_id_space() const
The map from library ids to clients ids for the schema this is defined on.
static const std::string & static_class_name()
The name of this class.
bool is_table_dof_map() const
True if this is a table dof map.
virtual void allocate_dofs()
Allocates dof storage.
virtual ~array_poset_dof_map()
Destructor.
virtual array_poset_dof_map * clone() const
Virtual default constructor.
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
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.
static int dof_ct(const namespace_poset &xns, const poset_path &xpath, bool xis_table_dof, bool xauto_access=true)
The number of table dofs (xis_table_dof true) or row dofs defined by the schema specified by xns and ...
dof_descriptor_array * dof_descriptors(bool xis_table_dof) const
The dof_descriptors_array for the table dof tuple (xis_table_dof true) or row dof tuple defined by th...
bool is_initialized() const
True if this has been initialized, that is, if the schema has been set and the dof map storage alloca...
char * dof_ptr(const schema_poset_member &xschema_mbr)
Pointer to the first byte of the dof associated with xschema_mbr.
poset_dof_map & operator=(const poset_dof_map &xother)
Assignment operator.
const scoped_index & index() const
The index of the component state this handle is attached to.
The general, abstract map from dof ids to dof values.
size_t _dof_tuple_ub
The size of the dof tuple.
static dof_map_factory & factory()
The dof map factory.
virtual dof_tuple_type type_id() const
An identifer for the type of dof tuple this is.
virtual schema_poset_member & schema()
The schema for this poset (mutable version).
virtual bool invariant() const
The class invariant.
size_t dof_tuple_ub() const
The size of the dof tuple in bytes.
virtual bool invariant() const
The class invariant.
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.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
dof_tuple_type
Identifiers for dof tuple types.
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
array_poset_dof_map()
Default constructor; protected because doesn't initialize schema.
bool dof_in_bounds(pod_index_type xdof_id) const
True if and only if the dof asociated with id xdof_id is within the bounds of the dofs storage...
int dof_ct() const
The number of dofs in this map.
Basic description of a dof.
void remove_reference()
Remove a reference from this.
virtual void * dof_tuple()
The dof tuple (mutable version).
virtual void put_dof_tuple(const void *xbuf, size_t xbuflen)
Copies the entire dof tuple from xbuf into internal storage.
void init_dofs(void *xdofs)
Allocates dof array.
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.
bool invariant_check() const
True if invariant checking is enabled.
size_t dof_tuple_ub(bool xis_table_dof) const
The size in bytes of the table dof tuple (xis_table_dof true) or the row dof tuple defined by this sc...
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 add_reference()
Add a reference to this.
virtual void get_dof_tuple(void *xbuf, size_t xbuflen) const
Copies the entire dof tuple from internal storage into xbuf.
void tuple(pod_index_type x, size_type xj_ub, pod_index_type &xi, pod_index_type &xj)
Ordinal to 2-tuple conversion.
void insert_prototype(const poset_dof_map *xprototype)
Sets xprototype as the prototype for its client class.
An array representation of abstract class poset_dof_map.
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 array_poset_dof_map * copy() const
Virtual copy constructor.
A client handle for a poset member which has been prepared for use as a schema.
array_poset_dof_map & operator=(const array_poset_dof_map &xother)
Assignment operator.