SheafSystem  0.0.0.0
poset_path.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_path
19 
20 #ifndef POSET_PATH_H
21 #define POSET_PATH_H
22 
23 #ifndef SHEAF_DLL_SPEC_H
24 #include "SheafSystem/sheaf_dll_spec.h"
25 #endif
26 
27 #ifndef STD_IOSTREAM_H
28 #include "SheafSystem/std_iostream.h"
29 #endif
30 
31 #ifndef STD_STRING_H
32 #include "SheafSystem/std_string.h"
33 #endif
34 
35 
36 namespace sheaf
37 {
38 
39  class namespace_poset;
40  class primitive_value;
41 
42 
48 class SHEAF_DLL_SPEC poset_path
49 {
50 
51 public:
52 
56  poset_path();
57 
61  poset_path(const poset_path& xposet_path);
62 
67  poset_path(const std::string& xposet_name, const std::string& xmember_name);
68 
72  ~poset_path();
73 
77  poset_path(const std::string& xpath);
78 
82  poset_path(const char* xpath);
83 
87  poset_path(const primitive_value& xpath);
88 
92  operator primitive_value() const;
93 
97  poset_path& operator=(const poset_path& xposet_path);
98 
102  poset_path& operator=(const std::string& xpath);
103 
107  poset_path& operator=(const char* cpath);
108 
112  poset_path& operator=(const primitive_value& xpath);
113 
117  bool empty() const;
118 
122  bool full() const;
123 
128  static bool is_valid_name(const std::string& xname);
129 
136  static bool is_valid_path(const std::string& xpath);
137 
141  bool operator==(const poset_path& xother) const;
142 
146  bool operator==(const std::string& xother) const;
147 
151  bool operator==(const char* xother) const;
152 
156  std::string path() const;
157 
161  std::string poset_name() const;
162 
166  void put_poset_name(const std::string& xname);
167 
171  std::string member_name() const;
172 
176  void put_member_name(const std::string& xname);
177 
181  static const std::string& name_legal_characters();
182 
186  static char delimiter();
187 
191  static const std::string& path_legal_characters();
192 
196  static std::string poset_name(const std::string& xpath);
197 
201  static std::string delimiter(const std::string& xpath);
202 
206  static std::string member_name(const std::string& xpath);
207 
211  void to_stream(std::ostream& xos = std::cout) const;
212 
216  static std::string make_name(const std::string& xprefix, int xindex, const std::string& xsuffix);
217 
221  static std::string make_reserved_name(const std::string& xprefix, const size_t& xindex, const std::string& xsuffix);
222 
226  static std::string block_name(const size_t& xindex);
227 
232  static std::string block_name(const std::string& xneighborhood_name);
233 
237  static std::string block_neighborhood_name(const size_t& xindex);
238 
243  static std::string block_neighborhood_name(const std::string& xblock_name);
244 
248  static size_t block_id(const std::string& xname);
249 
253  static std::string reserved_prefix();
254 
258  static std::string boundary_prefix();
259 
264  static std::string boundary_name(const std::string& xmbr_name);
265 
269  static std::string block_prefix();
270 
274  static std::string neighborhood_prefix();
275 
281  namespace_poset* current_namespace() const;
282 
288  bool state_exists(bool xauto_access) const;
289 
295  bool poset_exists(bool xauto_access) const;
296 
302  bool member_exists(bool xauto_access) const;
303 
308  bool state_is_read_accessible(bool xauto_access) const;
309 
314  bool state_is_read_write_accessible(bool xauto_access) const;
315 
320  bool conforms_to(const poset_path& xother, bool xauto_access) const;
321 
326  bool conforms_to(const namespace_poset& xns, const poset_path& xother, bool xauto_access) const;
327 
328 
329 private:
330 
334  std::string _poset_name;
335 
339  std::string _member_name;
340 
341 // ///
342 // /// True if xname contains only path legal characters.
343 // ///
344 // static bool contains_legal_characters(const std::string& xname, const std::string& xlegal_chars);
345 
349  static void parse_path(const std::string& xpath,
350  std::string& xposet_name,
351  std::string& xdelimiter,
352  std::string& xmember_name);
353 
354 
355 };
356 
357 //==============================================================================
358 // NON-MEMBER FUNCTIONS
359 //==============================================================================
360 
364 SHEAF_DLL_SPEC
365 std::ostream & operator << (std::ostream& os, const poset_path& pp);
366 
370 SHEAF_DLL_SPEC
371 bool operator==(const poset_path& xpath, const primitive_value& xprim);
372 
376 SHEAF_DLL_SPEC
377 bool operator==(const primitive_value& xprim, const poset_path& xpath);
378 
383 size_t
384 SHEAF_DLL_SPEC
385 deep_size(const poset_path& xpath, bool xinclude_shallow = true);
386 
387 
388 } // namespace sheaf
389 
390 #endif // ifndef POSET_PATH_H
The default name space; a poset which contains other posets as members.
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
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.
bool operator==(const singly_linked_list< T, Alloc > &lhs, const singly_linked_list< T, Alloc > &rhs)
Checks if the contents of lhs and rhs are equal, that is, whether lhs.size() == rhs.size() and each element in lhs compares equal with the element in rhs at the same position.
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.
Abstract object wrapper for an instance of a primitive type.