SheafSystem  0.0.0.0
crg_interval.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 CRG_INTERVAL_H
22 #define CRG_INTERVAL_H
23 
24 #ifndef SHEAF_DLL_SPEC_H
25 #include "SheafSystem/sheaf_dll_spec.h"
26 #endif
27 
28 #ifndef BLOCK_H
29 #include "SheafSystem/block.h"
30 #endif
31 
32 #ifndef PRIMARY_INDEX_SPACE_HANDLE_H
33 #include "SheafSystem/primary_index_space_handle.h"
34 #endif
35 
36 #ifndef SCOPED_INDEX_H
37 #include "SheafSystem/scoped_index.h"
38 #endif
39 
40 #ifndef STD_IOSTREAM_H
41 #include "SheafSystem/std_iostream.h"
42 #endif
43 
44 #ifndef STD_STRING_H
45 #include "SheafSystem/std_string.h"
46 #endif
47 
48 
49 namespace sheaf
50 {
51 
52 template <typename T>
53 class factory;
54 
55 class poset_state_handle;
56 class namespace_poset;
57 
58 // Forward declarations to support friend declaration.
59 
60 class crg_interval;
61 
65 std::ostream& operator <<(std::ostream& os, const crg_interval& m);
66 
70 class SHEAF_DLL_SPEC crg_interval : public any
71 {
72 
73  friend std::ostream& operator <<(std::ostream& os, const crg_interval& m);
74  friend SHEAF_DLL_SPEC size_t deep_size(const crg_interval& xp, bool xinclude_shallow);
75  friend class poset_crg_state; // uses cover_name
76 
77  // ===========================================================
79  // ===========================================================
81 
82 public:
83 
87  crg_interval();
88 
92  virtual ~crg_interval();
93 
94 protected:
95 
96 private:
97 
99 
100 
101  // ===========================================================
103  // ===========================================================
105 
106 public:
107 
112  pod_index_type begin() const;
113 
118  void begin(scoped_index& result) const;
119 
123  pod_index_type end() const;
124 
128  void end(scoped_index& result) const;
129 
133  size_type size() const;
134 
139  bool contains_member(pod_index_type xindex) const;
140 
145  bool contains_member(const scoped_index& xindex) const;
146 
147 protected:
148 
149 private:
150 
152 
153 
154  // ===========================================================
156  // ===========================================================
158 
159 public:
160 
164  const index_space_family& id_spaces() const;
165 
169  const hub_index_space_handle& hub_id_space() const;
170 
174  void initialize_id_spaces(index_space_family& xid_spaces);
175 
179  bool id_spaces_initialized() const;
180 
181 protected:
182 
187 
192 
193 private:
194 
196 
197 
198  // ===========================================================
200  // ===========================================================
202 
203 public:
204 
209  static std::string local_id_space_name(pod_index_type xindex);
210 
214  const primary_index_space_handle& local_id_space() const;
215 
220  void initialize_local_id_space(const index_space_handle& xlocal_id_space);
221 
225  bool local_id_space_initialized() const;
226 
227 protected:
228 
233 
238 
239 private:
240 
242 
243 
244  // ===========================================================
246  // ===========================================================
248 
249 public:
250 
255  pod_index_type cover_id_space_id(bool xlower, pod_index_type xmbr_index) const;
256 
261  bool covers_initialized(bool xlower) const;
262 
266  void initialize_covers();
267 
268 protected:
269 
273  virtual void initialize_lower_covers() = 0;
274 
278  virtual void initialize_upper_covers() = 0;
279 
284 
289 
294 
299 
300 private:
301 
303 
304 
305  // ===========================================================
307  // ===========================================================
309 
310 public:
311 
316  bool cover_is_explicit(bool xlower, pod_index_type xmbr_index) const;
317 
325  pod_index_type force_explicit_cover(bool xlower,
326  pod_index_type xmbr_index,
327  bool xinitialize = true);
328 
329 protected:
330 
334  static std::string explicit_cover_name(bool xlower, const scoped_index& xmbr_index);
335 
339  static std::string explicit_cover_name(bool xlower, pod_index_type xmbr_index);
340 
344  typedef unordered::unordered_map<pod_index_type, pod_index_type> explicit_cover_map_type;
345 
349  explicit_cover_map_type _explicit_upper_cover_map;
350 
354  explicit_cover_map_type _explicit_lower_cover_map;
355 
359  inline explicit_cover_map_type& explicit_cover_map(bool xlower)
360  {
361  return (xlower ? _explicit_lower_cover_map : _explicit_upper_cover_map);
362  };
363 
367  inline const explicit_cover_map_type& explicit_cover_map(bool xlower) const
368  {
369  return (xlower ? _explicit_lower_cover_map : _explicit_upper_cover_map);
370  };
371 
372 private:
373 
375 
376 
377  // ===========================================================
379  // ===========================================================
381 
382 public:
383 
387  static factory<crg_interval>& interval_factory();
388 
393  static crg_interval* new_interval(const std::string& xname);
394 
399  void initialize(const namespace_poset& xnamespace);
400 
404  virtual bool is_initialized() const;
405 
410  virtual const std::string& class_name() const;
411 
412 protected:
413 
414 private:
415 
417 
418 
419  // ===========================================================
421  // ===========================================================
423 
424 public:
425 
429  virtual bool is_ancestor_of(const any* other) const;
430 
435  virtual crg_interval* clone() const = 0;
436 
440  virtual bool invariant() const;
441 
442 protected:
443 
444 private:
445 
447 };
448 
449 // ===========================================================
450 // NON-MEMBER FUNCTIONS
451 // ===========================================================
452 
457 SHEAF_DLL_SPEC
458 size_t deep_size(const crg_interval& xp, bool xinclude_shallow = true);
459 
460 } // namespace sheaf
461 
462 #endif // ifndef CRG_INTERVAL_H
The data structure representing the cover relation graph of a poset.
index_space_family * _id_spaces
The id space family of this interval.
Definition: crg_interval.h:186
explicit_cover_map_type _explicit_lower_cover_map
The map from ids to explicit lower cover id spaces.
Definition: crg_interval.h:354
The default name space; a poset which contains other posets as members.
pod_index_type _lower_covers_begin
The offset into the id space family for the interval of lower covers.
Definition: crg_interval.h:283
bool _lower_covers_initialized
True if and only if the lower cover is initialized.
Definition: crg_interval.h:288
bool _local_id_space_initialized
True if local id space has been initialized.
Definition: crg_interval.h:237
explicit_cover_map_type & explicit_cover_map(bool xlower)
The lower (xlower true) or upper (xlower false) map to explicit cover id spaces.
Definition: crg_interval.h:359
bool _upper_covers_initialized
True if and only if the upper cover is initialized.
Definition: crg_interval.h:298
An abstract handle to a space of alternate integer identifiers (aliases) for a subset of a hub set of...
primary_index_space_handle _local_id_space
The id space of this interval.
Definition: crg_interval.h:232
explicit_cover_map_type _explicit_upper_cover_map
The map from ids to explicit upper cover id spaces.
Definition: crg_interval.h:349
An implementation of class sum_index_space_handle that has a primary sum id space state...
An implementation of class explicit_index_space_handle that has a primary id space state...
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
Abstract emulator for an interval of cover relation graph members.
Definition: crg_interval.h:70
A factory for instanting descendants of an abstract type T, given the class name of the descendant...
Definition: eval_family.h:49
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
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.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
bool _id_spaces_initialized
True if the id space family has been initialized.
Definition: crg_interval.h:191
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
const explicit_cover_map_type & explicit_cover_map(bool xlower) const
The lower (xlower true) or upper (xlower false) map to explicit cover id spaces; const version...
Definition: crg_interval.h:367
SHEAF_DLL_SPEC std::ostream & operator<<(std::ostream &os, const dof_descriptor_array &p)
Insert dof_descriptor_array& p into ostream& os.
Namespace for the sheaves component of the sheaf system.
Factory and container for a family of id spaces.
unordered::unordered_map< pod_index_type, pod_index_type > explicit_cover_map_type
The type of the explicit cover maps..
Definition: crg_interval.h:344