22 #include "SheafSystem/poset_dof_iterator.h" 24 #include "SheafSystem/assert_contract.h" 25 #include "SheafSystem/poset_state_handle.h" 26 #include "SheafSystem/schema_poset_member.h" 41 _is_table_dof =
false;
46 ensure(!is_initialized());
60 require(is_ancestor_of(&xother));
83 ensure(is_initialized() ? anchor().is_same_state(&xother.
anchor()) :
true);
84 ensure(is_initialized() ? anchor().version() == xother.
anchor().
version() :
true);
85 ensure(is_initialized() ? item().is_same_type(&xother.
item()) :
true);
101 require(is_ancestor_of(&xother));
110 _item->detach_from_state();
114 _anchor->detach_from_state();
119 if(lother._anchor != 0)
123 _anchor = lother._anchor->
clone();
128 _is_table_dof = lother._is_table_dof;
134 ensure(is_initialized() ? anchor().is_same_state(&xother.
anchor()) :
true);
135 ensure(is_initialized() ? anchor().version() == xother.
anchor().
version() :
true);
136 ensure(is_initialized() ? item().is_same_type(&xother.
item()) :
true);
155 _anchor->detach_from_state();
161 _item->detach_from_state();
225 invariance( any::invariant() );
227 if(invariant_check())
229 disable_invariant_check();
231 invariance( is_initialized() == (_anchor != 0) );
232 invariance( is_initialized() == (_item != 0) );
233 invariance( is_initialized() == (_itr.is_initialized()) );
237 enable_invariant_check();
255 require(item_is_ancestor_of(xanchor));
266 _is_table_dof = xis_table_dof;
267 put_anchor(&xanchor, xversion);
273 ensure(is_initialized());
274 ensure(anchor().is_same_state(&xanchor));
275 ensure(anchor().is_same_type(&xanchor));
276 ensure(unexecutable(postorder - have visited all children of
this));
277 ensure(unexecutable(!is_done() implies
this is first member));
278 ensure(item().is_attached() == !is_done());
279 ensure(is_table_dof() == xis_table_dof);
302 result = (_anchor != 0);
303 result = result && (_item != 0);
304 result = result && _itr.is_initialized();
321 require(is_initialized());
342 require(is_initialized());
363 require(xanchor != 0);
364 require(item_is_ancestor_of(*xanchor));
376 _anchor = xanchor->
clone();
386 _anchor->put_version(xversion,
true);
390 string ldof_sp_name = schema_poset_member::dof_subposet_name(
"top", _is_table_dof);
391 _itr.put_anchor(_anchor);
392 _itr.put_filter(ldof_sp_name);
405 ensure(is_initialized());
407 ensure(anchor().is_same_state(xanchor));
408 ensure(anchor().is_same_type(xanchor));
421 require(is_initialized());
422 require(anchor().host()->contains_member(xhub_id));
426 define_old_variable(
int old_anchor_version = anchor().version());
430 _anchor->attach_to_state(xhub_id);
434 _itr.put_anchor(xhub_id);
447 ensure(is_initialized());
449 ensure(anchor().index() == xhub_id);
450 ensure(anchor().version() == old_anchor_version);
462 require(is_initialized());
463 require(anchor().host()->contains_member(xid));
467 define_old_variable(
int old_anchor_version = anchor().version());
474 ensure(is_initialized());
476 ensure(anchor().index() ==~ xid);
477 ensure(anchor().version() == old_anchor_version);
491 require(is_initialized());
495 result = _itr.is_done();
510 require(is_initialized());
514 _itr.force_is_done();
515 _item->detach_from_state();
532 require(is_initialized());
543 ensure(!is_done() == item().is_attached());
544 ensure(unexecutable(postorder - have visited all of the members of the strict down
set 558 require(is_initialized());
559 require(anchor().state_is_read_accessible());
563 define_old_variable(
int old_anchor_version = anchor().version());
565 _itr.reset(xreset_markers);
571 ensure(is_initialized());
572 ensure(item().is_attached() == !is_done());
573 ensure(anchor().version() == old_anchor_version);
588 require(is_initialized());
589 require(xreset ? anchor().state_is_read_accessible():
true);
593 result = _itr.ct(xreset);
614 require(is_initialized());
615 require(anchor().state_is_read_accessible());
616 require(anchor().host()->contains_member(xhub_id));
620 result = _itr.has_visited(xhub_id);
638 require(is_initialized());
639 require(anchor().state_is_read_accessible());
640 require(anchor().host()->contains_member(xid));
644 return has_visited(xid.
hub_pod());
655 require(is_initialized());
656 require(anchor().state_is_read_accessible());
657 require(item_is_ancestor_of(xmbr));
659 require(anchor().host()->is_same_state(xmbr.
host()));
663 result = _itr.has_visited(&xmbr);
680 require(is_initialized());
681 require(anchor().state_is_read_accessible());
682 require(anchor().host()->contains_member(xhub_id));
686 _itr.put_has_visited(xhub_id, xvalue);
690 ensure(has_visited(xhub_id) == xvalue);
704 require(is_initialized());
705 require(anchor().state_is_read_accessible());
706 require(anchor().host()->contains_member(xid));
710 put_has_visited(xid.
hub_pod(), xvalue);
714 ensure(has_visited(xid) == xvalue);
729 require(is_initialized());
750 require(is_initialized());
795 require(is_initialized());
799 define_old_variable(
scoped_index result(_item->index()));
803 ensure(result == item().index());
807 return _item->index();
820 result = _is_table_dof;
852 ensure(item().is_attached() == !is_done());
865 require(is_initialized());
871 _item->detach_from_state();
875 _item->attach_to_state(_itr.anchor().host(), _itr.index());
880 ensure(item().is_attached() == !is_done());
virtual void force_is_done()
Force the iterator to be done.
poset_state_handle * host() const
The poset which this is a handle to a component of.
virtual poset_dof_iterator * clone() const
Make a new instance of the same type as this.
int unaliased_version(int xversion) const
The actual version associated with (possibly aliased) version xversion in this.
int version(bool xunalias=true) const
The (possibly aliased) version of this component. The version of the host used when evaluating proper...
virtual void update_item()
Attaches the item handle to the current index, or detaches the item handle if is_done.
virtual void next()
Makes this the next member of the subset.
virtual void reset(bool xreset_markers=RESET)
Restarts the iteration over the down set of anchor() If xreset_markers, set !has_visited for all memb...
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 void reset_item()
Creates item if needed and attaches it to the current index.
virtual bool is_done() const
True if iteration finished.
virtual void put_has_visited(pod_index_type xhub_id, bool xvalue)
Set the visisted marker for hub id xhub_id to xvalue. Intended for use reseting iterator without havi...
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...
Abstract base class with useful features for all objects.
poset_dof_iterator()
Default constructor; creates an unattached iterator, with and all-pass filter.
An index within the external ("client") scope of a given id space.
virtual bool is_attached() const
True if this handle is attached to a non-void state.
virtual ~poset_dof_iterator()
Destructor.
virtual bool is_initialized() const
True if this has been initialized for iteration with respect to a specific anchor.
virtual bool invariant() const
The class invariant.
virtual const scoped_index & index()
The index of the current member of the iteration.
virtual bool is_ancestor_of(const any *other) const
True if other conforms to this.
virtual bool has_visited(pod_index_type xhub_id) const
True if this has already visited hub id xhub_id.
bool is_table_dof() const
True if iterating over table dofs.
schema_poset_member & anchor()
The schema member whose downset is being iterated over; the top member of the domain of iteration (mu...
virtual bool is_schematized(bool xauto_access) const
True if this poset has been prepared for use as a schema, that is, if the top member has been schemat...
Iterates in postorder over dofs of a schema member anchor. Attaches a handle of type schema_poset_mem...
postorder_iterator _itr
The index iterator used to implement the iteration.
bool _is_table_dof
True if iterating over table dofs.
schema_poset_member * _anchor
The schema member whose downset is being iterated over; the top member of the domain of iteration...
int_type pod_index_type
The plain old data index type.
virtual poset_dof_iterator & operator=(const poset_dof_iterator &xother)
Assignment operator.
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.
virtual int ct(bool xreset=false)
The number of members of the iteration set, from the current member to the end, inclusive. If xreset, reset before computing the count.
virtual bool item_is_ancestor_of(const schema_poset_member &xmbr) const
True if xmbr conforms to the type of item of this.
schema_poset_member * _item
The member handle for the current item in the iteration.
A client handle for a poset member which has been prepared for use as a schema.
virtual void put_anchor(const schema_poset_member *xanchor, int xversion)
Set anchor() to xversion of *xanchor. Forces reset of markers, since the host may be different...
bool has_version(int xversion) const
True if xversion is a valid version for this.
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.