SheafSystem  0.0.0.0
poset_state_handle.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 POSET_STATE_HANDLE_IMPL_H
22 #define POSET_STATE_HANDLE_IMPL_H
23 
24 #ifndef SHEAF_DLL_SPEC_H
25 #include "SheafSystem/sheaf_dll_spec.h"
26 #endif
27 
28 #ifndef POSET_STATE_HANDLE_H
29 #include "SheafSystem/poset_state_handle.h"
30 #endif
31 
32 #ifndef ASSERT_CONTRACT_H
33 #include "SheafSystem/assert_contract.h"
34 #endif
35 
36 #ifndef INDEX_SPACE_ITERATOR_H
37 #include "SheafSystem/index_space_iterator.h"
38 #endif
39 
40 // ===========================================================
41 // POSET_STATE_HANDLE FACET
42 // ===========================================================
43 
44 template<typename handle_type>
45 handle_type&
47 get_cover_id_space(bool xlower, pod_index_type xmbr_index) const
48 {
49  // Preconditions:
50 
51  require(contains_member(xmbr_index));
52  require(unexecutable("handle type conforms to state or is mutable"));
53 
54  // Body:
55 
56  handle_type& result = crg().get_cover_id_space<handle_type>(xlower, xmbr_index);
57 
58  // Postconditions:
59 
60  ensure(result.is_attached());
61 
62  // Exit:
63 
64  return result;
65 }
66 
67 template<typename handle_type>
68 bool
70 cover_id_space_handle_conforms_to(bool xlower, pod_index_type xmbr_index) const
71 {
72  // cout << endl << "Entering poset_state_handle::cover_id_space_handle_conforms_to." << endl;
73 
74  // Preconditions:
75 
76  require(contains_member(xmbr_index));
77 
78  // Body:
79 
80  bool result = crg().cover_id_space_handle_conforms_to<handle_type>(xlower, xmbr_index);
81 
82  // Postconditions:
83 
84 
85  // Exit:
86 
87  // cout << "Leaving poset_state_handle::cover_id_space_handle_conforms_to." << endl;
88  return result;
89 }
90 
91 template<typename filter_type>
92 void
94 remove_cover_members(const filter_type& xfilter, bool xlower, pod_index_type xmbr_hub_id)
95 {
96  // Preconditions:
97 
98  require(contains_member(xmbr_hub_id));
99 
100  // Body:
101 
102  crg().remove_cover_members(xfilter, xlower, xmbr_hub_id);
103 
104  // Postconditions:
105 
106  ensure_for_iterator(index_space_iterator& i=get_cover_id_space_iterator(xlower, xmbr_hub_id),
107  !i.is_done(),
108  i.next(),
109  !xfilter(i.hub_pod()),
111 
112  // Exit:
113 
114  return;
115 }
116 
117 template<typename filter_type>
118 void
120 remove_cover_members(const filter_type& xfilter, bool xlower, const scoped_index& xmbr_id)
121 {
122  // Preconditions:
123 
124  require(contains_member(xmbr_id));
125 
126  // Body:
127 
128  remove_cover_members(xfilter, xlower, xmbr_id.hub_pod());
129 
130  // Postconditions:
131 
132  ensure_for_iterator(index_space_iterator& i=get_cover_id_space_iterator(xlower, xmbr_id),
133  !i.is_done(),
134  i.next(),
135  !xfilter(i.hub_pod()),
137 
138  // Exit:
139 
140  return;
141 }
142 
143 #endif // ifndef POSET_STATE_HANDLE_IMPL_H
void remove_cover_members(const filter_type &xfilter, bool xlower, pod_index_type xmbr_hub_id)
Removes all members for which functor xfilter(xmbr.index().hub_pod()) is true from the lower (xlower ...
index_space_handle & get_cover_id_space(bool xlower, pod_index_type xmbr_index) const
Allocates an handle for the lower (xlower true) or upper (xlower false) cover of member with index xm...
An abstract iterator over the ids of an id space.
index_space_iterator & get_cover_id_space_iterator(bool xlower, pod_index_type xmbr_hub_id) const
Allocates an iterator for the lower (xlower true) or upper (xlower false) cover id space of the membe...
index_space_handle & get_cover_id_space(bool xlower, pod_index_type xmbr_hub_id) const
Allocates a handle for the lower (xlower true) or upper (xlower false) cover id space of the member w...
void remove_cover_members(const filter_type &xfilter, bool xlower, pod_index_type xmbr_index)
Removes all members for which functor xfilter(xmbr.index().top_pod()) is true from the lower (xlower ...
bool is_done() const
True if iteration is finished.
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
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. ...
poset_crg_state & crg() const
The cover relation graph.
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
bool cover_id_space_handle_conforms_to(bool xlower, pod_index_type xmbr_index) const
True if a handle for the lower (xlower true) or upper (xlower false) cover id space of the member wit...
bool cover_id_space_handle_conforms_to(bool xlower, pod_index_type xmbr_index) const
True if a handle for the lower (xlower true) or upper (xlower false) cover id space of the member wit...
void release_cover_id_space_iterator(index_space_iterator &xcover_itr) const
Returns xcover_itr to the pool of id space iterators.
pod_type hub_pod() const
The pod value of this mapped to the unglued hub id space.
Definition: scoped_index.h:710