21 #include "SheafSystem/poset_component.h" 23 #include "SheafSystem/assert_contract.h" 24 #include "SheafSystem/namespace_poset.h" 25 #include "SheafSystem/poset.h" 26 #include "SheafSystem/poset_state.h" 27 #include "SheafSystem/poset_crg_state.h" 28 #include "SheafSystem/pool.h" 29 #include "SheafSystem/std_typeinfo.h" 68 _version = NOT_A_STANDARD_VERSION_INDEX;
73 ensure(!is_attached());
90 result = _host != 0 ? _host->state_obj() : 0;
96 ensure(_host == 0 ? result == 0 :
true);
107 return state_obj()->powerset();
114 return state_obj()->crg();
127 require(state_is_read_accessible());
131 result = &(_host->powerset().member(xindex));
150 require(state_is_read_accessible());
154 result = state_obj()->table()->row_dof_tuple(xindex);
169 require(state_is_read_accessible());
180 ensure(unexecutable(data members created but not attached));
193 require(state_is_read_accessible());
194 require(unexecutable(data members created));
205 ensure(unexecutable(data members attached()));
229 define_old_variable(
const scoped_index& result = _index);
233 ensure(result.is_hub_scope() || !result.is_valid());
234 ensure(result.is_positive() || !result.is_valid());
251 require(host_is_ancestor_of(xhost));
274 require(host_is_ancestor_of(xhost));
278 return is_valid_index(xhost, xid.
hub_pod(), xversion);
287 require(state_is_read_accessible());
308 require(state_is_read_accessible());
331 require(state_is_read_accessible());
342 ensure(result.
pod() == xid);
356 require(host_is_ancestor_of(xhost));
358 require(!xname.empty());
381 require(host_is_ancestor_of(xhost));
383 require(!xname.empty());
404 require(xunalias ? state_is_read_accessible() :
true);
408 result = xunalias ? unaliased_version(_version) : _version;
412 ensure(result != CURRENT_MEMBER_VERSION);
413 ensure(xunalias ? (result != CURRENT_HOST_VERSION) :
true);
426 require(xunalias ? state_is_read_accessible() :
true);
427 require(has_version(xversion));
428 require(!xunalias ? xversion != CURRENT_MEMBER_VERSION :
true);
432 _version = xunalias ? unaliased_version(xversion) : xversion;
437 version(
false) == unaliased_version(xversion) :
438 version(
false) == xversion);
455 if(xversion == CURRENT_HOST_VERSION)
457 result = host()->version();
459 else if(xversion == CURRENT_MEMBER_VERSION)
462 if(result == CURRENT_HOST_VERSION)
464 result = host()->version();
475 ensure(result != CURRENT_HOST_VERSION);
476 ensure(result != CURRENT_MEMBER_VERSION);
489 require(state_is_read_accessible());
497 ensure(host()->includes_subposet(result));
510 require(state_is_read_accessible());
514 host()->version_index(version(
true), result);
518 ensure(host()->includes_subposet(result));
533 require(state_is_read_accessible());
537 result = host()->version_to_name(version(
true));
541 ensure(host()->includes_subposet(result));
558 result = ((xversion == CURRENT_MEMBER_VERSION) ||
559 (xversion == CURRENT_HOST_VERSION) ||
560 host()->has_version(xversion));
564 ensure( result == ( (xversion == CURRENT_MEMBER_VERSION) ||
565 (xversion == CURRENT_HOST_VERSION) ||
566 host()->has_version(xversion)));
592 require(state_is_read_accessible());
598 ensure(unexecutable(result.empty() implies
this has no name));
613 require(xauto_access || state_is_read_accessible());
621 ensure(unexecutable(result.empty() implies
this has no name));
634 require(xauto_access || state_is_read_accessible());
642 ensure(xresult.
ct() == name_ct(xauto_access));
643 ensure_for_all(i, 0, xresult.
ct(), !xresult[i].empty());
656 require(xauto_access || state_is_read_accessible());
673 has_name(
const std::string& xname,
bool xauto_access)
const 677 require(xauto_access || state_is_read_accessible());
678 require(!xname.empty());
695 put_name(
const std::string& xname,
bool xunique,
bool xauto_access)
699 require(is_attached());
700 require(xauto_access || state_is_read_write_accessible());
701 require(poset_path::is_valid_name(xname));
710 ensure(xunique ? (name(xauto_access) == xname) : has_name(xname, xauto_access));
723 require(xauto_access || state_is_read_write_accessible());
724 require(!xname.empty());
732 ensure(!has_name(xname, xauto_access));
745 require(xauto_access || state_is_read_write_accessible());
753 ensure(name_ct(xauto_access) == 0);
770 require(!xname.empty());
774 result =
is_valid(get_index_from_name(xhost, xname));
778 ensure(unexecutable(xhost has a component of the same type as
this with name xname));
792 require(is_attached());
793 require(xauto_access || state_is_read_accessible());
800 require(!name().empty());
808 ensure(result.
poset_name() == host()->name());
829 require(state_is_auto_read_accessible(xauto_access));
920 else if(is_attached())
978 require(xother != 0);
1008 result = host()->host()->is_same_state(xother->
host()->
host());
1013 result = (!is_attached()) && (!xother->
is_attached());
1018 ensure(unexecutable(
true if hosts of
this and xother are in same
namespace or
if this and xother both unattached));
1038 result = host()->host()->is_same_state(xother->
host());
1043 result = (!is_attached()) && (!xother->
is_attached());
1048 ensure(unexecutable(
"true if hosts of this and xother are in same namespace or if this and xother both unattached"));
1072 require(xhost != 0);
1073 require(host_is_ancestor_of(xhost));
1075 require(is_valid_index(xhost, xhub_id));
1102 init_handle_data_members();
1106 _version = CURRENT_HOST_VERSION;
1111 attach_to_state(xhub_id);
1115 ensure(is_attached());
1116 ensure(host()->is_same_state(xhost));
1117 ensure(index().is_hub_scope());
1118 ensure(index() == xhub_id);
1119 ensure(version() == xhost->
version());
1120 ensure(postcondition_of(attach_handle_data_members()));
1133 require(xhost != 0);
1134 require(host_is_ancestor_of(xhost));
1136 require(is_valid_index(xhost, xid));
1140 attach_to_state(xhost, xid.
hub_pod());
1144 ensure(is_attached());
1145 ensure(host()->is_same_state(xhost));
1146 ensure(index().is_hub_scope());
1147 ensure(index() ==~ xid);
1148 ensure(version() == xhost->
version());
1149 ensure(postcondition_of(attach_handle_data_members()));
1162 require(xhost != 0);
1163 require(host_is_ancestor_of(xhost));
1165 require(is_valid_name(xhost, xname));
1171 attach_to_state(xhost, lindex);
1175 ensure(is_attached());
1176 ensure(host() == xhost);
1177 ensure(has_name(xname));
1178 ensure(postcondition_of(attach_handle_data_members()));
1187 require(state_is_read_accessible());
1188 require(!xname.empty());
1189 require(is_valid_name(host(), xname));
1190 require(precondition_of(attach_to_state(get_index_from_name(host(), xname))));
1194 attach_to_state(get_index_from_name(host(), xname));
1198 ensure(postcondition_of(attach_to_state(get_index_from_name(host(), xname))));
1211 require(state_is_read_accessible());
1212 require(is_valid_index(host(), xhub_id, version(
false)));
1217 define_old_variable(
int old_version = _version);
1227 attach_handle_data_members();
1231 ensure(is_attached());
1232 ensure(host() == old_host);
1233 ensure(index().is_hub_scope());
1234 ensure(index() == xhub_id);
1235 ensure(version(
false) == old_version);
1236 ensure(postcondition_of(attach_handle_data_members()));
1245 require(state_is_read_accessible());
1246 require(is_valid_index(host(), xid, version(
false)));
1251 define_old_variable(
int old_version = _version);
1253 attach_to_state(xid.
hub_pod());
1257 ensure(is_attached());
1258 ensure(host() == old_host);
1259 ensure(index().is_hub_scope());
1260 ensure(index() ==~ xid);
1261 ensure(version(
false) == old_version);
1262 ensure(postcondition_of(attach_handle_data_members()));
1271 require(xother != 0);
1289 if(!_host->is_same_state(xother->
host()))
1294 _host = xother->
host();
1295 init_handle_data_members();
1298 _index = xother->
index();
1305 attach_handle_data_members();
1312 detach_from_state();
1321 _host = xother->
host();
1322 _index = xother->
index();
1329 init_handle_data_members();
1330 attach_handle_data_members();
1336 ensure(is_same_state(xother));
1338 ensure(version(
false) == xother->
version(
false));
1353 require(xother != 0);
1365 attach_to_state(xother);
1374 ensure(postcondition_of(attach_to_state(xother)));
1392 _index.invalidate();
1394 _version = NOT_A_STANDARD_VERSION_INDEX;
1402 ensure(poset_component::invariant());
1403 ensure(!is_attached());
1417 result = (_host != 0) && (_index.is_positive());
1421 ensure(result == ((host() != 0) && (index().is_positive())));
1436 require(xhost != 0 ? host_is_ancestor_of(xhost) :
true);
1448 result = ( (xhost != 0) && (xhost->
state_obj() == state_obj()) && (index() == xhub_id) );
1465 require(xhost != 0 ? host_is_ancestor_of(xhost) :
true);
1469 return is_same_state(xhost, xid.
hub_pod());
1490 result = result && (xother != 0);
1491 result = result && (xother->
state_obj() == state_obj());
1492 result = result && (xother->
index() == index());
1523 require(is_attached());
1527 int old_access_request_depth = host()->access_request_depth();
1529 host()->get_read_access();
1533 ensure(state_is_read_accessible());
1534 ensure(access_request_depth() == old_access_request_depth + 1);
1543 require(is_attached());
1544 require(!xrelease_read_only_access ? state_is_not_read_only_accessible() :
true);
1549 int old_access_request_depth = host()->access_request_depth();
1551 host()->get_read_write_access(xrelease_read_only_access);
1555 ensure(state_is_read_write_accessible());
1556 ensure(access_request_depth() == old_access_request_depth + 1);
1565 require(state_is_read_accessible());
1569 int old_access_request_depth = host()->access_request_depth();
1571 host()->release_access(xall);
1576 access_request_depth() == 0 :
1577 access_request_depth() == old_access_request_depth - 1);
1578 ensure(access_request_depth() == 0 ? state_is_not_read_accessible() :
true);
1623 result = result && read_write_monitor_handle::invariant();
1625 if(invariant_check())
1629 disable_invariant_check();
1633 result = result && ((_host == 0) ? (!_index.is_valid()) : (_index.is_hub_scope()));
1635 result = result && (_version != CURRENT_MEMBER_VERSION);
1639 enable_invariant_check();
1668 result = xinclude_shallow ?
sizeof(xp) : 0;
1672 ensure(result >= 0);
virtual void put_version(int xversion, bool xunalias=false)
Sets version to (possibly aliased) xversion. If unalias == true, set version to the actual version al...
virtual pod_index_type get_index_from_name(const poset_state_handle *xhost, const std::string &xname) const =0
Gets the index of the component in xhost with name xname.
poset_state_handle * host() const
The poset which this is a handle to a component of.
poset_component()
Default constructor.
bool has_path(const poset_path &xpath, bool xauto_access) const
True if and only if xpath refers to this component.
virtual ~poset_component()
Destructor.
int unaliased_version(int xversion) const
The actual version associated with (possibly aliased) version xversion in this.
The data structure representing the cover relation graph of a poset.
poset_dof_map * row_dof_tuple(const scoped_index &xindex) const
The row dof tuple associated with xindex.
int version(bool xunalias=true) const
The (possibly aliased) version of this component. The version of the host used when evaluating proper...
size_type ct() const
The number of items currently in use.
poset_crg_state * crg() const
The cover relation graph of host().
The private state of a partially ordered set.
const pod_type & pod() const
The "plain old data" storage of this; the value in the external id space.
virtual bool has_name(const std::string &xname, bool xauto_access=false) const =0
True if xname is a name for this.
virtual poset_state * state_obj() const
State object for this poset.
pod_index_type version_index() const
The subposet index for the filter associated with version().
poset_path path(bool xauto_access=true) const
A path to this component.
The default name space; a poset which contains other posets as members.
virtual subposet_state * powerset_member(const scoped_index &xindex) const
The hidden state of the subposet asocciated with index xindex.
virtual void delete_name(const std::string &xname, bool xauto_access=false)=0
Delete all names for this.
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 bool is_ancestor_of(const any *other) const
True if other conforms to current.
The data structure representing the state of a subposet.
virtual void all_names(block< std::string > &xresult, bool xauto_access=false) const =0
All the names for this.
A client handle for a general, abstract partially order set.
A path defined by a poset name and a member name separated by a forward slash ('/'). For example: "cell_definitions/triangle".
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.
virtual int version() const
The current version.
virtual void get_read_access() const
Get read access to the state associated with this.
virtual void put_name(const std::string &xname, bool xunique, bool xauto_access)=0
Make xname a name for this; if xunique, make xname the only name.
virtual namespace_poset * name_space() const
The namespace of host()
Features shared by poset_member and subposet. Subposet and poset_member objects can be attached...
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.
namespace_poset * host() const
The namespace this poset resides in. Obsolete; use name_space() instead.
An implementation of class sum_index_space_handle that has a primary sum id space state...
void attach_to_state(const poset_state_handle *xhost, pod_index_type xhub_id)
Attach this handle to the state with hub id xhub_id in the current version of host xhost...
bool is_hub_scope() const
True if and only if the id space of this is the hub id space.
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 const scoped_index & hub_id() const =0
A id in the hub id space for components of this type; intended for copying to initialize ids to the h...
Abstract base class with useful features for all objects.
virtual void attach_handle_data_members()
Initializes handle data members when attaching to a different member of the same host; intended to be...
bool has_same_host(const poset_component *xother) const
True if xother is attached to the same host as this or if both are unattached.
virtual bool host_is_ancestor_of(const poset_state_handle *xther) const
True if xother conforms to host.
An index within the external ("client") scope of a given id space.
virtual const hub_index_space_handle & hub_id_space() const =0
The hub id space; const version.
virtual bool is_attached() const
True if this handle is attached to a non-void state.
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.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
std::string poset_name() const
The poset name part of the path.
virtual size_type name_ct(bool xauto_access) const =0
The number of names for this.
int _version
The version of this component. The version of the host used when evaluating properties of this compon...
bool same_namespace(const poset_component *xother) const
True if the host of xother resides in the same namespace as this or if both are unattached.
virtual void detach_from_state()
Detach this handle from its state, if any.
namespace_poset * name_space() const
The namespace this poset resides in.
virtual bool is_attached() const
True if this is attached to a state.
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...
poset_powerset_state * powerset() const
The set of subposets of host().
int_type pod_index_type
The plain old data index type.
std::string name() const
OBSOLETE: use name(bool xauto_access). A name for this.
std::string member_name() const
The member name part of the path.
virtual void delete_all_names(bool xauto_access=false)=0
Delete all the names for this.
virtual bool is_valid_index(const poset_state_handle *xhost, pod_index_type xhub_id, int xversion=CURRENT_HOST_VERSION) const =0
True if there exists a component of the same type as this with hub id xhub_id in version xversion of ...
bool is_same_state(const poset_state_handle *xother) const
True if this is attached to the same state as xother.
poset_state * state_obj() const
The state this component handle is attached to.
virtual bool invariant() const
Class invariant.
virtual void init_handle_data_members()
Initializes handle data members when attaching to a different member in a different host; intended to...
bool is_valid_name(const poset_state_handle *xhost, const std::string &xname) const
True if there exists a component as the same type as this in xhost with name xname.
SHEAF_DLL_SPEC bool is_valid(pod_index_type xpod_index)
True if an only if xpod_index is valid.
std::string version_name() const
The subposet name for the filter associated with version().
The set of subsets of a poset.
bool has_version(int xversion) const
True if xversion is a valid version for this.
virtual bool namespace_is_ancestor_of(const namespace_poset *xother) const
True if xother conforms to name_space().
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.