20 #include "SheafSystem/poset_path.h" 22 #include "SheafSystem/assert_contract.h" 23 #include "SheafSystem/namespace_poset.h" 24 #include "SheafSystem/primitive_value.h" 25 #include "SheafSystem/schema_poset_member.h" 26 #include "SheafSystem/std_iostream.h" 27 #include "SheafSystem/std_sstream.h" 29 using namespace sheaf;
66 ensure(*
this == xposet_path);
75 poset_path(
const std::string& xposet_name,
const std::string& xmember_name)
79 require(!xposet_name.empty());
80 require(is_valid_path(xposet_name + delimiter() + xmember_name));
84 *
this = xposet_name + delimiter() + xmember_name;
88 ensure(poset_name() == xposet_name);
89 ensure(member_name() == xmember_name);
121 require(is_valid_path(xpath));
129 ensure(*
this == xpath);
143 require(is_valid_path(xpath));
152 ensure((*
this) == xpath);
161 require(xpath.
id() == C_STRING);
162 require(is_valid_path(xpath.
value().c_string_primitive));
171 ensure((*
this) == xpath);
174 #ifndef DOXYGEN_SHOULD_SKIP_THIS 189 ensure(result.
id() == C_STRING);
190 ensure(
string(result) == path());
196 #endif // ifndef DOXYGEN_SHOULD_SKIP_THIS 207 _poset_name = xposet_path._poset_name;
208 _member_name = xposet_path._member_name;
213 ensure(*
this == xposet_path);
228 require(is_valid_path(xpath));
233 parse_path(xpath, _poset_name, ldelimiter, _member_name);
237 ensure(*
this == xpath);
252 require(is_valid_path(cpath));
257 parse_path(cpath, _poset_name, ldelimiter, _member_name);
261 ensure(*
this == cpath);
277 *
this = xposet_path.
value().c_string_primitive;
281 ensure(*
this == xposet_path);
299 result = _poset_name.empty() && _member_name.empty();
319 result = !_poset_name.empty() && !_member_name.empty();
340 result = (!xname.empty() && (xname.find_first_not_of(name_legal_characters()) == string::npos));
345 ensure(result == (!xname.empty() && (xname.find_first_not_of(name_legal_characters()) == string::npos)));
362 bool result = (xpath.find_first_not_of(path_legal_characters()) == string::npos);
366 string lposet_name, ldelimiter, lmember_name;
367 parse_path(xpath, lposet_name, ldelimiter, lmember_name);
369 lposet_name.empty() ? (ldelimiter.empty() && lmember_name.empty()) :
true;
374 ensure(result == ((xpath.find_first_not_of(path_legal_characters()) == string::npos) &&
375 (!poset_name(xpath).empty() || (delimiter(xpath).empty() && member_name(xpath).empty()))));
394 (_poset_name == xother._poset_name) && (_member_name == xother._member_name);
413 string lposet_name, ldelimiter, lmember_name;
414 parse_path(xother, lposet_name, ldelimiter, lmember_name);
416 (_poset_name == lposet_name) && (_member_name == lmember_name);
434 require(xother != 0);
438 string lother(xother);
456 string result = _poset_name;
457 if(!_member_name.empty())
459 result += delimiter() + _member_name;
493 require(is_valid_name(xname));
501 ensure(poset_name() == xname);
530 require(is_valid_name(xname));
534 _member_name = xname;
538 ensure(member_name() == xname);
560 static const string result(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_ -,.=+()*:?");
564 ensure(result ==
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_ -,.=+()*:?");
588 ensure(result ==
'/');
607 static const string result(name_legal_characters() + delimiter());
611 ensure(result == (name_legal_characters() + delimiter()));
630 string result, ldelim, lmbr_name;
632 parse_path(xpath, result, ldelim, lmbr_name);
654 string lposet_name, result, lmbr_name;
656 parse_path(xpath, lposet_name, result, lmbr_name);
679 string lposet_name, ldelim, result;
681 parse_path(xpath, lposet_name, ldelim, result);
685 ensure(delimiter(xpath).empty() ? result.empty() :
true);
705 make_name(
const std::string& xprefix,
int xindex,
const std::string& xsuffix)
714 stringstream lname_stream;
715 lname_stream << xprefix << xindex << xsuffix;
716 lname_stream >> result;
720 ensure(!result.empty());
721 ensure(!xprefix.empty() ? result.find(xprefix) == 0 :
true);
722 ensure(!xsuffix.empty() ?
723 (result.find(xsuffix) + xsuffix.size()) == result.size() :
true);
741 ensure(postcondition_of(make_name(reserved_prefix()+xprefix, xindex, xsuffix)));
745 return make_name(reserved_prefix()+xprefix, xindex, xsuffix);
761 result = make_name(block_prefix(), xindex,
"");
765 ensure(!result.empty());
766 ensure(result.find(block_prefix()) == 0);
784 require(xneighborhood_name.find(neighborhood_prefix()) != string::npos);
788 result = xneighborhood_name.substr(neighborhood_prefix().size());
792 ensure(!result.empty());
793 ensure(result.find(block_prefix()) == 0);
815 result = neighborhood_prefix() + block_name(xindex);
819 ensure(!result.empty());
820 ensure(result.find(neighborhood_prefix()) == 0);
838 ensure(xblock_name.find(block_prefix()) == 0);
842 result = neighborhood_prefix() + xblock_name;
846 ensure(!result.empty());
847 ensure(result.find(neighborhood_prefix()) == 0);
863 require(xname.find(block_prefix()) != string::npos);
867 stringstream lname_stream;
868 string lblock_prefix = block_prefix();
869 lname_stream << xname.substr(xname.find(lblock_prefix) + lblock_prefix.size());
870 lname_stream >> result;
914 string result(reserved_prefix() +
"bdy_of_");
935 result = boundary_prefix() + xmbr_name;
939 ensure(!result.empty());
940 ensure(result.find(boundary_prefix()) == 0);
958 string result(reserved_prefix() +
"block_");
981 string result(reserved_prefix() +
"neighborhood_of_");
1023 require(current_namespace() != 0);
1024 require(xauto_access || current_namespace()->state_is_read_accessible());
1028 result = !_poset_name.empty();
1031 if(!_member_name.empty())
1033 result = current_namespace()->contains_poset_member(*
this, xauto_access);
1037 result = current_namespace()->contains_poset(*
this, xauto_access);
1059 require(current_namespace() != 0);
1060 require(xauto_access || current_namespace()->state_is_read_accessible());
1064 result = !empty() && state_exists(xauto_access);
1085 require(current_namespace() != 0);
1086 require(xauto_access || current_namespace()->state_is_read_accessible());
1090 result = full() && state_exists(xauto_access);
1109 require(current_namespace() != 0);
1110 require(xauto_access || current_namespace()->state_is_read_accessible());
1111 require(state_exists(xauto_access));
1116 current_namespace()->member_poset(*
this, xauto_access).state_is_read_accessible();
1135 require(current_namespace() != 0);
1136 require(xauto_access || current_namespace()->state_is_read_accessible());
1137 require(state_exists(xauto_access));
1142 current_namespace()->member_poset(*
this, xauto_access).state_is_read_write_accessible();
1161 require(current_namespace() != 0);
1162 require(xauto_access || current_namespace()->state_is_read_accessible());
1163 require(state_exists(xauto_access));
1164 require(xauto_access || state_is_read_accessible(xauto_access));
1170 result = poset_name() == xother.
poset_name();
1270 parse_path(
const std::string& xpath,
1271 std::string& xposet_name,
1272 std::string& xdelimiter,
1273 std::string& xmember_name)
1280 xposet_name.clear();
1281 xmember_name.clear();
1283 string::const_iterator itr = xpath.begin();
1284 while((itr != xpath.end()))
1288 if(c == delimiter())
1295 xposet_name.push_back(c);
1299 while((itr != xpath.end()))
1301 xmember_name.push_back(*itr);
1307 ensure(xdelimiter.empty() ? xmember_name.empty() :
true);
1332 require(xprim.
id() == C_STRING);
1333 return xpath.
path() == xprim.
value().c_string_primitive;
1340 require(xprim.
id() == C_STRING);
1341 return xpath.
path() == xprim.
value().c_string_primitive;
1361 ensure(result == 0);
static std::string block_prefix()
Prefix for identifying blocks.
poset_path & operator=(const poset_path &xposet_path)
Assignment from poset_path.
bool full() const
True if both poset name and member name are not empty.
bool state_is_read_accessible(bool xauto_access) const
static std::string make_name(const std::string &xprefix, int xindex, const std::string &xsuffix)
Creates a string xprefix_xindex_xsuffix.
static std::string boundary_name(const std::string &xmbr_name)
Creates the standard boundary name associated with the member with name xmbr_name.
bool conforms_to(const schema_poset_member &xother) const
True if the dofs defined by this agree in type and in order with the dofs defined by xother...
The default name space; a poset which contains other posets as members.
static char delimiter()
The path delimiter; used to separate poset name from member name.
bool state_is_auto_read_accessible(bool xauto_access) const
True if the state is auto accessible for read, that is, if the state is already accessible for read o...
static const std::string & name_legal_characters()
The characters a name is allowed to contain.
A path defined by a poset name and a member name separated by a forward slash ('/'). For example: "cell_definitions/triangle".
static std::string block_neighborhood_name(const size_t &xindex)
Creates the standard name for the neighborhood of the block with index xindex.
virtual void get_read_access() const
Get read access to the state associated with this.
poset_state_handle & member_poset(pod_index_type xhub_id, bool xauto_access=true) const
The poset_state_handle object referred to by hub id xhub_id.
static namespace_poset * current_namespace()
The current default namespace.
Features describing T as an index type.
namespace_poset * current_namespace() const
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...
bool state_is_read_write_accessible(bool xauto_access) const
bool conforms_to(const poset_path &xother, bool xauto_access) const
True if the schema member this refers to conforms to the schema member xother refers to in the curren...
void put_member_name(const std::string &xname)
Sets member_name() to xname.
virtual void detach_from_state()
Detach this handle from its state, if any.
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.
std::string poset_name() const
The poset name part of the path.
bool contains_path(const poset_path &xpath, bool xauto_access=true) const
True if this contains the poset or poset member specified by xpath.
static std::string boundary_prefix()
Prefix for identifying boundary members.
static size_t block_id(const std::string &xname)
Extracts the index from a block name or block neighborhood name.
bool state_exists(bool xauto_access) const
static std::string reserved_prefix()
Prefix for identifying member names reserved by the sheaf system.
static bool is_valid_path(const std::string &xpath)
True if xpath is empty, or if not empty, contains only legal characters and contains just a poset nam...
void to_stream(std::ostream &xos=std::cout) const
Write instance information to an ostream (default = stdout).
bool empty() const
True if both poset name and member name are empty.
void put_poset_name(const std::string &xname)
Sets poset_name() to xname.
bool operator==(const poset_path &xother) const
True if this specifies the same poset and member as xother.
primitive_buffer_type & value()
The value of this.
bool member_exists(bool xauto_access) const
bool operator==(const singly_linked_list< T, Alloc > &lhs, const singly_linked_list< T, Alloc > &rhs)
Checks if the contents of lhs and rhs are equal, that is, whether lhs.size() == rhs.size() and each element in lhs compares equal with the element in rhs at the same position.
primitive_type & id()
Type id of the primitive type.
bool poset_exists(bool xauto_access) const
std::string member_name() const
The member name part of the path.
SHEAF_DLL_SPEC std::ostream & operator<<(std::ostream &os, const dof_descriptor_array &p)
Insert dof_descriptor_array& p into ostream& os.
Namespace for the sheaves component of the sheaf system.
poset_path()
Default constructor.
static bool is_valid_name(const std::string &xname)
True if xname is not empty and contains only name legal characters.
Abstract object wrapper for an instance of a primitive type.
std::string path() const
The full path as a string.
static std::string neighborhood_prefix()
Prefix for identifying neighborhoods.
static const std::string & path_legal_characters()
The characters a path is allowed to contain.
static std::string block_name(const size_t &xindex)
Creates the standard name for the block with index xindex.
A client handle for a poset member which has been prepared for use as a schema.
static std::string make_reserved_name(const std::string &xprefix, const size_t &xindex, const std::string &xsuffix)
Creates a string reserved_prefix()_xprefix_xindex_xsuffix.