SheafSystem  0.0.0.0
namespace_poset.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 NAMESPACE_POSET_H
22 #define NAMESPACE_POSET_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 NAMESPACE_POSET_DOF_MAP_H
33 #include "SheafSystem/namespace_poset_dof_map.h"
34 #endif
35 
36 #ifndef NAMESPACE_POSET_SCHEMA_H
37 #include "SheafSystem/namespace_poset_schema.h"
38 #endif
39 
40 #ifndef SCATTERED_INSERTION_INDEX_SPACE_HANDLE_H
41 #include "SheafSystem/scattered_insertion_index_space_handle.h"
42 #endif
43 
44 #ifndef PRIMITIVES_POSET_H
45 #include "SheafSystem/primitives_poset.h"
46 #endif
47 
48 #ifndef PRIMITIVES_POSET_SCHEMA_H
49 #include "SheafSystem/primitives_poset_schema.h"
50 #endif
51 
52 #ifndef STD_IOSTREAM_H
53 #include "SheafSystem/std_iostream.h"
54 #endif
55 
56 namespace sheaf
57 {
58 
59 class namespace_poset_member;
60 class poset_path;
61 class poset;
62 class sheaf_file;
63 class storage_agent;
64 
68 class SHEAF_DLL_SPEC namespace_poset : public poset_state_handle
69 {
70 
71  friend class poset_state_handle;
72  friend class storage_agent;
73 
74  // ===========================================================
76  // ===========================================================
78 
79 public:
80 
84  namespace_poset(const std::string& xname);
85 
89  virtual ~namespace_poset();
90 
91 protected:
92 
97 
102 
106  namespace_poset(const namespace_poset& xother) { };
107 
112  {
113  return const_cast<namespace_poset&>(*this);
114  };
115 
120  {
121  return const_cast<namespace_poset&>(*this);
122  };
123 
124 private:
125 
129  static bool make_prototype();
130 
132 
133  // ===========================================================
135  // ===========================================================
137 
138 public:
139 
144  {
145  return _primitives;
146  };
147 
151  inline const primitives_poset& primitives() const
152  {
153  return _primitives;
154  };
155 
159  static poset_path primitives_schema_path();
160 
165  {
166  return _primitives_schema;
167  };
168 
173  {
174  return _primitives_schema;
175  };
176 
177 protected:
178 
179 private:
180 
184  primitives_poset _primitives;
185 
189  primitives_poset_schema _primitives_schema;
190 
192 
193 
194  // ===========================================================
196  // ===========================================================
198 
199 public:
200 
204  bool contains_poset(pod_index_type xhub_id, bool xauto_access = true) const;
205 
209  bool contains_poset(const scoped_index& xid, bool xauto_access = true) const;
210 
215  template <typename P>
216  SHEAF_DLL_SPEC
217  bool contains_poset(pod_index_type xhub_id, bool xauto_access = true) const;
218 
223  template <typename P>
224  SHEAF_DLL_SPEC
225  bool contains_poset(const scoped_index& id, bool xauto_access = true) const;
226 
230  bool contains_poset(const poset_path& xpath, bool xauto_access = true) const;
231 
236  template <typename P>
237  SHEAF_DLL_SPEC
238  bool contains_poset(const poset_path& xpath, bool xauto_access = true) const;
239 
244  bool owns(const poset_state_handle& xposet, bool xauto_access) const;
245 
250  bool contains_poset_member(pod_index_type xposet_hub_id,
251  pod_index_type xmember_hub_id,
252  bool xauto_access = true) const;
253 
258  bool contains_poset_member(const scoped_index& xposet_id,
259  const scoped_index& xmember_id,
260  bool xauto_access = true) const;
261 
265  bool contains_poset_member(const poset_path& xpath, bool xauto_access = true) const;
266 
271  bool contains_poset_members(const std::string& xposet_name,
272  const std::string xmember_names[],
273  int xmember_names_ct,
274  bool xauto_access = true) const;
275 
279  bool contains_poset_subposet(const poset_path& xpath, bool xauto_access = true) const;
280 
284  poset_state_handle& member_poset(pod_index_type xhub_id, bool xauto_access = true) const;
285 
289  poset_state_handle& member_poset(const scoped_index& xid, bool xauto_access = true) const;
290 
295  template <typename P>
296  SHEAF_DLL_SPEC
297  P& member_poset(pod_index_type xhub_id, bool xauto_access = true) const;
298 
303  template <typename P>
304  SHEAF_DLL_SPEC
305  P& member_poset(const scoped_index& xid, bool xauto_access = true) const;
306 
311  poset_state_handle& member_poset(const poset_path& xpath, bool xauto_access = true) const;
312 
317  template <typename P>
318  SHEAF_DLL_SPEC
319  P& member_poset(const poset_path& xpath, bool xauto_access = true) const;
320 
324  pod_index_type member_poset_schema_id(const scoped_index& xindex, bool xauto_access) const;
325 
329  void delete_poset(pod_index_type xhub_id, bool xauto_access);
330 
334  void delete_poset(scoped_index xid, bool xauto_access);
335 
339  void delete_poset(std::string xname, bool xauto_access);
340 
344  void delete_poset(poset_path xpath, bool xauto_access);
345 
349  void delete_poset(namespace_poset_member& xmbr);
350 
351 protected:
352 
356  scoped_index insert_poset(const poset_state_handle& xposet,
357  const std::string& xposet_name,
358  bool xauto_link);
359 
363  scoped_index insert_poset(const poset_state_handle& xposet,
364  const std::string& xposet_name,
365  bool xauto_link,
366  bool xauto_access);
367 
371  virtual void link_poset(const namespace_poset_member& xmbr);
372 
373 private:
374 
376 
377  // ===========================================================
379  // ===========================================================
381 
382 public:
383 
387  bool contains_path(const poset_path& xpath, bool xauto_access = true) const;
388 
393  template <typename P>
394  bool contains_path(const poset_path& xpath, bool xauto_access = true) const;
395 
399  bool path_is_auto_read_accessible(const poset_path& xpath, bool xauto_access) const;
400 
405  template <typename P>
406  bool path_is_auto_read_accessible(const poset_path& xpath, bool xauto_access) const;
407 
411  bool path_is_auto_read_write_accessible(const poset_path& xpath, bool xauto_access) const;
412 
417  template <typename P>
418  bool path_is_auto_read_write_accessible(const poset_path& xpath, bool xauto_access) const;
419 
424  template <typename P>
425  bool path_is_available(const poset_path& xpath, bool xauto_access) const;
426 
431  bool path_is_auto_read_available(const poset_path& xpath, bool xauto_access) const;
432 
437  template <typename P>
438  bool path_is_auto_read_available(const poset_path& xpath, bool xauto_access) const;
439 
444  bool path_is_auto_read_write_available(const poset_path& xpath, bool xauto_access) const;
445 
450  template <typename P>
451  bool path_is_auto_read_write_available(const poset_path& xpath, bool xauto_access) const;
452 
456  bool poset_state_is_read_accessible(const poset_path& xpath, bool xauto_access = true) const;
457 
461  bool poset_state_is_read_write_accessible(const poset_path& xpath, bool xauto_access = true) const;
462 
463 protected:
464 
465 private:
466 
468 
469 
470  // ===========================================================
472  // ===========================================================
474 
475 public:
476 
480  static namespace_poset* current_namespace();
481 
485  void put_current_namespace(namespace_poset* xns);
486 
487 protected:
488 
489 private:
490 
494  static namespace_poset* _current_namespace;
495 
497 
498 
499  // ===========================================================
501  // ===========================================================
503 
504 public:
505 
509  static void initialize_prototypes();
510 
514  static void initialize_poset_prototypes();
515 
519  static void initialize_crg_interval_prototypes();
520 
524  static void initialize_dof_map_prototypes();
525 
529  static void initialize_id_space_prototypes();
530 
531 protected:
532 
537  virtual void virtual_initialize_prototypes();
538 
539 private:
540 
542 
543 
544  // ===========================================================
546  // ===========================================================
548 
549 public:
550 
554  virtual poset_type type_id() const;
555 
559  virtual const char* class_name() const;
560 
564  virtual void begin_jim_edit_mode(bool xauto_access = true);
565 
569  virtual void end_jim_edit_mode(bool xensure_lattice_invariant = true,
570  bool xauto_access = true);
571 
575  virtual void get_read_access() const;
576 
583  virtual void get_read_write_access(bool xrelease_read_only_access = false);
584 
589  virtual void release_access(bool xall = false) const;
590 
591 protected:
592 
594 
598  void new_state(const std::string& xname);
599 
603  virtual void detach_from_state();
604 
609  virtual void attach_handle_data_members();
610 
611 private:
612 
614 
615 
616  // ===========================================================
618  // ===========================================================
620 
621 public:
622 
626  virtual std::string name() const;
627 
631  virtual std::string name(bool xauto_access) const;
632 
636  virtual poset_path path(bool xauto_access = true) const;
637 
638 protected:
639 
641 
645  virtual void initialize_namespace(namespace_poset& xns, bool xauto_link = true);
646 
647 private:
648 
650 
651 
652  // ===========================================================
654  // ===========================================================
656 
657 public:
658 
663 
668  {
669  return _namespace_schema;
670  };
671 
676  {
677  return _namespace_schema;
678  };
679 
684  virtual bool row_dof_map_conforms(const poset_dof_map* xdof_map) const;
685 
690  virtual namespace_poset_dof_map& row_dof_map(pod_index_type xtuple_hub_id,
691  bool xrequire_write_access = false) const;
692 
696  virtual const scoped_index& new_row_dof_map();
697 
698 protected:
699 
704 
705 private:
706 
708 
709 
710  // ===========================================================
712  // ===========================================================
714 
715 public:
716 
720  namespace_poset_member& top();
721 
725  const namespace_poset_member& top() const;
726 
730  namespace_poset_member& bottom();
731 
735  const namespace_poset_member& bottom() const;
736 
740  void clear();
741 
742 protected:
743 
747  virtual void initialize_standard_members();
748 
752  virtual void initialize_additional_members();
753 
754 private:
755 
757 
758  // ===========================================================
760  // ===========================================================
762 
763 public:
764 
769  const index_space_handle& get_member_poset_id_space(bool xauto_access) const;
770 
775  void release_member_poset_id_space(index_space_handle& xid_space, bool xauto_access) const;
776 
781  index_space_iterator& get_member_poset_id_space_iterator(bool xauto_access) const;
782 
787  void release_member_poset_id_space_iterator(index_space_iterator& xid_space, bool xauto_access) const;
788 
789 protected:
790 
794  void initialize_member_poset_id_space();
795 
796 private:
797 
799 
800 
801  // ===========================================================
803  // ===========================================================
805 
806 public:
807 
811  virtual pod_index_type prereq_id(int xi) const;
812 
813 protected:
814 
819  void put_name(const std::string& xname);
820 
821 private:
822 
824 
825 
826  // ===========================================================
828  // ===========================================================
830 
831 public:
832 
836  void to_stream(std::ostream& xos = std::cout);
837 
838 
842  std::string to_string();
843 
844 protected:
845 
846 private:
847 
849 
850 
851  // ===========================================================
853  // ===========================================================
855 
856 public:
857 
861  virtual bool is_ancestor_of(const any* other) const;
862 
867  namespace_poset* clone() const;
868 
872  bool invariant() const;
873 
874 protected:
875 
876 private:
877 
879 };
880 
881 
882 // ===========================================================
883 // NON-MEMBER FUNCTIONS
884 // ===========================================================
885 
889 SHEAF_DLL_SPEC
890 std::ostream & operator << (std::ostream &os, const namespace_poset& p);
891 
895 SHEAF_DLL_SPEC
896 size_t deep_size(const namespace_poset& xp, bool xinclude_shallow = true, size_t xresults[4] = 0);
897 
898 } // namespace sheaf
899 
900 #endif // ifndef NAMESPACE_POSET_H
The schema poset for the namespace.
const namespace_poset_schema & namespace_schema() const
The namespace poset schema within this namespace (const version)
const primitives_poset & primitives() const
The poset of primitives this namespace (const version)
An abstract iterator over the ids of an id space.
namespace_poset_schema & namespace_schema()
The namespace poset schema within this namespace (mutable version)
The default name space; a poset which contains other posets as members.
poset_type
Identifiers for poset types.
Definition: poset_type.h:41
A client handle for a general, abstract partially order set.
namespace_poset & operator=(const poset_state_handle &xother)
Assignment operator; disabled.
primitives_poset & primitives()
The poset of primitives for this namespace (mutable version)
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
An abstract handle to a space of alternate integer identifiers (aliases) for a subset of a hub set of...
The general, abstract map from dof ids to dof values.
Definition: poset_dof_map.h:59
primitives_poset_schema & primitives_schema()
The schema poset for the primitives poset (mutable version)
A client handle for a member of a namespace poset.
The poset containing the primitive type definitions.
Abstract base class with useful features for all objects.
Definition: any.h:39
virtual void initialize_namespace(namespace_poset &xns, const std::string &xposet_name, bool xauto_link=true)
Installs this as a member of xns. If xauto_link, automatically links the member into an appropriate g...
namespace_poset(const namespace_poset &xother)
Copy constructor; disabled.
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.
The schema poset for the primitives.
namespace_poset_schema schema_type
The type of schema member for this class.
namespace_poset & operator=(const namespace_poset &xother)
Assignment operator; disabled.
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
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.
const primitives_poset_schema & primitives_schema() const
The schema poset for the primitives poset (const version)
A map from schema poset member ids to dof values for namespace_poset members.
void new_state(namespace_poset &xns, const poset_path &xpath, const schema_poset_member &xschema, array_poset_dof_map &xdof_map)
Creates a new poset state with schema xschema and table dof map xdof_map, attaches this to the state ...
namespace_poset_schema _namespace_schema
The schema poset for this namespace.
Agent responsible for importing and exporting posets from an external name space which resides on dis...
Definition: storage_agent.h:74