SheafSystem  0.0.0.0
namespace_poset.impl.h
Go to the documentation of this file.
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
20 
21 #ifndef NAMESPACE_POSET_IMPL_H
22 #define NAMESPACE_POSET_IMPL_H
23 
24 #ifndef SHEAF_DLL_SPEC_H
25 #include "SheafSystem/sheaf_dll_spec.h"
26 #endif
27 
28 #ifndef NAMESPACE_POSET_H
29 #include "SheafSystem/namespace_poset.h"
30 #endif
31 
32 #ifndef ARRAY_POSET_DOF_MAP_H
33 #include "SheafSystem/array_poset_dof_map.h"
34 #endif
35 
36 #ifndef ASSERT_CONTRACT_H
37 #include "SheafSystem/assert_contract.h"
38 #endif
39 
40 #ifndef NAMESPACE_POSET_MEMBER_H
41 #include "SheafSystem/namespace_poset_member.h"
42 #endif
43 
44 #ifndef POSET_PATH_H
45 #include "SheafSystem/poset_path.h"
46 #endif
47 
48 // ===========================================================
49 // NAMESPACE_POSET FACET
50 // ===========================================================
51 
52 // PUBLIC FUNCTIONS
53 
54 // PROTECTED FUNCTIONS
55 
56 // PRIVATE FUNCTIONS
57 
58 
59 // ===========================================================
60 // POSET FACTORY METHOD FACET
61 // ===========================================================
62 
63 // PUBLIC FUNCTIONS
64 
65 template<typename P>
66 P&
68 member_poset(pod_index_type xhub_id, bool xauto_access) const
69 {
70  // Preconditions:
71 
72  require(xauto_access || state_is_read_accessible());
73  require(contains_member(xhub_id, xauto_access));
74 
75  if(xauto_access)
76  {
78  }
79 
80  require(is_jim(xhub_id));
81 
82  // Body:
83 
84  namespace_poset_dof_map& ldof_map =
85  row_dof_map(member_dof_tuple_id(xhub_id, false));
86 
87  P& result = dynamic_cast<P&>(*ldof_map.poset_pointer());
88 
89  if(xauto_access)
90  {
92  }
93 
94  return result;
95 }
96 
97 template<typename P>
98 P&
100 member_poset(const scoped_index& xid, bool xauto_access) const
101 {
102  // Preconditions:
103 
104  require(xauto_access || state_is_read_accessible());
105  require(contains_member(xid, xauto_access));
106 
107  if(xauto_access)
108  {
109  get_read_access();
110  }
111 
112  require(is_jim(xid));
113 
114  // Body:
115 
116  P& result = member_poset<P>(xid.hub_pod(), false);
117 
118  if(xauto_access)
119  {
120  release_access();
121  }
122 
123  return result;
124 }
125 
126 template<typename P>
127 P&
129 member_poset(const poset_path& xpath, bool xauto_access) const
130 {
131  // Preconditions:
132 
133  require(contains_poset<P>(xpath, xauto_access));
134 
135  // Body:
136 
137  P& result = dynamic_cast<P&>(member_poset(xpath, xauto_access));
138 
139  // Postconditions:
140 
141  // Exit:
142 
143  return result;
144 }
145 
146 // PROTECTED FUNCTIONS
147 
148 // PRIVATE FUNCTIONS
149 
150 
151 // ===========================================================
152 // POSET FACTORY METHOD QUERY FACET
153 // ===========================================================
154 
155 // PUBLIC FUNCTIONS
156 
157 template<typename P>
158 bool
160 contains_poset(pod_index_type xhub_id, bool xauto_access) const
161 {
162  // Preconditions:
163 
164  require(xauto_access || state_is_read_accessible());
165 
166  if(xauto_access)
167  {
168  get_read_access();
169  }
170 
171  // Body:
172 
173  bool result = contains_member(xhub_id, false) && is_jim(xhub_id);
174  if(result)
175  {
176  result = (dynamic_cast<P*>(&member_poset(xhub_id, xauto_access)) != 0);
177  }
178 
179  // Postconditions:
180 
181  if(xauto_access)
182  {
183  release_access();
184  }
185 
186  // Exit
187 
188  return result;
189 }
190 
191 template<typename P>
192 bool
194 contains_poset(const scoped_index& xid, bool xauto_access) const
195 {
196  // Preconditions:
197 
198  require(xauto_access || state_is_read_accessible());
199 
200  if(xauto_access)
201  {
202  get_read_access();
203  }
204 
205  // Body:
206 
207  return contains_poset<P>(xid.hub_pod(), xauto_access);
208 }
209 
210 template<typename P>
211 bool
213 contains_poset(const poset_path& xpath, bool xauto_access) const
214 {
215  // Preconditions:
216 
217  require(xauto_access || state_is_read_accessible());
218 
219  // Body:
220 
221  bool result = contains_poset(xpath, xauto_access);
222  if(result)
223  {
224  result = (dynamic_cast<P*>(&member_poset(xpath, xauto_access)) != 0);
225  }
226 
227  // Postconditions:
228 
229  // Exit:
230 
231  return result;
232 }
233 
234 template<typename P>
235 bool
237 contains_path(const poset_path& xpath, bool xauto_access) const
238 {
239  // Preconditions:
240 
241 
242  // Body:
243 
244  bool result = contains_path(xpath, xauto_access);
245  if(result)
246  {
247  result = (dynamic_cast<P*>(&member_poset(xpath, xauto_access)) != 0);
248  }
249 
250  // Postconditions:
251 
252  // Exit:
253 
254  return result;
255 }
256 
257 template<typename P>
258 bool
260 path_is_auto_read_accessible(const poset_path& xpath, bool xauto_access) const
261 {
262  bool result;
263 
264  // Preconditions:
265 
266  require(state_is_auto_read_accessible(xauto_access));
267 
268  // Body:
269 
270  result =
271  contains_path<P>(xpath, xauto_access) &&
272  member_poset(xpath, xauto_access).state_is_auto_read_accessible(xauto_access);
273 
274  // Postconditions:
275 
276  // Exit:
277 
278  return result;
279 }
280 
281 template<typename P>
282 bool
284 path_is_available(const poset_path& xpath, bool xauto_access) const
285 {
286  bool result;
287 
288  // Preconditions:
289 
290  require(state_is_auto_read_accessible(xauto_access));
291 
292  // Body:
293 
294  result = !contains_path(xpath, xauto_access) || contains_path<P>(xpath, xauto_access);
295 
296  // Postconditions:
297 
298  // Exit:
299 
300  return result;
301 }
302 
303 template<typename P>
304 bool
306 path_is_auto_read_write_accessible(const poset_path& xpath, bool xauto_access) const
307 {
308  bool result;
309 
310  // Preconditions:
311 
312  require(state_is_auto_read_accessible(xauto_access));
313 
314  // Body:
315 
316  result =
317  contains_path<P>(xpath, xauto_access) &&
318  member_poset(xpath, xauto_access).state_is_auto_read_write_accessible(xauto_access);
319 
320  // Postconditions:
321 
322  // Exit:
323 
324  return result;
325 }
326 
327 template<typename P>
328 bool
330 path_is_auto_read_available(const poset_path& xpath, bool xauto_access) const
331 {
332  bool result;
333 
334  // Preconditions:
335 
336  require(state_is_auto_read_accessible(xauto_access));
337 
338  // Body:
339 
340  result = !contains_path(xpath, xauto_access);
341 
342  if(!result)
343  {
344  P* lhost = dynamic_cast<P*>(&member_poset(xpath, xauto_access));
345  result = (lhost != 0) && lhost->state_is_auto_read_accessible(xauto_access);
346  }
347 
348  // Postconditions:
349 
350  // Exit:
351 
352  return result;
353 }
354 
355 template<typename P>
356 bool
358 path_is_auto_read_write_available(const poset_path& xpath, bool xauto_access) const
359 {
360  bool result;
361 
362  // Preconditions:
363 
364  require(state_is_auto_read_accessible(xauto_access));
365 
366  // Body:
367 
368  result = !contains_path(xpath, xauto_access);
369 
370  if(!result)
371  {
372  P* lhost = dynamic_cast<P*>(&member_poset(xpath, xauto_access));
373  result = (lhost != 0) && lhost->state_is_auto_read_write_accessible(xauto_access);
374  }
375 
376  // Postconditions:
377 
378  // Exit:
379 
380  return result;
381 }
382 
383 // PROTECTED FUNCTIONS
384 
385 // PRIVATE FUNCTIONS
386 
387 
388 // ===========================================================
389 // STATE FACET
390 // ===========================================================
391 
392 // PUBLIC FUNCTIONS
393 
394 // PROTECTED FUNCTIONS
395 
396 // PRIVATE FUNCTIONS
397 
398 
399 // ===========================================================
400 // GLOBAL ATTRIBUTES FACET
401 // ===========================================================
402 
403 // PUBLIC FUNCTIONS
404 
405 // PROTECTED FUNCTIONS
406 
407 // PRIVATE FUNCTIONS
408 
409 
410 // ===========================================================
411 // SCHEMA FACET
412 // ===========================================================
413 
414 // PUBLIC FUNCTIONS
415 
416 // PROTECTED FUNCTIONS
417 
418 // PRIVATE FUNCTIONS
419 
420 
421 // ===========================================================
422 // MEMBERSHIP FACET
423 // ===========================================================
424 
425 // PUBLIC FUNCTIONS
426 
427 // PROTECTED FUNCTIONS
428 
429 // PRIVATE FUNCTIONS
430 
431 
432 // ===========================================================
433 // I/O SUPPORT FACET
434 // ===========================================================
435 
436 // PUBLIC FUNCTIONS
437 
438 // PROTECTED FUNCTIONS
439 
440 // PRIVATE FUNCTIONS
441 
442 
443 // ===========================================================
444 // DEBUGGING FACET
445 // ===========================================================
446 
447 // PUBLIC FUNCTIONS
448 
449 // PROTECTED FUNCTIONS
450 
451 // PRIVATE FUNCTIONS
452 
453 
454 // ===========================================================
455 // ANY FACET
456 // ===========================================================
457 
458 // PUBLIC FUNCTIONS
459 
460 // PROTECTED FUNCTIONS
461 
462 // PRIVATE FUNCTIONS
463 
464 
465 #endif // ifndef NAMESPACE_POSET_IMPL_H
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 ...
bool path_is_auto_read_write_available(const poset_path &xpath, bool xauto_access) const
True if the state referred to xpath does not exist or exists and is auto read-write accessible...
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
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.
pod_index_type member_dof_tuple_id(pod_index_type xmbr_hub_id, bool xauto_access) const
The dof tuple hub id of the member with hub id xmbr_hub_id.
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...
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
poset_state_handle * poset_pointer() const
The pointer to the poset associated with this namespace member.
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.
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 namespace_poset_dof_map & row_dof_map(pod_index_type xtuple_hub_id, bool xrequire_write_access=false) const
The map from row dof client_ids to row dof values for dof tuple hub id xtuple_hub_id.
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
virtual void get_read_access() const
Get read access to the state associated with this.
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 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. ...
bool contains_poset(pod_index_type xhub_id, bool xauto_access=true) const
True if this contains a poset with hub id xhub_id..
bool path_is_auto_read_available(const poset_path &xpath, bool xauto_access) const
True if the state referred to xpath does not exist or exists and is auto read accessible.
bool path_is_auto_read_write_accessible(const poset_path &xpath, bool xauto_access) const
True if the state referred to xpath exists and is auto read-write accessible.
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
virtual bool is_jim(pod_index_type xmbr_hub_id, bool xin_current_version=true) const
True if the member with hub id xmbr_hub_id is a jim in the current version (xin_current_version == tr...
A map from schema poset member ids to dof values for namespace_poset members.
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...
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
Definition: scoped_index.h:710