21 #include "SheafSystem/primitives_poset_schema.h" 23 #include "SheafSystem/assert_contract.h" 24 #include "SheafSystem/array_index_space_state.h" 25 #include "SheafSystem/array_poset_dof_map.h" 26 #include "SheafSystem/namespace_poset.impl.h" 27 #include "SheafSystem/namespace_poset_member.h" 28 #include "SheafSystem/poset_handle_factory.h" 29 #include "SheafSystem/primitives_poset_dof_map.h" 30 #include "SheafSystem/poset_type.h" 31 #include "SheafSystem/primitives_index_space_handle.h" 32 #include "SheafSystem/primitives_index_space_state.h" 33 #include "SheafSystem/std_iomanip.h" 34 #include "SheafSystem/std_iostream.h" 35 #include "SheafSystem/total_poset_member.h" 53 static const string result(
"primitives_schema");
57 ensure(result ==
"primitives_schema");
68 sheaf::primitives_poset_schema::
69 primitives_poset_schema()
80 ensure(!is_attached());
85 sheaf::primitives_poset_schema::
86 ~primitives_poset_schema()
101 sheaf::primitives_poset_schema::
108 poset_type ltype = PRIMITIVES_POSET_SCHEMA_ID;
133 return PRIMITIVES_POSET_SCHEMA_ID;
144 static const char* result =
"primitives_poset_schema";
161 require(xdof_map != 0);
171 ensure(result ? (dynamic_cast<const primitives_poset_dof_map*>(xdof_map) != 0) :
true);
184 require(is_attached());
188 int old_access_request_depth = access_request_depth();
190 read_write_monitor_handle::get_read_access();
194 ensure(state_is_read_accessible());
195 ensure(access_request_depth() == old_access_request_depth + 1);
208 require(is_attached());
209 require(!xrelease_read_only_access ? state_is_not_read_only_accessible() :
true);
214 int old_access_request_depth = access_request_depth();
216 read_write_monitor_handle::get_read_write_access(xrelease_read_only_access);
220 ensure(state_is_read_write_accessible());
221 ensure(access_request_depth() == old_access_request_depth + 1);
234 require(state_is_read_accessible());
238 int old_access_request_depth = access_request_depth();
244 read_write_monitor_handle::release_access(xall);
248 ensure(!xall ? access_request_depth() == old_access_request_depth - 1 :
249 access_request_depth() == 0);
250 ensure(access_request_depth() == 0 ? state_is_not_read_accessible() :
true);
279 poset_state_handle::initialize_standard_members();
286 begin_jim_edit_mode();
294 lmbr_id = new_member(
true, ldof_map,
false);
295 put_member_name(lmbr_id,
"size",
true,
false);
296 _row_dof_subposet->insert_member(lmbr_id);
301 lmbr_id = new_member(
true, ldof_map,
false);
302 put_member_name(lmbr_id,
"alignment",
true,
false);
303 _row_dof_subposet->insert_member(lmbr_id);
308 lmbr_id = new_member(
true, ldof_map,
false);
309 put_member_name(lmbr_id,
"type_id",
true,
false);
310 _row_dof_subposet->insert_member(lmbr_id);
321 put_standard_member_ct(member_ct());
322 put_standard_row_dof_tuple_ct(row_dof_tuple_ct());
326 ensure(has_standard_member_ct());
327 ensure(has_standard_row_dof_tuple_ct());
341 require(poset_path::is_valid_name(xname));
342 require(state_is_read_write_accessible());
348 poset_state_handle::initialize_standard_subposets(xname);
353 _table_dof_subposet =
new subposet(
this);
354 _row_dof_subposet =
new subposet(
this);
356 put_standard_subposet_ct(subposet_ct());
363 ensure(has_standard_subposet_ct());
378 require(state_is_read_write_accessible());
379 require(xtable_dof_subposet != 0);
380 require(includes_subposet(xtable_dof_subposet));
381 require(xrow_dof_subposet != 0);
382 require(includes_subposet(xrow_dof_subposet));
391 xtable_dof_subposet->
put_name(schema_poset_member::table_dof_subposet_name(
"top"),
true,
false);
395 xtable_dof_subposet->
new_id_space(
"array_index_space_state");
408 ltable_dof_descriptors[0].
size = 0;
409 ltable_dof_descriptors[0].alignment = 0;
410 ltable_dof_descriptors[0].type = NOT_A_PRIMITIVE_TYPE;
411 ltable_dof_descriptors[0].offset = 0;
419 xrow_dof_subposet->
put_name(schema_poset_member::row_dof_subposet_name(
"top"),
true,
false);
423 string lname = xrow_dof_subposet->
name();
425 primitives_index_space_state::new_space(member_id_spaces(
false), lname);
445 lrow_dof_descriptors[0].
size = size_t_desc.size;
446 lrow_dof_descriptors[0].alignment = size_t_desc.alignment;
447 lrow_dof_descriptors[0].type = size_t_desc.index;
448 lrow_dof_descriptors[0].offset = 0;
449 size_t loffset = size_t_desc.size;
453 lrow_dof_descriptors[1].
size = size_t_desc.size;
454 lrow_dof_descriptors[1].alignment = size_t_desc.alignment;
455 lrow_dof_descriptors[1].type = size_t_desc.index;
456 loffset =
align(loffset, size_t_desc.alignment);
457 lrow_dof_descriptors[1].offset = loffset;
458 loffset += size_t_desc.size;
464 lrow_dof_descriptors[2].
size = int_desc.size;
465 lrow_dof_descriptors[2].alignment = int_desc.alignment;
466 lrow_dof_descriptors[2].type = int_desc.index;
467 loffset =
align(loffset, int_desc.alignment);
468 lrow_dof_descriptors[2].offset = loffset;
469 loffset += int_desc.size;
473 lrow_dof_descriptors[3].
size = 0;
474 lrow_dof_descriptors[3].alignment = 0;
475 lrow_dof_descriptors[3].type = NOT_A_PRIMITIVE_TYPE;
476 lrow_dof_descriptors[3].offset = loffset;
482 ensure(is_schematized(
false));
495 require(state_is_read_write_accessible());
508 ensure(!is_attached());
509 ensure(unexecutable(state has been deleted));
519 sheaf::primitives_poset_schema::
529 disable_invariant_check();
535 _state =
new poset_state(0, PRIMITIVES_POSET_SCHEMA_ID, standard_name());
539 get_read_write_access();
545 initialize_standard_subposets(standard_name());
549 initialize_standard_members();
554 schematize(_table_dof_subposet, _row_dof_subposet);
559 put_standard_subposet_ct(subposet_ct());
563 update_standard_member_id_spaces();
568 _table_dof_subposet->detach_from_state();
569 delete _table_dof_subposet;
570 _table_dof_subposet = 0;
572 _row_dof_subposet->detach_from_state();
573 delete _row_dof_subposet;
574 _row_dof_subposet = 0;
585 schema().attach_to_state(&(top()));
591 initialize_table_dofs(0,0);
595 enable_invariant_check();
600 ensure(!in_jim_edit_mode());
601 ensure(has_standard_member_ct());
602 ensure(has_standard_row_dof_tuple_ct());
603 ensure(has_standard_subposet_ct());
609 ensure(state_is_not_read_accessible());
649 result = result && poset_state_handle::invariant();
651 if(invariant_check())
653 disable_invariant_check();
660 enable_invariant_check();
675 sheaf::primitives_poset_schema::
A client handle for a subposet.
The private state of a partially ordered set.
const int PRIMITIVES_SCHEMA_DOF_CT
Number of dofs defined by primitives schema.
virtual void get_read_access() const
Get read access to the state associated with this.
virtual bool is_ancestor_of(const any *other) const
True if other conforms to this.
poset_type
Identifiers for poset types.
size_type size() const
The number of bytes in the dof tuple described by this.
bool invariant() const
Class invariant.
virtual void get_read_write_access(bool xrelease_read_only_access=false)
Get read write access to the state associated with this. If release_read_only_access is requested...
The general, abstract map from dof ids to dof values.
virtual void initialize_standard_members()
Initializes the predefined members of the poset.
virtual void terminate_access()
Release all access to posets this depends on, then detach and delete the state.
Abstract base class with useful features for all objects.
virtual void put_name(const std::string &xname, bool xunique, bool xauto_access)
Make xname a name for this; if xunique, make xname the only name.
A factory for instanting descendants of an abstract type T, given the class name of the descendant...
A map from schema poset member ids to dof values for primitives_poset members.
virtual scattered_insertion_index_space_handle & new_id_space(const std::string &xstate_class_name)
Creates an id space for the members of this.
virtual const char * class_name() const
The name of this class.
The schema poset for the primitives.
virtual void release_access(bool xall=false) const
Release access. If xall is true, release all levels of access. Otherwise, release one level of access...
virtual void put_dof_ct(int xct)
Set the number of dofs defined this, considered as a dof_subposet, to xct; Note: dof_ct() == member_c...
virtual poset_type type_id() const
Identifier for the type of this poset.
An array for storing structs which describe the size, alignment, and offset of dofs within a dof tupl...
virtual void initialize_standard_subposets(const std::string &xname)
Creates the subposets common to every poset (i.e._whole and _jims) plus those required of a schema po...
virtual void put_dof_descriptors(const dof_descriptor_array *xoffsets)
Set the offset from beginning of the dof tuple of each dof to xoffsets.
virtual void schematize(subposet *xtable_dof_subposet, subposet *xrow_dof_subposet, bool xall_members=true)
Prepare this for use as a schema All members will be schematized; argument xall_members is ignored...
virtual bool row_dof_map_conforms(const poset_dof_map *xdof_map) const
True if xdof_map conforms to (i.e. is derived from) the type of row dof map required by this poset...
virtual void put_is_dof_subposet(bool xis_dof_subposet)
True if this is a dofs subposet.
virtual bool is_attached() const
True if this is attached to a state.
int_type pod_index_type
The plain old data index type.
size_t align(const size_t xoffset, const size_t xalignment)
Smallest offset greater than or equal to xoffset that has alignment xalignment.
static const std::string & standard_name()
The standard name for an instance of this class.
void insert_prototype(T *xprototype)
Sets xprototype as the prototype for its client class.
virtual pod_index_type prereq_id(int xi) const
The id of the xi-th prerequisite poset for this.
SHEAF_DLL_SPEC pod_index_type invalid_pod_index()
The invalid pod index value.