SheafSystem  0.0.0.0
base_space_factory.impl.h
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 
18 // Implementation for class base_space_factory
19 
20 #ifndef BASE_SPACE_FACTORY_IMPL_H
21 #define BASE_SPACE_FACTORY_IMPL_H
22 
23 #ifndef SHEAF_DLL_SPEC_H
24 #include "SheafSystem/sheaf_dll_spec.h"
25 #endif
26 
27 #ifndef BASE_SPACE_FACTORY_H
28 #include "SheafSystem/base_space_factory.h"
29 #endif
30 
31 #ifndef ASSERT_CONTRACT_H
32 #include "SheafSystem/assert_contract.h"
33 #endif
34 
35 #ifndef ERROR_MESSAGE_H
36 #include "SheafSystem/error_message.h"
37 #endif
38 
39 #ifndef FIBER_BUNDLES_NAMESPACE_H
40 #include "SheafSystem/fiber_bundles_namespace.h"
41 #endif
42 
43 namespace fiber_bundle
44 {
45 
46 // =============================================================================
47 // BASE_SPACE_FACTORY FACET
48 // =============================================================================
49 
51 template <typename base_type>
54 {
55 
56  // Preconditions:
57 
58  // Body:
59 
60  path = "";
61  schema_path = "";
62  local_cell_prototype_path = "";
63  index_ubs = "";
64 
65  // Postconditions:
66 
67  // Exit:
68 
69  return;
70 }
71 
72 
74 template <typename base_type>
77 {
78  // Preconditions:
79 
80  // Body:
81 
82  // Nothing to do.
83 
84  // Postconditions:
85 
86  // Exit:
87 
88  return;
89 }
90 
91 
93 template <typename base_type>
97 {
98  // Preconditions:
99 
100  require(xns.state_is_read_accessible());
101  require(!path.empty());
102  require(poset_path::is_valid_name(path.poset_name()));
103 
104  // Body:
105 
106  base_space_poset* result;
107 
108  if(xns.contains_poset(path, false))
109  {
110  result = dynamic_cast<base_space_poset*>(&xns.member_poset(path, false));
111  }
112  else
113  {
114  result = &base_type::standard_host(xns, path.poset_name(), false);
115  }
116 
117  // Get
118 
119  // Postconditions:
120 
121  ensure(result->path(true) == path);
122 
123  // Exit:
124 
125  return result;
126 }
127 
128 
130 template <typename base_type>
131 base_type*
134 {
135  // Preconditions:
136 
137  require(xns.state_is_read_accessible());
138  require(xbase_path.full());
139 
140  // Body:
141 
142  path = xbase_path.poset_name();
143 
144  base_type* result = new_base(xns, xbase_path.member_name());
145 
146  // Get
147 
148  // Postconditions:
149 
150  ensure(result->path(true) == xbase_path);
151 
152  // Exit:
153 
154  return result;
155 }
156 
157 
159 template <typename base_type>
160 base_type*
162 new_base(fiber_bundles_namespace& xns, const std::string& xbase_name)
163 {
164  // Preconditions:
165 
166  require(xns.state_is_read_accessible());
167  require(poset_path::is_valid_name(xbase_name));
168  require(xns.contains_poset_member(poset_path(path.poset_name(), xbase_name)));
169 
170  // Body:
171 
172  base_type* result = new base_type;
173 
174  poset_path lbase_path(path.poset_name(), xbase_name);
175 
176  result->attach_to_state(&xns, lbase_path);
177 
178  // Get
179 
180  // Postconditions:
181 
182  ensure(result->path() == poset_path(path.poset_name(), xbase_name));
183 
184  // Exit:
185 
186  return result;
187 }
188 
189 
190 
191 
192 // =============================================================================
193 // NON-MEMBER FUNCTIONS
194 // =============================================================================
195 
196 } // namespace fiber_bundle
197 
198 #endif // BASE_SPACE_FACTORY_IMPL_H
virtual poset_path path(bool xauto_access=true) const
The path of this poset.
bool full() const
True if both poset name and member name are not empty.
Definition: poset_path.cc:311
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
The standard fiber bundles name space; extends the standard sheaves namespace by defining base space...
bool contains_poset_member(pod_index_type xposet_hub_id, pod_index_type xmember_hub_id, bool xauto_access=true) const
True if this contains a poset with hub id xposet_hub_id which contains a member with hub id xmember_h...
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
base_space_poset * new_space(fiber_bundles_namespace &xns)
Finds or creates the base space poset specified by path in namespace xns.
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 lattice of closed cells of a cellular space; a lattice representation of a computational mesh...
std::string poset_name() const
The poset name part of the path.
Definition: poset_path.cc:473
bool contains_poset(pod_index_type xhub_id, bool xauto_access=true) const
True if this contains a poset with hub id xhub_id..
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
Namespace for the fiber_bundles component of the sheaf system.
base_type * new_base(fiber_bundles_namespace &xns, const poset_path &xbase_path)
Finds or creates the base space specified by xbase_path in namespace xns.