21 #include "SheafSystem/primitives_poset.h" 23 #include "SheafSystem/assert_contract.h" 24 #include "SheafSystem/array_poset_dof_map.h" 25 #include "SheafSystem/namespace_poset.impl.h" 26 #include "SheafSystem/poset_handle_factory.h" 27 #include "SheafSystem/primitive_attributes.h" 28 #include "SheafSystem/primitives_poset_dof_map.h" 29 #include "SheafSystem/primitives_poset_schema.h" 30 #include "SheafSystem/poset_type.h" 31 #include "SheafSystem/primitive_type.h" 32 #include "SheafSystem/std_iomanip.h" 33 #include "SheafSystem/total_poset_member.h" 52 static const string result(
"primitives");
56 ensure(result ==
"primitives");
73 result = result && bool_type().is_attached();
74 result = result && (bool_type().index() == BOOL);
76 result = result && char_type().is_attached() ;
77 result = result && (char_type().index() == CHAR);
79 result = result && signed_char_type().is_attached();
80 result = result && (signed_char_type().index() == SIGNED_CHAR);
82 result = result && short_int_type().is_attached();
83 result = result && (short_int_type().index() == SHORT_INT);
85 result = result &&
int_type().is_attached();
86 result = result && (
int_type().index() == INT);
88 result = result && long_int_type().is_attached();
89 result = result && (long_int_type().index() == LONG_INT);
91 result = result && long_long_int_type().is_attached();
92 result = result && (long_long_int_type().index() == LONG_LONG_INT);
94 result = result && unsigned_char_type().is_attached();
95 result = result && (unsigned_char_type().index() == UNSIGNED_CHAR);
97 result = result && unsigned_short_int_type().is_attached();
98 result = result && (unsigned_short_int_type().index() == UNSIGNED_SHORT_INT);
100 result = result && unsigned_int_type().is_attached();
101 result = result && (unsigned_int_type().index() == UNSIGNED_INT);
103 result = result && unsigned_long_int_type().is_attached();
104 result = result && (unsigned_long_int_type().index() == UNSIGNED_LONG_INT);
106 result = result && unsigned_long_long_int_type().is_attached();
107 result = result && (unsigned_long_long_int_type().index() == UNSIGNED_LONG_LONG_INT);
109 result = result && float_type().is_attached();
110 result = result && (float_type().index() == FLOAT);
112 result = result && double_type().is_attached();
113 result = result && (double_type().index() == DOUBLE);
115 result = result && long_double_type().is_attached();
116 result = result && (long_double_type().index() == LONG_DOUBLE);
118 result = result && void_star_type().is_attached();
119 result = result && (void_star_type().index() == VOID_STAR);
121 result = result && c_string_type().is_attached();
122 result = result && (c_string_type().index() == C_STRING);
124 result = result && namespace_relative_member_index_type().is_attached();
125 result = result && (namespace_relative_member_index_type().index() == NAMESPACE_RELATIVE_MEMBER_INDEX);
127 result = result && namespace_relative_subposet_index_type().is_attached();
128 result = result && (namespace_relative_subposet_index_type().index() == NAMESPACE_RELATIVE_SUBPOSET_INDEX);
141 sheaf::primitives_poset::
153 ensure(!is_attached());
158 sheaf::primitives_poset::
176 sheaf::primitives_poset::
190 string lname = primitive_attributes::name(xtype);
193 _row_dof_subposet->insert_member(&xmbr);
198 ensure(xmbr.
index() == xtype);
199 ensure(xmbr.
name() == primitive_attributes::name(xtype));
207 sheaf::primitives_poset::
241 return PRIMITIVES_POSET_ID;
252 static const char* result =
"primitives_poset";
269 require(xdof_map != 0);
279 ensure(result ? (dynamic_cast<const primitives_poset_dof_map*>(xdof_map) != 0) :
true);
291 sheaf::primitives_poset::
303 disable_invariant_check();
305 poset_state_handle::attach_to_state(xhost, xindex);
307 define_old_variable(
int old_access_request_depth = access_request_depth());
315 bool_type().attach_to_state(
this, BOOL);
316 char_type().attach_to_state(
this, CHAR);
318 signed_char_type().attach_to_state(
this, SIGNED_CHAR);
319 short_int_type().attach_to_state(
this, SHORT_INT);
320 int_type().attach_to_state(
this, INT);
321 long_int_type().attach_to_state(
this, LONG_INT);
322 long_long_int_type().attach_to_state(
this, LONG_LONG_INT);
324 unsigned_char_type().attach_to_state(
this, UNSIGNED_CHAR);
325 unsigned_short_int_type().attach_to_state(
this, UNSIGNED_SHORT_INT);
326 unsigned_int_type().attach_to_state(
this, UNSIGNED_INT);
327 unsigned_long_int_type().attach_to_state(
this, UNSIGNED_LONG_INT);
328 unsigned_long_long_int_type().attach_to_state(
this, UNSIGNED_LONG_LONG_INT);
330 float_type().attach_to_state(
this, FLOAT);
331 double_type().attach_to_state(
this, DOUBLE);
332 long_double_type().attach_to_state(
this, LONG_DOUBLE);
334 void_star_type().attach_to_state(
this, VOID_STAR);
335 c_string_type().attach_to_state(
this, C_STRING);
337 namespace_relative_member_index_type().
338 attach_to_state(
this, NAMESPACE_RELATIVE_MEMBER_INDEX);
340 namespace_relative_subposet_index_type().
341 attach_to_state(
this, NAMESPACE_RELATIVE_SUBPOSET_INDEX);
343 enable_invariant_check();
347 ensure(poset_state_handle::invariant());
348 ensure(is_attached());
349 ensure(primitive_members_attached());
350 ensure(host() == xhost);
351 ensure(index() == xindex);
357 ensure(access_request_depth() == old_access_request_depth);
363 sheaf::primitives_poset::
373 bool_type().detach_from_state();
374 char_type().detach_from_state();
376 signed_char_type().detach_from_state();
377 short_int_type().detach_from_state();
379 long_int_type().detach_from_state();
380 long_long_int_type().detach_from_state();
382 unsigned_char_type().detach_from_state();
383 unsigned_short_int_type().detach_from_state();
384 unsigned_int_type().detach_from_state();
385 unsigned_long_int_type().detach_from_state();
386 unsigned_long_long_int_type().detach_from_state();
388 float_type().detach_from_state();
389 double_type().detach_from_state();
390 long_double_type().detach_from_state();
392 void_star_type().detach_from_state();;
393 c_string_type().detach_from_state();;
395 namespace_relative_member_index_type().detach_from_state();
396 namespace_relative_subposet_index_type().detach_from_state();
400 poset_state_handle::detach_from_state();
404 ensure(!is_attached());
405 ensure(!primitive_members_attached());
413 sheaf::primitives_poset::
418 require(xschema != 0);
419 require(unexecutable(
"schema is primitives schema"));
426 disable_invariant_check();
432 _state =
new poset_state(xschema, PRIMITIVES_POSET_ID, standard_name());
436 get_read_write_access();
441 initialize_table_dofs(0,0);
445 initialize_standard_subposets(standard_name());
449 initialize_standard_members();
453 schematize(_table_dof_subposet, _row_dof_subposet,
true);
458 put_standard_subposet_ct(subposet_ct());
462 update_standard_member_id_spaces();
467 _table_dof_subposet->detach_from_state();
468 delete _table_dof_subposet;
469 _table_dof_subposet = 0;
471 _row_dof_subposet->detach_from_state();
472 delete _row_dof_subposet;
473 _row_dof_subposet = 0;
475 enable_invariant_check();
480 ensure(primitive_members_attached());
481 ensure(!in_jim_edit_mode());
483 ensure(has_standard_member_ct());
484 ensure(has_standard_row_dof_tuple_ct());
485 ensure(has_standard_subposet_ct());
491 ensure(state_is_not_read_accessible());
495 sheaf::primitives_poset::
496 initialize_standard_members()
504 poset_state_handle::initialize_standard_members();
511 begin_jim_edit_mode();
515 initialize_primitive_member(_bool_type, BOOL);
516 initialize_primitive_member(_char_type, CHAR);
518 initialize_primitive_member(_signed_char_type, SIGNED_CHAR);
519 initialize_primitive_member(_short_int_type, SHORT_INT);
520 initialize_primitive_member(_int_type, INT);
521 initialize_primitive_member(_long_int_type, LONG_INT);
522 initialize_primitive_member(_long_long_int_type, LONG_LONG_INT);
524 initialize_primitive_member(_unsigned_char_type, UNSIGNED_CHAR);
525 initialize_primitive_member(_unsigned_short_int_type, UNSIGNED_SHORT_INT);
526 initialize_primitive_member(_unsigned_int_type, UNSIGNED_INT);
527 initialize_primitive_member(_unsigned_long_int_type, UNSIGNED_LONG_INT);
528 initialize_primitive_member(_unsigned_long_long_int_type, UNSIGNED_LONG_LONG_INT);
530 initialize_primitive_member(_float_type, FLOAT);
531 initialize_primitive_member(_double_type, DOUBLE);
532 initialize_primitive_member(_long_double_type, LONG_DOUBLE);
534 initialize_primitive_member(_void_star_type, VOID_STAR);
535 initialize_primitive_member(_c_string_type, C_STRING);
537 initialize_primitive_member(_namespace_relative_member_index_type, NAMESPACE_RELATIVE_MEMBER_INDEX);
538 initialize_primitive_member(_namespace_relative_subposet_index_type, NAMESPACE_RELATIVE_SUBPOSET_INDEX);
549 put_standard_member_ct(member_ct());
550 put_standard_row_dof_tuple_ct(row_dof_tuple_ct());
554 ensure(primitive_members_attached());
555 ensure(has_standard_member_ct());
556 ensure(has_standard_row_dof_tuple_ct());
564 sheaf::primitives_poset::
565 initialize_standard_subposets(
const std::string& xname)
570 require(poset_path::is_valid_name(xname));
571 require(state_is_read_write_accessible());
577 poset_state_handle::initialize_standard_subposets(xname);
582 _table_dof_subposet =
new subposet(
this);
583 _row_dof_subposet =
new subposet(
this);
585 put_standard_subposet_ct(subposet_ct());
592 ensure(has_standard_subposet_ct());
635 if(invariant_check())
637 result = result && poset_state_handle::invariant();
639 disable_invariant_check();
643 result = result && primitive_members_attached();
647 enable_invariant_check();
663 sheaf::primitives_poset::
677 ensure(is_same_type(result));
A client handle for a subposet.
virtual void new_jim_state(poset_dof_map *xdof_map=0, bool xcopy_dof_map=false, bool xauto_access=true)
Creates a new jim (join-irreducible member) state in host() and attaches this to it. If xdof_map == 0 a new dof map is created. If xdof_map != 0 and xcopy_dof_map == false, xdof_map is used as the dof map. If xdof_map != 0 and xcopy_dof_map is true, a copy of xdof_map is used.
The private state of a partially ordered set.
virtual bool is_ancestor_of(const any *other) const
True if other conforms to this.
The default name space; a poset which contains other posets as members.
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
poset_type
Identifiers for poset types.
static const std::string & standard_name()
The standard name for an instance of this class.
const scoped_index & index() const
The index of the component state this handle is attached to.
std::string name() const
A name for this.
The general, abstract map from dof ids to dof values.
The poset containing the primitive type definitions.
Abstract base class with useful features for all objects.
bool invariant() const
Class invariant.
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...
A factory for instanting descendants of an abstract type T, given the class name of the descendant...
primitive_type
Type ids for sheaf primitives.
A map from schema poset member ids to dof values for primitives_poset members.
virtual bool is_attached() const
True if this handle is attached to a non-void state.
bool primitive_members_attached() const
True if the primitive members are all attached.
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. ...
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.
int_type pod_index_type
The plain old data index type.
virtual poset_type type_id() const
Identifier for the type of this poset.
void insert_prototype(T *xprototype)
Sets xprototype as the prototype for its client class.
virtual const char * class_name() const
The name of this class.
An abstract client handle for a member of a poset.
int int_type
The preferred integer type.
A client handle for an unrestricted member of a poset. A total_poset_member is guaranteed not to be r...