20 #include "SheafSystem/poset_dof_map.h" 22 #include "SheafSystem/arg_list.h" 23 #include "SheafSystem/assert_contract.h" 24 #include "SheafSystem/dof_descriptor_array.h" 25 #include "SheafSystem/dof_map_factory.h" 26 #include "SheafSystem/poset_dof_iterator.h" 27 #include "SheafSystem/poset_state_handle.h" 28 #include "SheafSystem/primitive_value.h" 44 const string& result = static_class_name();
48 ensure(!result.empty());
63 static const string result(
"poset_dof_map");
67 ensure(!result.empty());
68 ensure(result ==
"poset_dof_map");
85 result =
factory().new_dof_map(xclass_name, xsheaf_base_class_id);
162 require(ref_ct() == 0);
166 _host = xother.
_host;
171 _schema->detach_from_state();
185 ensure(host() == xother.
host());
186 ensure(index() == xother.
index());
187 ensure(schema().is_same_state(&xother.
schema()));
189 ensure(dof_ct() == xother.
dof_ct());
191 ensure(ref_ct() == 0);
205 require(ref_ct() == 0);
211 _schema->detach_from_state();
233 if(invariant_check())
237 disable_invariant_check();
245 invariance(unexecutable(
"is_initialized() ? version() == schema().version(true) : true"));
250 enable_invariant_check();
272 require(!is_initialized());
291 _index.put_scope(_host->dof_tuple_hub_id_space(
false));
298 _schema->put_version(xschema_version,
true);
300 _is_table_dof_map =
false;
301 _dof_ct = _schema->row_dof_ct();
302 _dof_tuple_ub = _schema->row_dof_tuple_ub();
310 ensure(is_initialized());
311 ensure(host() == xhost);
313 ensure(index().same_scope(host()->dof_tuple_hub_id_space(
false)));
314 ensure(is_table_dof_map() ==
false);
315 ensure(dof_ct() == schema().row_dof_ct());
316 ensure(dof_tuple_ub() == schema().row_dof_tuple_ub());
317 ensure(version() == schema().version(
true));
318 ensure(ref_ct() == 0);
319 ensure(schema().index() == xschema_mbr_id);
320 ensure(version() == schema().unaliased_version(xschema_version));
336 require(!is_initialized());
352 init_row_dof_map(xhost, xschema_mbr_id.
hub_pod(), xschema_version);
356 ensure(is_initialized());
357 ensure(host() == xhost);
361 ensure(is_table_dof_map() ==
false);
362 ensure(dof_ct() == schema().row_dof_ct());
363 ensure(dof_tuple_ub() == schema().row_dof_tuple_ub());
364 ensure(version() == schema().version(
true));
365 ensure(ref_ct() == 0);
366 ensure(schema().index() ==~ xschema_mbr_id);
367 ensure(version() == schema().unaliased_version(xschema_version));
384 result = (_schema != 0);
436 require(is_initialized());
455 require(is_initialized());
479 result = _is_table_dof_map;
524 require(schema().state_is_read_accessible());
525 require(schema().dof_id_space(is_table_dof_map()).contains(xdof_id));
533 result.
id() = schema().type(xdof_id, _is_table_dof_map);
549 require(schema().state_is_read_accessible());
550 require(schema().dof_id_space(is_table_dof_map()).contains(xdof_id));
555 schema().dof_id_space(_is_table_dof_map).pod(xdof_id);
567 dof(
const std::string& xname)
const 571 require(schema().state_is_read_accessible());
572 require(!xname.empty());
573 require(schema().contains_dof(xname, is_table_dof_map()));
577 pod_index_type lhub_id = schema().host()->member_id(xname,
false);
578 pod_index_type lindex = schema().dof_id_space(_is_table_dof_map).pod(lhub_id);
594 require(schema().state_is_read_accessible());
595 require(schema().dof_id_space(is_table_dof_map()).contains(xdof_id));
596 require(xdof.
id() == schema().type(xdof_id, is_table_dof_map()));
604 ensure(dof(xdof_id) == xdof);
617 require(schema().state_is_read_accessible());
618 require(schema().dof_id_space(is_table_dof_map()).contains(xdof_id));
620 require(xdof.
id() == schema().type(xdof_id, is_table_dof_map(),
false));
624 pod_index_type lindex = schema().dof_id_space(_is_table_dof_map).pod(xdof_id);
625 put_dof(lindex, xdof);
629 ensure(dof(xdof_id) == xdof);
642 require(schema().state_is_read_accessible());
643 require(schema().contains_dof(xname, is_table_dof_map()));
644 require(xdof.
id() == schema().type(xname, is_table_dof_map(),
false));
648 pod_index_type lhub_id = schema().host()->member_id(xname,
false);
649 pod_index_type lindex = schema().dof_id_space(_is_table_dof_map).pod(lhub_id);
650 put_dof(lindex, xdof);
654 ensure(dof(xname) == xdof);
667 require(schema().state_is_read_accessible());
668 require(schema().dof_id_space(is_table_dof_map()).contains(xdof_id));
669 require(unexecutable(
"xdof points to buffer of size xdof_size"));
670 require(xdof_size >= schema().size(xdof_id, is_table_dof_map()));
690 require(schema().state_is_read_accessible());
691 require(schema().dof_id_space(is_table_dof_map()).contains(xdof_id));
692 require(unexecutable(
"xdof points to buffer of size xdof_size"));
693 require(xdof_size >= schema().size(xdof_id, is_table_dof_map(),
false));
698 schema().dof_id_space(_is_table_dof_map).pod(xdof_id);
699 get_dof(lindex, xdof, xdof_size);
715 require(schema().state_is_read_accessible());
716 require(schema().dof_id_space(is_table_dof_map()).contains(xdof_id));
717 require(unexecutable(
"xdof points to buffer of size xdof_size"));
718 require(xdof_size >= schema().size(xdof_id, is_table_dof_map()));
738 require(schema().state_is_read_accessible());
739 require(schema().dof_id_space(is_table_dof_map()).contains(xdof_id));
740 require(unexecutable(
"xdof points to buffer of size xdof_size"));
741 require(xdof_size >= schema().size(xdof_id, is_table_dof_map(),
false));
746 schema().dof_id_space(_is_table_dof_map).pod(xdof_id);
748 put_dof(lindex, xdof, xdof_size);
772 result = _dof_tuple_ub;
790 require(schema().state_is_read_accessible());
811 #ifdef DIAGNOSTIC_OUTPUT 812 cout <<
"poset_dof_map::get_dof_tuple: " << endl;
813 cout <<
"\thost name: " << host()->name() << endl;
814 cout <<
"\tschema name: " << schema().name() << endl << endl;
815 cout << xargs << endl;
821 ensure(xargs.
ct() == dof_ct());
822 ensure(xargs.
conforms_to(schema(), is_table_dof_map(),
false));
838 require(dof_ct() == xargs.
ct());
839 require(schema().state_is_read_accessible());
840 require(xargs.
conforms_to(schema(), is_table_dof_map(),
false));
844 #ifdef DIAGNOSTIC_OUTPUT 845 cout <<
"poset_dof_map::put_dof_tuple: schema:: " << schema().name()
846 <<
" table_dof_descriptors: " << *(schema().table_dof_descriptors()) << endl;
865 #ifdef DIAGNOSTIC_OUTPUT 866 cout << *
this << endl;
875 ensure(unexecutable(
"xargs copied to dof tuple"));
891 require(dof_ct() == xother.
dof_ct());
892 require(schema().state_is_read_accessible());
901 put_dof_tuple(largs);
919 require(schema().state_is_read_accessible());
939 ensure(unexecutable(xargs copied to dof
tuple));
978 define_old_variable(
unsigned int old_ref_ct = _ref_ct);
984 ensure(ref_ct() == old_ref_ct + 1);
1000 define_old_variable(
unsigned int old_ref_ct = _ref_ct);
1006 ensure(ref_ct() == old_ref_ct - 1);
1023 require(is_initialized());
1027 result = _schema->version();
1044 require(is_initialized());
1049 _schema->dof_id_space(_is_table_dof_map);
1108 _index.invalidate();
1111 _is_table_dof_map =
false;
1118 ensure(!is_initialized());
1119 ensure(host() == 0);
1123 ensure(is_table_dof_map() ==
false);
1124 ensure(dof_ct() == 0);
1125 ensure(dof_tuple_ub() == 0);
1126 ensure(ref_ct() == 0);
1152 _dof_tuple_ub =
const_cast<poset_dof_map&
>(xother).dof_tuple_ub();
1157 ensure(is_initialized());
1158 ensure(host() == xother.
host());
1159 ensure(index() == xother.
index());
1160 ensure(schema().is_same_state(&xother.
schema()));
1162 ensure(dof_ct() == xother.
dof_ct());
1164 ensure(ref_ct() == 0);
1179 require(xhost != 0);
1186 _index.invalidate();
1187 _index.put_scope(_host->dof_tuple_hub_id_space(
false));
1194 _schema->put_version(_schema->version(),
true);
1196 _is_table_dof_map = xis_table_dof_map;
1198 _dof_ct = _schema->dof_ct(_is_table_dof_map);
1199 _dof_tuple_ub = _schema->dof_tuple_ub(_is_table_dof_map);
1205 ensure(is_initialized());
1206 ensure(host() == xhost);
1209 ensure(index().same_scope(host()->dof_tuple_hub_id_space(
false)));
1210 ensure(schema().is_same_state(&xhost->
schema()));
1211 ensure(is_table_dof_map() == xis_table_dof_map);
1212 ensure(dof_ct() == schema().dof_ct(is_table_dof_map()));
1213 ensure(dof_tuple_ub() == schema().dof_tuple_ub(is_table_dof_map()));
1214 ensure(version() == schema().version(
true));
1227 require(xschema != 0);
1234 _index.invalidate();
1237 _schema = xschema->
clone();
1242 _schema->put_version(_schema->version(),
true);
1244 _is_table_dof_map = xis_table_dof_map;
1246 _dof_ct = _schema->dof_ct(_is_table_dof_map);
1247 _dof_tuple_ub = _schema->dof_tuple_ub(_is_table_dof_map);
1253 ensure(is_initialized());
1254 ensure(host() == 0);
1256 ensure(index().same_scope(schema().host()->dof_tuple_hub_id_space(
false)));
1257 ensure(schema().is_same_state(xschema));
1258 ensure(is_table_dof_map() == xis_table_dof_map);
1259 ensure(dof_ct() == schema().dof_ct(is_table_dof_map()));
1260 ensure(dof_tuple_ub() == schema().dof_tuple_ub(is_table_dof_map()));
1261 ensure(version() == schema().version(
true));
1274 require(is_initialized());
1284 ensure(host() == xhost);
1305 ensure(index() == xindex);
1325 ensure(dof_ct() == xdof_ct);
1341 _dof_tuple_ub = xub;
1345 ensure(dof_tuple_ub() == xub);
1358 require(xref_ct >= 0);
1366 ensure(ref_ct() == xref_ct);
1382 if(schema().contains_dof(xschema, _is_table_dof_map))
1384 result = xschema.
name() +
"=" + dof(xschema.
index()).to_string();
1412 result += to_string(lschema);
1423 result += to_string(lschema);
1470 result = xinclude_shallow ?
sizeof(xp) : 0;
1478 result += deep_size(*xp.
_schema,
true);
1487 ensure(result >= 0);
virtual const index_space_handle & client_id_space() const
The map from library ids to clients ids for the schema this is defined on.
primitive_value value
The value of the argument.
poset_state_handle * host() const
The poset which this is a handle to a component of.
bool is_table_dof_map() const
True if this is a table dof map.
bool is_valid() const
True if this is a valid id.
virtual void next()
Makes this the next member of the subset.
virtual bool supports_xfr_opt() const
True if this dof map type supports dof tuple transfer optimization. /.
virtual void put_host(const poset_state_handle *xhost)
Sets host() to xhost.
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
schema_poset_member & item()
The current member of the iteration (mutable version).
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.
int version() const
The version of the host of the schema this is defined on.
A client handle for a general, abstract partially order set.
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.
static poset_dof_map * new_dof_map(const std::string &xclass_name, dof_tuple_type xsheaf_base_class_id)
Creates an uninitialized dof map of type xclass_name, if a prototype of that name exists...
bool _is_table_dof_map
True if this is a table dof map.
bool is_initialized() const
True if this has been initialized, that is, if the schema has been set and the dof map storage alloca...
bool is_same_state(const poset_state_handle *xhost, pod_index_type xhub_id) const
True is this is attached to state with hub id xhub_id in host xhost.
An abstract handle to a space of alternate integer identifiers (aliases) for a subset of a hub set of...
void put_index(const scoped_index &xindex)
Sets the index of the member for which this provides the dofs.
virtual ~poset_dof_map()
Destructor.
virtual bool is_done() const
True if iteration finished.
poset_dof_map & operator=(const poset_dof_map &xother)
Assignment operator.
virtual void get_dof_tuple(void *xbuf, size_t xbuflen) const =0
Copies the entire dof tuple from internal storage into xbuf.
const scoped_index & index() const
The index of the component state this handle is attached to.
void put_dof_tuple_ub(size_t xub)
Sets dof_tuple_ub() to xub.
The general, abstract map from dof ids to dof values.
virtual bool is_attached() const =0
True if this handle is attached to a state.
The internal argument type.
virtual primitive_type type() const
The primitive type index of the dof defined by this.
void copy_dof_tuple(const poset_dof_map &xother)
Copies the dof tuple of xother into this.
bool has_version(int xversion) const
True if xversion is a valid version.
const hub_index_space_handle & dof_tuple_hub_id_space(bool xauto_access) const
The dof tuple hub id space.
size_t _dof_tuple_ub
The size of the dof tuple.
virtual void put_defaults()
Sets all dofs to defualt values.
schema_poset_member * clone(bool xnew_state, bool xauto_access=true) const
Make a new handle instance of current. Attach the new instance to a new state if xnew_state is true...
std::string name
The name of the argument.
void put_ref_ct(int xref_ct)
Sets ref_ct() to xref_ct).
A whitespace separated list of arguments. Insertion operaters are used to insert arguments into the l...
static dof_map_factory & factory()
The dof map factory.
virtual schema_poset_member & schema()
The schema for this poset (mutable version).
A factory for instanting descendants of an abstract type T, given the class name of the descendant...
virtual bool invariant() const
The class invariant.
primitive_value & value(int xi)
The value of the xi-th argument.
Type of buffer large enough to hold any primitive type.
size_t dof_tuple_ub() const
The size of the dof tuple in bytes.
An index within the external ("client") scope of a given id space.
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.
virtual poset_dof_map * copy() const =0
Virtual copy constructor.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
void inc_ref_ct()
Increase the number of references to this map by one;.
void put_dof_ct(int xdof_ct)
Sets dof_ct() to xdof_ct.
virtual void init_row_dof_map(const poset_state_handle *xhost, pod_index_type xschema_mbr_id, int xschema_version)
Initializes this as a map for row dofs in host xhost, with schema member specified by xschema_mbr_id ...
virtual bool contains_member(pod_index_type xmbr_hub_id, bool xauto_access=true) const
True if some version of this poset contains poset member with hub id xmbr_hub_id. ...
std::string name(pod_index_type xdof_id, bool xis_table_dof) const
The name of the table dof (xis_table_dof true) or row dof referred to by xdof_id in the schema define...
unsigned int ct() const
The number of arguments.
scoped_index _index
The poset member for which this stores the dofs.
dof_tuple_type
Identifiers for dof tuple types.
int _dof_ct
The number of dofs in this map.
static const std::string & static_class_name()
The name of this class.
int dof_ct() const
The number of dofs in this map.
primitive_buffer_type & value()
The value of this.
void dec_ref_ct()
Decrease the number of references to this map by one.
bool conforms_to(const namespace_poset &xns, const poset_path &xschema_path, bool xuse_table_schema, bool xauto_access) const
True if the values in this conform to the table schema (xuse_table_schema true) or row schema (xuse_t...
virtual poset_state_handle * host() const
The poset which owns this.
primitive_type & id()
Type id of the primitive type.
int index(const std::string &xname) const
The index of the argument with name xname.
Iterates in postorder over dofs of a schema member anchor. Attaches a handle of type schema_poset_mem...
schema_poset_member * _schema
The schema on which this is instantiated.
void put_dof(pod_index_type xdof_id, const primitive_value &xdof)
Sets the dof referred to by xdof_id to xdof.
int_type pod_index_type
The plain old data index type.
SHEAF_DLL_SPEC std::ostream & operator<<(std::ostream &os, const dof_descriptor_array &p)
Insert dof_descriptor_array& p into ostream& os.
void put_type(primitive_type xid)
Sets the type of the argument to xid.
virtual void put_dof_tuple(const void *xbuf, size_t xbuflen)=0
Copies the entire dof tuple from xbuf into internal storage.
std::string to_string(const schema_poset_member &xschema) const
Return schema member dof value as a string.
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.
Abstract object wrapper for an instance of a primitive type.
poset_state_handle * _host
The host of the poset member for which this stores the dofs.
poset_dof_map()
Default constructor;.
void push_back(const arg_type &xarg)
A factory for creating dof maps.
SHEAF_DLL_SPEC bool is_valid(pod_index_type xpod_index)
True if an only if xpod_index is valid.
virtual const std::string & class_name() const
The name of the actual (possibly derived) class of this instance.
bool is_same_type(const any *other) const
True if other is the same type as this.
bool is_positive() const
True if this is greater than or equal to ZERO.
virtual poset_dof_map * clone() const =0
Virtual default constructor.
unsigned int ref_ct() const
The number of references to this map.
A client handle for a poset member which has been prepared for use as a schema.
const scoped_index & index() const
The index of this in host() dof tuple table.
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
std::string to_string() const
Return dof values as a formated string.