22 #include "SheafSystem/poset_table_state.h" 24 #include "SheafSystem/array_poset_dof_map.h" 25 #include "SheafSystem/assert_contract.h" 26 #include "SheafSystem/index_space_iterator.h" 27 #include "SheafSystem/poset_dof_iterator.h" 28 #include "SheafSystem/poset_state_handle.h" 29 #include "SheafSystem/schema_poset_member.h" 30 #include "SheafSystem/std_iomanip.h" 31 #include "SheafSystem/primitive_value.h" 80 sheaf::poset_table_state::
85 require(xschema != 0 ? xschema->
is_attached() :
true);
91 disable_invariant_check();
95 _row_dof_tuple_index_ub.put(hub_id_space(), 0);
108 _schema = lschema->
clone();
134 _row_dof_tuples.reserve(xcapacity);
136 _standard_row_dof_tuple_ct = 0;
140 ensure( (xschema != 0) == schema().is_attached() );
141 ensure(row_dof_tuple_index_ub().is_hub_scope());
149 require(_schema != 0);
155 _schema->detach_from_state();
162 _table_dofs->dec_ref_ct();
163 if(_table_dofs->ref_ct() == 0)
171 for(
int i=0; i<_row_dof_tuple_index_ub.pod(); i++)
247 _table_dofs = xtable_dofs;
264 bool result = hub_id_space().contains(xindex);
277 return contains_row_dof_tuple(xindex.
hub_pod());
290 result = hub_id_space().ct();
329 result = _standard_row_dof_tuple_ct;
346 _standard_row_dof_tuple_ct = xct;
365 if(contains_row_dof_tuple(xindex))
367 result = _row_dof_tuples[xindex];
385 return row_dof_tuple(xindex.
hub_pod());
396 define_old_variable(
scoped_index old_row_dof_tuple_index_ub = row_dof_tuple_index_ub());
397 define_old_variable(
size_type old_row_dof_tuple_ct = row_dof_tuple_ct());
398 define_old_variable(
int old_ref_ct = xdof_tuple->
ref_ct());
411 _row_dof_tuples.force_item(lindex, xdof_tuple);
415 _row_dof_tuple_index_ub = hub_id_space().end();
428 ensure(row_dof_tuple_ct() == old_row_dof_tuple_ct+1);
429 ensure(row_dof_tuple_index_ub() >= old_row_dof_tuple_index_ub);
430 ensure(contains_row_dof_tuple(xdof_tuple->
index()));
431 ensure(row_dof_tuple(xdof_tuple->
index()) == xdof_tuple);
432 ensure(xdof_tuple->
ref_ct() == old_ref_ct + 1);
451 ensure(hub_id_space().allocated_iterator(result));
464 require(hub_id_space().allocated_iterator(xitr));
468 hub_id_space().release_iterator(xitr);
535 ensure(result.
pod() == xid);
606 if(invariant_check())
608 disable_invariant_check();
610 result = result && _schema->is_attached();
612 enable_invariant_check();
643 os <<
"Schema" << endl
666 <<
"Table Attributes" << endl
667 <<
"----------------" << endl
674 os <<
"table dof count: " << ldof_ct
678 const int NAME_WIDTH = 40;
679 const int VALUE_WIDTH = 40;
685 os <<
"table dofs:" << endl
686 << setw(NAME_WIDTH) <<
"name" 687 << setw(VALUE_WIDTH) <<
"value" 690 for(
int i=0; i<NAME_WIDTH; ++i)
695 for(
int i=0; i<VALUE_WIDTH; ++i)
702 while(!table_dof_itr->
is_done())
704 os << setw(NAME_WIDTH) << table_dof_itr->
item().
name().c_str();
706 os <<
" " << setw(VALUE_WIDTH)
710 table_dof_itr->
next();
712 delete table_dof_itr;
733 <<
"Row Attributes" << endl
734 <<
"--------------" << endl
743 lccr_schema->
put_version(sheaf::COARSEST_COMMON_REFINEMENT_VERSION);
749 os <<
"row dof count: " << ldof_ct
756 const int INDEX_WIDTH = 6;
757 const int TYPE_WIDTH = 6;
758 const int OTHER_WIDTH = 10;
759 const int C_STRING_WIDTH = 48;
761 os << setw(INDEX_WIDTH) <<
" index" << setw(TYPE_WIDTH) <<
" type";
768 int lwidth = (ltype == sheaf::C_STRING) ? C_STRING_WIDTH - 2 : OTHER_WIDTH - 2;
769 os << setw(lwidth) <<
" dof " << setw(3) << ldof_id++;
775 os << setw(INDEX_WIDTH) <<
" " << setw(TYPE_WIDTH) <<
" ";
780 int ltype = name_itr->
item().
type();
781 int lwidth = (ltype == sheaf::C_STRING) ? C_STRING_WIDTH : OTHER_WIDTH;
783 os <<
" " << setw(lwidth) << name_itr->
item().
name().substr(0, lwidth);
792 os << setw(INDEX_WIDTH) <<
" -----";
793 os << setw(TYPE_WIDTH) <<
" -----";
798 int ltype = undr_itr->
item().
type();
799 int lwidth = (ltype == sheaf::C_STRING) ? C_STRING_WIDTH : OTHER_WIDTH;
800 for(
int i=0; i<lwidth; ++i)
821 os << setw(INDEX_WIDTH) << lid;
822 os << setw(TYPE_WIDTH) <<
" ";
849 if(lprim.
id() == sheaf::VOID_STAR)
854 ldof_string = (lprim.
value().void_star_primitive == 0) ?
"<null>" :
"<non-null>";
855 lwidth = OTHER_WIDTH;
860 lwidth = (lprim.
id() == sheaf::C_STRING) ? C_STRING_WIDTH : OTHER_WIDTH;
863 os <<
" " << setw(lwidth) << ldof_string;
871 int lwidth = (ltype == sheaf::C_STRING) ? C_STRING_WIDTH : OTHER_WIDTH;
873 for(
int i=0; i<lwidth; ++i)
920 print_table_dofs(os, p);
921 print_row_dofs(os, p);
926 <<
"Tuple Id Space Family" << endl
927 <<
"----------------------" << endl
950 result = xinclude_shallow ?
sizeof(xp) : 0;
954 result += deep_size(xp._id_spaces,
false);
958 result += deep_size(*xp._schema,
true);
962 result += deep_size(*xp._table_dofs,
true);
971 result += deep_size(xp._row_dof_tuples,
false);
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...
poset_dof_iterator * table_dof_iterator(int xversion=CURRENT_MEMBER_VERSION) const
A postorder iterator over the table dofs defined by this. Synonym for dof_iterator(true).
poset_state_handle * host() const
The poset which this is a handle to a component of.
size_type standard_row_dof_tuple_ct() const
The number of standard row_dof_tuples automatically allocated by the poset handle constructor...
virtual bool is_ancestor_of(const any *other) const
True if other conforms to current.
const pod_type & pod() const
The "plain old data" storage of this; the value in the external id space.
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...
An abstract iterator over the ids of an id space.
poset_dof_iterator * row_dof_iterator(int xversion=CURRENT_MEMBER_VERSION) const
A postorder iterator over the row dofs defined by this.
void put_row_dof_tuple(poset_dof_map *xdof_tuple)
Sets the dof tuple at index xindex to xdof_tuple.
pod_type pod() const
The current id in the iteration.
schema_poset_member & item()
The current member of the iteration (mutable version).
bool contains_row_dof_tuple(pod_index_type xindex) const
True if xindex is a valid row dof tuple index.
virtual schema_poset_member & schema()
The schema on which this is allocated (mutable version).
primitive_value dof(pod_index_type xdof_id) const
The dof referred to by xdof_id.
int version() const
The version of the host of the schema this is defined on.
schema_poset_member & schema()
Schema (mutable version)
void put_index(const scoped_index &xindex)
Sets the index of the member for which this provides the dofs.
virtual bool is_done() const
True if iteration finished.
virtual void next()=0
Makes id() the next id in the iteration.
The general, abstract map from dof ids to dof values.
virtual primitive_type type() const
The primitive type index of the dof defined by this.
An implementation of class sum_index_space_handle that has a primary sum id space state...
const hub_index_space_handle & hub_id_space() const
The hub id space.
virtual poset_table_state * clone() const
Make a new instance of the same type as this.
bool is_hub_scope() const
True if and only if the id space of this is the hub id space.
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.
std::string to_string() const
Converts this to a string (for stream insertion).
bool is_done() const
True if iteration is finished.
~poset_table_state()
Destructor.
index_space_iterator & get_row_dof_tuple_id_space_iterator() const
Allocates an id space iterator over the row dof tuple ids from the iterator pool. ...
virtual void detach_from_state()
Detach this handle from its state, if any.
virtual void to_stream(std::ostream &xos=std::cout) const
Virtual stream insertion.
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.
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.
const hub_index_space_handle & hub_id_space() const
Hub id space for this poset powerset.
void inc_ref_ct()
Increase the number of references to this map by one;.
poset_dof_map * row_dof_tuple(pod_index_type xindex)
The row dof tuple with index xindex.
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. ...
std::string name(pod_index_type xdof_id, bool xis_table_dof) const
The name of the table dof (xis_table_dof true) or row dof referred to by xdof_id in the schema define...
size_t table_dof_tuple_ub() const
The size in bytes of the table dof tuple defined by this schema. Synonym for dof_tuple_ub(true).
static int row_dof_ct(const namespace_poset &xns, const poset_path &xpath, bool xauto_access=true)
The number of row dofs defined by the schema specified by xns and xpath. Synonym for dof_ct(xns...
virtual const scoped_index & index()
The index of the current member of the iteration.
const index_space_family & id_spaces() const
Collection of id spaces for this poset powerset.
primitive_buffer_type & value()
The value of this.
bool ge(pod_index_type xother_index) const
True if this is greater than or equal to the member with index xother_index.
void dec_ref_ct()
Decrease the number of references to this map by one.
const scoped_index & row_dof_tuple_index_ub() const
The upper bound of the index for row dof tuples.
array_poset_dof_map * table_dofs()
Get the table dof map.
primitive_type & id()
Type id of the primitive type.
size_t row_dof_tuple_ub() const
The size in bytes of the row dof tuple defined by this schema. Synonym for dof_tuple_ub(false).
Iterates in postorder over dofs of a schema member anchor. Attaches a handle of type schema_poset_mem...
const scoped_index & hub_id() const
A id in the hub id space; intended for copying to initialize ids to the hub id space.
T::table_dofs_type & table_dofs(T &x0)
The table dofs pod type for x0 (mutable version).
int_type pod_index_type
The plain old data index type.
SHEAF_DLL_SPEC std::ostream & operator<<(std::ostream &os, const dof_descriptor_array &p)
Insert dof_descriptor_array& p into ostream& os.
void put_standard_row_dof_tuple_ct(size_type xct)
Put the number of standard row_dof_tuples automatically allocated by the poset handle constructor...
static int table_dof_ct(const namespace_poset &xns, const poset_path &xpath, bool xauto_access=true)
The number of tablr dofs defined by the schema specified by xns and xpath. Synonym for dof_ct(xns...
virtual bool invariant() const
Class invariant.
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.
Abstract object wrapper for an instance of a primitive type.
An abstract client handle for a member of a poset.
Factory and container for a family of id spaces.
An array representation of abstract class poset_dof_map.
void release_row_dof_tuple_id_space_iterator(index_space_iterator &xitr) const
Returns the id space iterator xitr to the row dof tuple iterator pool.
void put_table_dofs(array_poset_dof_map *xtable_dofs)
Put the table dof map.
unsigned int ref_ct() const
The number of references to this map.
A client handle for a poset member which has been prepared for use as a schema.
The data structure representing the table containing the dof tuples of the members of a poset...
const scoped_index & index() const
The index of this in host() dof tuple table.
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
size_type row_dof_tuple_ct() const
The number of dof tuples in the dof tuple table.