SheafSystem  0.0.0.0
tuple.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 
22 #ifndef TUPLE_IMPL_H
23 #define TUPLE_IMPL_H
24 
25 #ifndef SHEAF_DLL_SPEC_H
26 #include "SheafSystem/sheaf_dll_spec.h"
27 #endif
28 
29 #ifndef TUPLE_H
30 #include "SheafSystem/tuple.h"
31 #endif
32 
33 #ifndef FIBER_BUNDLES_NAMESPACE_H
34 #include "SheafSystem/fiber_bundles_namespace.h"
35 #endif
36 
37 namespace fiber_bundle
38 {
39 
40 // ===========================================================
41 // HOST FACTORY FACET
42 // ===========================================================
43 
44 // PUBLIC MEMBER FUNCTIONS
45 
46 template <typename F>
49 standard_host_path(const std::string& xsuffix)
50 {
51  // Preconditions:
52 
53  require(poset_path::is_valid_name(F::static_class_name()));
54  require(xsuffix.empty() || poset_path::is_valid_name(xsuffix));
55 
56  // Body:
57 
58  poset_path result(F::static_class_name() + xsuffix, "");
59 
60  // Postconditions:
61 
62  ensure(result.poset_name() == F::static_class_name() + xsuffix);
63  ensure(result.member_name().empty());
64 
65  // Exit:
66 
67  return result;
68 }
69 
70 template <typename F>
71 bool
73 standard_host_is_available(namespace_type& xns, const std::string& xsuffix, bool xauto_access)
74 {
75  // Preconditions:
76 
77  require(xns.state_is_auto_read_write_accessible(xauto_access));
78 
79  require(poset_path::is_valid_name(F::static_class_name()));
80  require(xsuffix.empty() || poset_path::is_valid_name(xsuffix));
81 
82  // Body:
83 
84  if(xauto_access)
85  {
86  xns.get_read_access();
87  }
88 
89  poset_path lpath = standard_host_path<F>(xsuffix);
90 
91  bool result =
92  !xns.contains_poset(lpath, false) ||
93  xns.contains_poset<typename F::host_type>(lpath, false);
94 
95  if(xauto_access)
96  {
97  xns.release_access();
98  }
99 
100  // Postconditions:
101 
102  // Exit:
103 
104  return result;
105 }
106 
107 // PROTECTED MEMBER FUNCTIONS
108 
109 // PRIVATE MEMBER FUNCTIONS
110 
111 } // end namespace fiber_bundle
112 
113 #endif // ifndef TUPLE_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 ...
The standard fiber bundles name space; extends the standard sheaves namespace by defining base space...
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
virtual void get_read_access() const
Get read access to the state associated with this.
bool contains_poset(pod_index_type xhub_id, bool xauto_access=true) const
True if this contains a poset with hub id xhub_id..
static SHEAF_DLL_SPEC bool standard_host_is_available(namespace_type &xns, const std::string &xsuffix, bool xauto_access)
True, if standard_host_path<F>(xsuffix) does not exist or is a path to a poset of type F::host_type...
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
static SHEAF_DLL_SPEC poset_path standard_host_path(const std::string &xsuffix)
The standard path with poset name suffix xsuffix for host spaces for type F.
Namespace for the fiber_bundles component of the sheaf system.
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...