SheafSystem  0.0.0.0
binary_section_space_schema_member.impl.h
1 
2 
3 //
4 // Copyright (c) 2014 Limit Point Systems, Inc.
5 //
6 
7 // Implementation for section_space_schema_member facet function templates.
8 
9 #ifndef BINARY_SECTION_SPACE_SCHEMA_MEMBER_IMPL_H
10 #define BINARY_SECTION_SPACE_SCHEMA_MEMBER_IMPL_H
11 
12 #ifndef SHEAF_DLL_SPEC_H
13 #include "SheafSystem/sheaf_dll_spec.h"
14 #endif
15 
16 #ifndef BINARY_SECTION_SPACE_SCHEMA_MEMBER_H
17 #include "SheafSystem/binary_section_space_schema_member.h"
18 #endif
19 
20 #ifndef ASSERT_CONTRACT_H
21 #include "SheafSystem/assert_contract.h"
22 #endif
23 
24 #ifndef BASE_SPACE_POSET_H
25 #include "SheafSystem/base_space_poset.h"
26 #endif
27 
28 #ifndef BINARY_SECTION_SPACE_SCHEMA_POSET_H
29 #include "SheafSystem/binary_section_space_schema_poset.h"
30 #endif
31 
32 #ifndef FIBER_BUNDLES_NAMESPACE_H
33 #include "SheafSystem/fiber_bundles_namespace.h"
34 #endif
35 
36 #ifndef SEC_REP_DESCRIPTOR_POSET_H
37 #include "SheafSystem/sec_rep_descriptor_poset.h"
38 #endif
39 
40 #ifndef TUPLE_H
41 #include "SheafSystem/tuple.h"
42 #endif
43 
44 using namespace fiber_bundle; // Workaround for MS C++ bug.
45 
46 template <typename S>
49 standard_host_path(const poset_path& xbase_path, const poset_path& xrep_path, const std::string& xfiber_suffix)
50 {
51  // cout << endl << "Entering binary_section_space_schema_member::standard_host_path." << endl;
52 
53  // Preconditions:
54 
55  require(xbase_path.full());
56  require(xrep_path.empty() || xrep_path.full());
57  require(xfiber_suffix.empty() || poset_path::is_valid_name(xfiber_suffix));
58 
59  // Body:
60 
61  typedef typename S::fiber_type fiber_type;
62 
63  poset_path lstd_fiber_path(fiber_type::template standard_host_path<fiber_type>(xfiber_suffix));
64  poset_path lrep_path = !xrep_path.empty() ? xrep_path : S::standard_rep_path();
65 
66  std::string lposet_name(lstd_fiber_path.poset_name());
67  lposet_name += "_on_";
68  lposet_name += xbase_path.poset_name();
69  lposet_name += "_";
70  lposet_name += lrep_path.member_name();
71  lposet_name += "_schema";
72 
73  sheaf::poset_path result(lposet_name, "");
74 
75 
76  // Postconditions:
77 
78  ensure(!result.full());
79 
80  // Exit:
81 
82  // cout << "Leaving binary_section_space_schema_member::standard_host_path." << endl;
83  return result;
84 }
85 
86 template <typename S>
89 standard_member_path(const poset_path& xbase_path, const poset_path& xrep_path, const std::string& xfiber_suffix)
90 {
91  // cout << endl << "Entering binary_section_space_schema_member::standard_path." << endl;
92 
93  // Preconditions:
94 
95  require(xbase_path.full());
96  require(xrep_path.empty() || xrep_path.full());
97  require(xfiber_suffix.empty() || poset_path::is_valid_name(xfiber_suffix));
98 
99  // Body:
100 
101  typedef typename S::fiber_type fiber_type;
102 
103  poset_path result(standard_host_path<S>(xbase_path, xrep_path, xfiber_suffix));
104 
105  std::string lmember_name =
106  standard_member_name(fiber_type::standard_schema_path().member_name(),
107  xbase_path.member_name());
108 
109  result.put_member_name(lmember_name);
110 
111  // Postconditions:
112 
113  ensure(result.full());
114 
115  // Exit:
116 
117  // cout << "Leaving binary_section_space_schema_member::standard_path." << endl;
118  return result;
119 }
120 
121 
122 
123 template <typename S>
124 bool
127  const poset_path& xbase_path,
128  const poset_path& xrep_path,
129  const std::string& xfiber_suffix,
130  bool xauto_access)
131 {
132  // cout << endl << "Entering binary_section_space_schema_member::standard_host." << endl;
133 
134  // Preconditions:
135 
136 
137  require(xns.state_is_auto_read_write_accessible(xauto_access));
138 
139  require(xbase_path.full());
140  require(xns.path_is_auto_read_accessible<base_space_poset>(xbase_path, xauto_access));
141 
142  require(xrep_path.empty() || xrep_path.full());
143  require(xrep_path.empty() || xns.path_is_auto_read_accessible<sec_rep_descriptor_poset>(xrep_path, xauto_access));
144 
145  require(xfiber_suffix.empty() || poset_path::is_valid_name(xfiber_suffix));
146 
147  // Body:
148 
149  poset_path lstd_path(standard_host_path<S>(xbase_path, xrep_path, xfiber_suffix));
150 
151  bool result = xns.path_is_available<host_type>(lstd_path, xauto_access);
152 
153  // Postconditions:
154 
155 
156  // Exit:
157 
158  // cout << "Leaving binary_section_space_schema_member::standard_host." << endl;
159  return result;
160 }
161 
162 template <typename S>
166  const poset_path& xbase_path,
167  const poset_path& xrep_path,
168  const std::string& xfiber_suffix,
169  bool xauto_access)
170 {
171  // cout << endl << "Entering binary_section_space_schema_member::standard_host." << endl;
172 
173  // Preconditions:
174 
175  require(xns.state_is_auto_read_write_accessible(xauto_access));
176 
177  require(xbase_path.full());
178  require(xns.path_is_auto_read_accessible<base_space_poset>(xbase_path, xauto_access));
179 
180  require(xrep_path.full());
181  require(xns.path_is_auto_read_accessible<sec_rep_descriptor_poset>(xrep_path, xauto_access));
182 
183  require(xfiber_suffix.empty() || poset_path::is_valid_name(xfiber_suffix));
184  require(S::fiber_type::template standard_host_is_available<typename S::fiber_type>(xns, xfiber_suffix, xauto_access));
185 
186  require(standard_host_is_available<S>(xns, xbase_path, xrep_path, xfiber_suffix, xauto_access));
187 
188  // Body:
189 
190  typedef typename S::fiber_type fiber_type;
191  typedef typename S::fiber_type::host_type fiber_host_type;
192 
193  poset_path lstd_path(standard_host_path<S>(xbase_path, xrep_path, xfiber_suffix));
194 
195  host_type* lresult_ptr;
196 
197  if(xns.contains_path(lstd_path, xauto_access))
198  {
199  // Host already exists, just return it.
200 
201  lresult_ptr = &xns.member_poset<host_type>(lstd_path, xauto_access);
202  }
203  else
204  {
205  // Host does already exist, we will have to create it.
206 
207  // First, make sure the standard fiber space exists.
208 
209  fiber_host_type& lfiber_space = fiber_type::standard_host(xns, xfiber_suffix, xauto_access);
210  poset_path lfiber_path = lfiber_space.path(xauto_access);
211 
212  // Now create the host with the standard schema.
213 
214  poset_path lstd_schema_path(host_type::standard_schema_path());
215 
216  lresult_ptr = &new_host(xns, lstd_path, lstd_schema_path, xbase_path, lfiber_path, xrep_path, xauto_access);
217  }
218 
219  host_type& result = *lresult_ptr;
220 
221  // Postconditions:
222 
223  ensure(xns.owns(result, xauto_access));
224  ensure(result.path(true) == standard_host_path<S>(xbase_path, xrep_path, xfiber_suffix));
225  ensure(result.state_is_not_read_accessible());
226  ensure(result.schema(true).path(xauto_access) == host_type::standard_schema_path());
227 
228  ensure(result.base_space_path(true).poset_name() == xbase_path.poset_name());
229  ensure(result.fiber_space_path(true) == S::fiber_type::template standard_host_path<typename S::fiber_type>(xfiber_suffix));
230  ensure(result.rep_path(true) == xrep_path);
231 
232  // Exit:
233 
234  // cout << "Leaving binary_section_space_schema_member::standard_host." << endl;
235  return result;
236 }
237 
238 template <typename S>
242  const poset_path& xbase_path,
243  const poset_path& xrep_path,
244  const std::string& xfiber_suffix,
245  bool xauto_access)
246 {
247  // cout << endl << "Entering binary_section_space_schema_member::standard_host." << endl;
248 
249  // Preconditions:
250 
251  require(precondition_of(standard_host<S>(xns, xbase_path, xrep_path, xfiber_suffix, xauto_access)));
252 
253  // Body:
254 
255  // Find or create the standard host.
256 
257  host_type& lhost = standard_host<S>(xns, xbase_path, xrep_path, xfiber_suffix, xauto_access);
258 
259  // All members of the schema exist implicitly, but a member can't
260  // be accessed by path unless we explicitly give it a name..
261 
262  poset_path result(standard_member_path<S>(xbase_path, xrep_path, xfiber_suffix));
263  if(!lhost.contains_member(result.member_name()))
264  {
265  binary_section_space_schema_member lmbr(&lhost, xbase_path, lhost.fiber_space().schema(xauto_access).path(xauto_access));
266  lmbr.put_name(result.member_name(), true, true);
267  }
268 
269  // Postconditions:
270 
271  ensure(postcondition_of(standard_host<S>(xns, xbase_path, xrep_path, xfiber_suffix, xauto_access)));
272 
273  ensure(result == standard_member_path<S>(xbase_path, xrep_path, xfiber_suffix));
274  ensure(xns.contains_path(result, xauto_access));
275 
276  // Exit:
277 
278  // cout << "Leaving binary_section_space_schema_member::standard_host." << endl;
279  return result;
280 }
281 
282 #endif // ifndef BINARY_SECTION_SPACE_SCHEMA_MEMBER_IMPL_H
virtual poset_path path(bool xauto_access=true) const
The path of this poset.
bool state_is_auto_read_write_accessible(bool xauto_access) const
True if state is auto accessible for read and write, that is, if the state is already accessible for ...
static host_type & standard_host(namespace_type &xns, const poset_path &xbase_path, const poset_path &xrep_path, const std::string &xfiber_suffix, bool xauto_access)
The standard host of a schema for sections of type S with base space sepcified by xbase_path...
A client handle for a poset member which has been prepared for use as a schema for a section space...
bool full() const
True if both poset name and member name are not empty.
Definition: poset_path.cc:311
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.
bool path_is_auto_read_accessible(const poset_path &xpath, bool xauto_access) const
True if the state referred to xpath exists and is auto read accessible.
The standard fiber bundles name space; extends the standard sheaves namespace by defining base space...
static poset_path standard_member_path(const poset_path &xbase_path, const poset_path &xrep_path, const std::string &xfiber_suffix)
The standard path for a schema member for sections of type S with base space sepcified by xbase_path...
A path defined by a poset name and a member name separated by a forward slash (&#39;/&#39;). For example: "cell_definitions/triangle".
Definition: poset_path.h:48
A schema poset for a section space. A binary Cartesian product subspace of the binary tensor product ...
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.
The poset for sec_rep_descriptors.
poset_path rep_path(bool xauto_access) const
The path to the representation for section spaces on this schema..
poset & fiber_space()
The fiber space for section spaces on this schema.
The lattice of closed cells of a cellular space; a lattice representation of a computational mesh...
bool path_is_available(const poset_path &xpath, bool xauto_access) const
True if the state referred to xpath does not exist or exists and conforms to poset type P...
virtual schema_poset_member & schema()
The schema for this poset (mutable version).
void put_member_name(const std::string &xname)
Sets member_name() to xname.
Definition: poset_path.cc:526
bool owns(const poset_state_handle &xposet, bool xauto_access) const
True if and only if this contains the poset xposet. synonym for contains_poset(xposet.poset_path(true), xauto_access)
std::string poset_name() const
The poset name part of the path.
Definition: poset_path.cc:473
bool contains_path(const poset_path &xpath, bool xauto_access=true) const
True if this contains the poset or poset member specified by xpath.
virtual void put_name(const std::string &xname, bool xunique, bool xauto_access)
Make xname a name for this; if xunique, make xname the only name.
static bool standard_host_is_available(namespace_poset &xns, const poset_path &xbase_path, const poset_path &xrep_path, const std::string &xfiber_suffix, bool xauto_access)
True if and only if the host specified by standard_host_path<S>(xbase_path, xrep_path, xfiber_suffix) does not exist, or it exists and conforms to host_type.
bool empty() const
True if both poset name and member name are empty.
Definition: poset_path.cc:291
poset_path base_space_path(bool xauto_access) const
The path to the base space for section spaces on this schema.
static poset_path standard_host_path(const poset_path &xbase_path, const poset_path &xrep_path, const std::string &xfiber_suffix)
The standard path for the host of a schema for sections of type S with base space specified by xbase_...
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. ...
poset_path fiber_space_path(bool xauto_access) const
The path to the fiber space for section spaces on this schema.
static poset_path standard_member(namespace_type &xns, const poset_path &xbase_path, const poset_path &xrep_path, const std::string &xfiber_suffix, bool xauto_access)
The path for standard schema member for sections of type S with base space sepcified by xbase_path...
std::string member_name() const
The member name part of the path.
Definition: poset_path.cc:511
static bool is_valid_name(const std::string &xname)
True if xname is not empty and contains only name legal characters.
Definition: poset_path.cc:331
std::string path() const
The full path as a string.
Definition: poset_path.cc:450
Namespace for the fiber_bundles component of the sheaf system.
bool state_is_not_read_accessible() const
True if this is attached and if the state is accessible for read or if access control is disabled...