SheafSystem  0.0.0.0
poset_slicer.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 // Interface for class POSET_SLICER
19 
20 #ifndef POSET_SLICER_H
21 #define POSET_SLICER_H
22 
23 #ifndef SHEAF_DLL_SPEC_H
24 #include "SheafSystem/sheaf_dll_spec.h"
25 #endif
26 
27 #ifndef POSET_DFT_H
28 #include "SheafSystem/poset_dft.h"
29 #endif
30 
31 namespace sheaf
32 {
33 
34 class abstract_poset_member;
35 class subposet;
36 class total_poset_member;
37 
45 class SHEAF_DLL_SPEC poset_slicer: public poset_dft
46 {
47 
48  friend class poset_state_handle;
49  friend class abstract_poset_member;
50 
51 
52 public:
53 
57  enum slice_mode { MAXIMAL, MINIMAL, ALL };
58 
59  // queries:
60 
64  virtual bool invariant() const;
65 
66  // constructors:
67 
71  poset_slicer(const poset_state_handle* xhost);
72 
76  ~poset_slicer();
77 
78  // Action
79 
84  subposet* find(abstract_poset_member* xanchor,
85  subposet* xlayer,
86  bool xdown,
87  slice_mode xmode = ALL);
88 
93  void find_pa(abstract_poset_member* xanchor,
94  subposet* xlayer,
95  bool xdown,
96  subposet* result,
97  slice_mode xmode = ALL);
98 
103  subposet* find(subposet* xanchor, subposet* xlayer, bool xdown, slice_mode xmode = ALL);
104 
109  void find_pa(const subposet* xanchor, subposet* xlayer, bool xdown, subposet* result, slice_mode xmode = ALL);
110 
114  subposet* find_jims(abstract_poset_member* xanchor, slice_mode xmode = ALL);
115 
119  void find_jims_pa(abstract_poset_member* xanchor, subposet* result, slice_mode xmode = ALL);
120 
124  subposet* find_jims(const subposet* xanchor, slice_mode xmode = ALL);
125 
129  void find_jims_pa(const subposet* xanchor, subposet* result, slice_mode xmode = ALL);
130 
134  subposet* down_set(abstract_poset_member* xanchor, slice_mode xmode = ALL);
135 
139  void down_set_pa(abstract_poset_member* xanchor, subposet* result, slice_mode xmode = ALL);
140 
144  subposet* up_set(abstract_poset_member* xanchor, slice_mode xmode = ALL);
145 
149  void up_set_pa(abstract_poset_member* xanchor, subposet* result, slice_mode xmode = ALL);
150 
154  subposet* down_set(const subposet* xanchor, slice_mode xmode = ALL);
155 
159  void down_set_pa(const subposet* xanchor, subposet* result, slice_mode xmode = ALL);
160 
164  subposet* up_set(const subposet* xanchor, slice_mode xmode = ALL);
165 
169  void up_set_pa(const subposet* xanchor, subposet* result, slice_mode xmode = ALL);
170 
171 
172 private:
173 
174  // data:
175 
176  subposet* _layer;
177 
178  // The given subset being interesected with
179  // the down set (up set) of _anchor.
180 
181  subposet* _slice;
182 
183  // The result; the intersection of _layer
184  // with the down set or up set of _anchor
185 
186  slice_mode _mode;
187  // Include only maximal, minimal or all members
188 
189  bool _select_only_shallowest;
190  // True if maximal and going down or minimal and going up
191 
192  bool _select_only_deepest;
193  // True if minimal and going down or maxinal and going up
194 
195  std::stack<bool> _select_enabled;
196  // True if selection enabled
197 
198  int _depth_below_shallowest;
199  int _height_above_deepest;
200 
201 
202  // Actions:
203 
204  void vertical_set_pa(const subposet* xanchor, subposet* result, slice_mode xmode, bool xdown);
205 
206  void previsit_action(abstract_poset_member* xmbr);
207  void link_action(abstract_poset_member* xmbr, abstract_poset_member* linked_mbr);
208  void postvisit_action(abstract_poset_member* xmbr);
209 
211 
212  void find_pa(const block<scoped_index>& xanchor,
213  subposet* xlayer,
214  bool xdown,
215  subposet* result,
216  slice_mode xmode = ALL);
217 
218  inline bool only_shallowest();
219  inline bool only_deepest();
220  inline bool layer_contains_member(const abstract_poset_member* xmbr);
221  inline bool slice_contains_member(abstract_poset_member* xmbr);
222  inline void insert_member(abstract_poset_member* xmbr);
223 
224 
225 
226 
227 };
228 
229 } // namespace sheaf
230 
231 #endif // ifndef POSET_SLICER_H
A client handle for a subposet.
Definition: subposet.h:86
A client handle for a general, abstract partially order set.
slice_mode
Include only maximal, minimal, or all members in slice.
Definition: poset_slicer.h:57
Namespace for the sheaves component of the sheaf system.
An abstract client handle for a member of a poset.
Traverser to compute intersection of the down set (up set) of the anchor with a given subposet...
Definition: poset_slicer.h:45
Abstract traverser (internal iterator) for poset which traverses the cover relation graph in depth fi...
Definition: poset_dft.h:44