20 #include "SheafSystem/section_component_iterator.h" 22 #include "SheafSystem/poset_state_handle.h" 23 #include "SheafSystem/assert_contract.h" 24 #include "SheafSystem/section_space_schema_member.h" 25 #include "SheafSystem/section_space_schema_poset.h" 45 ensure(!is_initialized());
59 require(is_ancestor_of(&xother));
81 ensure(is_initialized() ? anchor().is_same_state(&xother.
anchor()) :
true);
82 ensure(is_initialized() ? item().is_same_type(&xother.
item()) :
true);
83 ensure(unexecutable(
this is first member of iteration or is_done()));
98 require(is_ancestor_of(&xother));
106 _item->detach_from_state();
110 _anchor->detach_from_state();
129 ensure(is_initialized() ? anchor().is_same_state(&xother.
anchor()) :
true);
130 ensure(is_initialized() ? item().is_same_type(&xother.
item()) :
true);
131 ensure(unexecutable(
this is first member of iteration or is_done()));
149 _anchor->detach_from_state();
155 _item->detach_from_state();
198 result = result && any::invariant();
200 if(invariant_check())
202 disable_invariant_check();
204 result = result && ( is_initialized() == (_anchor != 0) );
205 result = result && ( is_initialized() == (_item != 0) );
206 result = result && ( is_initialized() == (_itr.is_initialized()) );
210 enable_invariant_check();
228 require(item_is_ancestor_of(xanchor));
238 put_anchor(&xanchor);
244 ensure(is_initialized());
245 ensure(anchor().is_same_state(&xanchor));
246 ensure(anchor().is_same_type(&xanchor));
247 ensure(unexecutable(postorder - have visited all children of
this));
248 ensure(unexecutable(!is_done() implies
this is first member));
249 ensure(item().is_attached() == !is_done());
288 require(is_initialized());
307 require(is_initialized());
330 require(is_initialized());
334 result = _itr.is_done();
351 require(is_initialized());
362 ensure(!is_done() == item().is_attached());
363 ensure(unexecutable(postorder - have visited all of the members of the strict down
set 378 require(is_initialized());
379 require(anchor().state_is_read_accessible());
383 _itr.reset(xreset_markers);
389 ensure(is_initialized());
390 ensure(item().is_attached() == !is_done());
404 require(item_is_ancestor_of(*xanchor));
412 reset_anchor(*xanchor);
416 string ldof_sp_name = schema_poset_member::dof_subposet_name(
"top",
false);
418 _itr.put_filter(ldof_sp_name);
424 ensure(is_initialized());
425 ensure(anchor().is_same_state(xanchor));
426 ensure(anchor().is_same_type(xanchor));
427 ensure(item().is_attached() == !is_done());
440 require(is_initialized());
441 require(xreset ? anchor().state_is_read_accessible():
true);
445 result = _itr.ct(xreset);
466 require(is_initialized());
467 require(anchor().state_is_read_accessible());
468 require(anchor().host()->contains_member(xhub_id));
472 pod_index_type lbase_space_id = anchor().host()->get_base_space_id_from_index(xhub_id);
473 pod_index_type lfiber_schema_id = anchor().host()->get_fiber_schema_id_from_index(xhub_id);
475 result = (anchor().base_space_id() == lbase_space_id) && _itr.has_visited(lfiber_schema_id);
492 require(is_initialized());
493 require(anchor().state_is_read_accessible());
494 require(anchor().host()->contains_member(xid));
498 return has_visited(xid.
hub_pod());
510 require(is_initialized());
511 require(anchor().state_is_read_accessible());
512 require(item_is_ancestor_of(xmbr));
514 require(anchor().host()->is_same_state(xmbr.
host()));
518 result = (anchor().base_space_id() ==~ xmbr.base_space_id()) &&
536 require(is_initialized());
537 require(anchor().state_is_read_accessible());
538 require(anchor().host()->contains_member(xhub_id));
539 require(anchor().base_space_id() == anchor().host()->get_base_space_id_from_index(xhub_id));
543 _itr.put_has_visited(_anchor->host()->get_fiber_schema_id_from_index(xhub_id), xvalue);
547 ensure(has_visited(xhub_id) == xvalue);
561 require(is_initialized());
562 require(anchor().state_is_read_accessible());
563 require(anchor().host()->contains_member(xid));
564 require(anchor().base_space_id() == anchor().host()->get_base_space_id_from_index(xid.
hub_pod()));
568 put_has_visited(xid.
hub_pod(), xvalue);
572 ensure(has_visited(xid) == xvalue);
587 require(is_initialized());
606 require(is_initialized());
649 require(is_initialized());
657 ensure(result == item().index());
672 require(item_is_ancestor_of(xanchor));
681 _anchor = xanchor.
clone();
693 ensure(_anchor != 0);
694 ensure(_anchor->is_attached());
695 ensure(_anchor->is_same_state(&xanchor));
696 ensure(_anchor->is_same_type(&xanchor));
709 require(is_initialized());
715 _item->detach_from_state();
723 _item->attach_to_state(_anchor->host(), _anchor->base_space_id(), _itr.index().pod());
728 ensure(item().is_attached() == !is_done());
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 void update_item()
Attaches the item handle to the current index, or detaches the item handle if is_done.
bool is_initialized() const
True if this has been initialized for iteration with respect to a specific anchor.
virtual void next()
Makes this the next member of the subset.
section_space_schema_poset * host() const
The poset which this is a handle to a component of.
schema_poset_member & fiber_schema()
The fiber schema component of this (mutable version).
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
section_space_schema_member * _item
The member handle for the current item in the iteration.
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...
postorder_iterator _itr
The index iterator used to implement the iteration.
virtual section_component_iterator & operator=(const section_component_iterator &xother)
Assignment operator.
void put_anchor(const section_space_schema_member *xanchor)
Sets anchor to member xanchor.
section_component_iterator()
Default constructor; creates an unattached iterator, with and all-pass filter.
virtual ~section_component_iterator()
Destructor.
section_space_schema_member & item()
The the current member of the iteration (mutable version).
virtual bool has_visited(pod_index_type xhub_id) const
True if this has already visited hub id xhub_id.
section_space_schema_member & anchor()
The schema member whose downset is being iterated over; the top member of the domain of iteration (mu...
virtual void put_has_visited(pod_index_type xhub_id, bool xvalue)
Set the visited marker for hub id xhub_id to xvalue. Intended for use reseting iterator without havin...
Abstract base class with useful features for all objects.
virtual void reset_anchor(const section_space_schema_member &xanchor)
Creates anchor if needed and attaches it to xanchor. Abstract in this class; intended to be redefined...
virtual bool item_is_ancestor_of(const section_space_schema_member &xmbr) const
True if xmbr conforms to the type of item of this.
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 bool is_ancestor_of(const any *other) const
True if other conforms to this.
virtual const scoped_index & index() const
The index of the current member of the iteration.
Iterates in postorder over components of a section_space_schema_member anchor. The components of a se...
bool is_done() const
True if iteration finished.
int_type pod_index_type
The plain old data index type.
A client handle for a poset member which has been prepared for use as a schema for a section space...
bool invariant() const
The class invariant.
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...
Namespace for the fiber_bundles component of the sheaf system.
virtual void attach_to_state(pod_index_type xbase_space_id, pod_index_type xfiber_schema_id)=0
Attach to the state in host() with component ids xbase_id and xfiber_schema_id.
section_space_schema_member * _anchor
The schema member whose downset is being iterated over; the top member of the domain of iteration...
section_space_schema_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...
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.