SheafSystem  0.0.0.0
explicit_crg_interval.cc
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 #include "SheafSystem/explicit_crg_interval.h"
22 
23 #include "SheafSystem/assert_contract.h"
24 #include "SheafSystem/explicit_index_space_interval.h"
25 #include "SheafSystem/factory.h"
26 #include "SheafSystem/index_space_family.h"
27 #include "SheafSystem/index_space_iterator.h"
28 
29 // ===========================================================
30 // EXPLICIT_CRG_INTERVAL FACET
31 // ===========================================================
32 
33 // PUBLIC DATA MEMBERS
34 
37 {
38  // Preconditions:
39 
40  // Body:
41 
42  // Postconditions:
43 
44  ensure(invariant());
45  ensure(!is_initialized());
46 }
47 
50 {
51  // Preconditions:
52 
53  // Body:
54 
56  {
58  }
59 
61  {
63  }
64 
65  // Postconditions:
66 
67  // Exit:
68 
69  return;
70 }
71 
72 // PROTECTED DATA MEMBERS
73 
74 // PRIVATE DATA MEMBERS
75 
76 
77 // ===========================================================
78 // CRG_INTERVAL FACET
79 // ===========================================================
80 
81 // PUBLIC DATA MEMBERS
82 
83 // PROTECTED DATA MEMBERS
84 
85 // PRIVATE DATA MEMBERS
86 
87 
88 // ===========================================================
89 // COVER_SET FACET
90 // ===========================================================
91 
92 // PUBLIC DATA MEMBERS
93 
94 // PROTECTED DATA MEMBERS
95 
96 void
99 {
100  // Preconditions:
101 
102  require(id_spaces_initialized());
103  require(local_id_space_initialized());
104  require(!covers_initialized(LOWER));
105 
106  // Body:
107 
110 
112 
113  // Posconditions:
114 
115  ensure(covers_initialized(LOWER));
116 
117  // Exit:
118 
119  return;
120 }
121 
122 void
125 {
126  // Preconditions:
127 
128  require(id_spaces_initialized());
129  require(local_id_space_initialized());
130  require(!covers_initialized(UPPER));
131 
132  // Body:
133 
136 
138 
139  // Posconditions:
140 
141  ensure(covers_initialized(UPPER));
142 
143  // Exit:
144 
145  return;
146 }
147 
148 // PRIVATE DATA MEMBERS
149 
150 
151 // ===========================================================
152 // EXPLICIT COVER SET FACET
153 // ===========================================================
154 
155 // PUBLIC DATA MEMBERS
156 
157 // PROTECTED DATA MEMBERS
158 
159 // PRIVATE DATA MEMBERS
160 
161 
162 // ===========================================================
163 // FACTORY FACET
164 // ===========================================================
165 
166 // PUBLIC DATA MEMBERS
167 
168 const std::string&
170 class_name() const
171 {
172  static const std::string result("explicit_crg_interval");
173  return result;
174 }
175 
176 // PROTECTED DATA MEMBERS
177 
178 // PRIVATE DATA MEMBERS
179 
180 bool
181 sheaf::explicit_crg_interval::
182 make_prototype()
183 {
184  // Preconditions:
185 
186  // Body:
187 
189 
190  interval_factory().insert_prototype(lproto);
191 
192  // Postconditions:
193 
194  // Exit:
195 
196  return true;
197 }
198 
199 
200 // ===========================================================
201 // ANY FACET
202 // ===========================================================
203 
204 // PUBLIC DATA MEMBERS
205 
206 bool
208 is_ancestor_of(const any* other) const
209 {
210 
211  // Preconditions:
212 
213  require(other != 0);
214 
215  // Body:
216 
217  // True if other conforms to this
218 
219  bool result = dynamic_cast<const explicit_crg_interval*>(other) != 0;
220 
221  // Postconditions:
222 
223  return result;
224 }
225 
228 clone() const
229 {
230  // Preconditions:
231 
232  // Body:
233 
235 
236  // Postconditions:
237 
238  ensure(result != 0);
239  ensure(is_same_type(result));
240 
241  // Exit:
242 
243  return result;
244 }
245 
246 bool
248 invariant() const
249 {
250  bool result = true;
251 
252  if(invariant_check())
253  {
254  // Prevent recursive calls to invariant
255 
257 
258  // Must satisfy base class invariant
259 
260  invariance(crg_interval::invariant());
261 
262  // Invariances for this class:
263 
264  // Finished, turn invariant checking back on.
265 
267  }
268 
269  // Exit
270 
271  return result;
272 }
273 
274 // PROTECTED DATA MEMBERS
275 
276 // PRIVATE DATA MEMBERS
277 
278 
279 // ===========================================================
280 // NON-MEMBER FUNCTIONS
281 // ===========================================================
282 
283 size_t
284 sheaf::deep_size(const explicit_crg_interval& xp, bool xinclude_shallow)
285 {
286  size_t result;
287 
288  // Preconditions:
289 
290  // Body:
291 
292  result = xinclude_shallow ? sizeof(xp) : 0;
293 
294  // Postconditions:
295 
296  ensure(result >= 0);
297 
298  // Exit
299 
300  return result;
301 }
302 
virtual const std::string & class_name() const
The name of this class; provided to satisfy factory template.
index_space_family * _id_spaces
The id space family of this interval.
Definition: crg_interval.h:186
virtual bool invariant() const
Class invariant.
pod_index_type _lower_covers_begin
The offset into the id space family for the interval of lower covers.
Definition: crg_interval.h:283
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
bool _lower_covers_initialized
True if and only if the lower cover is initialized.
Definition: crg_interval.h:288
bool _upper_covers_initialized
True if and only if the upper cover is initialized.
Definition: crg_interval.h:298
virtual void initialize_lower_covers()
Initialize the lower covers for this interval.
virtual void initialize_upper_covers()
Initialize the upper covers for this interval.
bool local_id_space_initialized() const
True if local id space has been initialized.
virtual explicit_crg_interval * clone() const
Virtual constructor, makes a new instance of the same type as this.
virtual bool invariant() const
Class invariant.
Abstract base class with useful features for all objects.
Definition: any.h:39
pod_index_type _upper_covers_begin
The offset into the id space family for the interval of upper covers.
Definition: crg_interval.h:293
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.
virtual ~explicit_crg_interval()
Destructor.
const bool UPPER
Selector for upper cover.
Definition: sheaf.h:72
virtual bool is_initialized() const
True if fully initialized.
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
Definition: any.h:97
void delete_space(pod_type xid)
Delete the id space with index xid.
const bool LOWER
Selector for lower cover.
Definition: sheaf.h:67
size_type size() const
The number of members in the member interval.
bool invariant_check() const
True if invariant checking is enabled.
Definition: any.h:79
static factory< crg_interval > & interval_factory()
A factory for making descendants of this class.
bool id_spaces_initialized() const
True if the index space family has been initialized.
virtual pod_type begin(pod_type xlocal_id) const
Beginning id of the space with id xlocal_id.
bool covers_initialized(bool xlower) const
True if and only if the lower (xlower true) or upper (xlower false) covers has been initialized for t...
SHEAF_DLL_SPEC bool is_valid(pod_index_type xpod_index)
True if an only if xpod_index is valid.
Definition: pod_types.cc:37
explicit_crg_interval()
Default Constructor; constructs an uninitialized interval.
bool is_same_type(const any *other) const
True if other is the same type as this.
Definition: any.cc:79
void enable_invariant_check() const
Enable invariant checking.
Definition: any.h:87
static const explicit_index_space_interval & new_space(index_space_family &xid_spaces, size_type xub)
Create a new interval of id spaces for explicit id spaces in the id space family xid_spaces with uppe...
Implementation of crg_interval for explicit members of the poset.