SheafSystem  0.0.0.0
poset_scaffold.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_SCAFFOLD_H
22 #define POSET_SCAFFOLD_H
23 
24 #ifndef SHEAF_DLL_SPEC_H
25 #include "SheafSystem/sheaf_dll_spec.h"
26 #endif
27 
28 #ifndef ANY_H
29 #include "SheafSystem/any.h"
30 #endif
31 
32 #ifndef ARG_LIST_H
33 #include "SheafSystem/arg_list.h"
34 #endif
35 
36 #ifndef AUTO_BLOCK_H
37 #include "SheafSystem/auto_block.h"
38 #endif
39 
40 #ifndef INTERVAL_INDEX_SPACE_HANDLE_H
41 #include "SheafSystem/interval_index_space_handle.h"
42 #endif
43 
44 #ifndef NAME_MULTIMAP_H
45 #include "SheafSystem/name_multimap.h"
46 #endif
47 
48 #ifndef RECORD_MAP_H
49 #include "SheafSystem/record_map.h"
50 #endif
51 
52 #ifndef POSET_STATE_HANDLE_H
53 #include "SheafSystem/poset_state_handle.h"
54 #endif
55 
56 #ifndef POSET_DATA_TYPE_MAP_H
57 #include "SheafSystem/poset_data_type_map.h"
58 #endif
59 
60 #ifndef RECORD_QUEUE_H
61 #include "SheafSystem/record_queue.h"
62 #endif
63 
64 #ifndef SCHEMA_POSET_MEMBER_H
65 #include "SheafSystem/schema_poset_member.h"
66 #endif
67 
68 #ifndef STD_UNORDERED_MAP_H
69 #include "SheafSystem/std_unordered_map.h"
70 #endif
71 
72 #ifndef STD_VECTOR_H
73 #include "SheafSystem/std_vector.h"
74 #endif
75 
76 #ifndef STORAGE_AGENT_H
77 #include "SheafSystem/storage_agent.h"
78 #endif
79 
80 namespace sheaf
81 {
82 
83 class poset_bounds;
84 class subposet;
85 class namespace_poset;
86 
93 class SHEAF_DLL_SPEC poset_scaffold : public any
94 {
95 
96  // ===========================================================
98  // ===========================================================
100 
101 public:
102 
106  poset_scaffold(const poset_scaffold& xother);
107 
111  virtual ~poset_scaffold();
112 
117  poset_scaffold(const poset_state_handle& xposet,
118  const storage_agent::transaction& xtrans,
119  data_type_map& xtype_map,
120  const std::string& xfile_id_space_name,
121  bool xis_write_transaction);
122 
128  poset_state_handle& structure();
129 
135  const poset_state_handle& structure() const;
136 
140  poset_powerset_state& powerset();
141 
145  const poset_powerset_state& powerset() const;
146 
150  poset_table_state& table();
151 
155  const poset_table_state& table() const;
156 
160  bool is_write_transaction() const;
161 
165  poset_bounds& row_bounds();
166 
170  const poset_bounds& row_bounds() const;
171 
175  poset_bounds& col_bounds();
176 
180  const poset_bounds& col_bounds() const;
181 
185  const poset_bounds& toc_bounds() const;
186 
191  void update_toc_bounds(const poset_bounds_descriptor& xdesc);
192 
197  void evaluate_toc_alias();
198 
202  subposet& resident();
203 
207  const subposet& resident() const;
208 
212  namespace_poset* name_space() const;
213 
217  bool structure_is_namespace() const;
218 
222  scoped_index index() const;
223 
227  std::string name() const;
228 
232  schema_poset_member& internal_schema();
233 
237  const schema_poset_member& internal_schema() const;
238 
242  schema_poset_member& transfer_schema();
243 
247  const schema_poset_member& transfer_schema() const;
248 
252  schema_poset_member& external_schema();
253 
257  const schema_poset_member& external_schema() const;
258 
262  poset_data_type_map& type_map();
263 
267  const poset_data_type_map& type_map() const;
268 
272  const std::string& file_id_space_name() const;
273 
277  bool& is_versioned();
278 
282  const bool& is_versioned() const;
283 
288  void initialize_schema_for_read(schema_poset_member* xext_schema,
289  int xschema_version);
290 
295  void initialize_transfer_schema_for_read(const scoped_index& xindex);
296 
300  void insert_id_name_pair(pod_index_type xid, const std::string& xname, block<char>& xbuf);
301 
305  void extract_id_name_pair(pod_index_type& xid, std::string& xname, char*& xbuf);
306 
310  void get_member_names_from_poset();
311 
316  void put_member_names_to_poset();
317 
318 protected:
319 
320 private:
321 
323 
327  poset_state_handle& _structure;
328 
332  bool _is_write_transaction;
333 
337  poset_bounds* _row_bounds;
338 
342  poset_bounds* _col_bounds;
343 
347  poset_bounds* _toc_bounds;
348 
352  subposet _resident;
353 
357  schema_poset_member* _internal_schema;
358 
363  schema_poset_member* _transfer_schema;
364 
368  schema_poset_member* _external_schema;
369 
374  void initialize_schema_for_write();
375 
379  poset_data_type_map _type_map;
380 
384  std::string _file_id_space_name;
385 
389  bool _is_versioned;
390 
392 
393 
394  // ===========================================================
396  // ===========================================================
398 
399 public:
400 
405 
410 
411  // The following features are logically members
412  // of class member_record, but are placed here so they
413  // will only be initialized once per poset, rather than
414  // once per member record.
415 
419  void put_member_record_type_aliases(int xtoc_index,
420  int xdof_tuple_id_index,
421  int xoffset_index);
422 
426  void initialize_member_id_space();
427 
431  bool member_id_space_initialized() const;
432 
436  scoped_index member_ext_id(const scoped_index& xid) const;
437 
441  scoped_index member_ext_id(pod_index_type xid) const;
442 
446  member_index_space_type& member_id_space();
447 
451  const member_index_space_type& member_id_space() const;
452 
456  member_name_map_type& member_name_map();
457 
461  const member_name_map_type& member_name_map() const;
462 
466  typedef unordered::unordered_map<pod_index_type, std::pair<std::string, size_type> > member_class_names_type;
467 
471  member_class_names_type& member_class_names();
472 
476  const member_class_names_type& member_class_names() const;
477 
482  void convert_member_id_to_record_id(void *buf);
483 
488  void convert_record_id_to_member_id(void *buf);
489 
490 protected:
491 
492 private:
493 
497  member_index_space_type _member_id_space;
498 
502  member_name_map_type _member_name_map;
503 
507  member_class_names_type _member_class_names;
508 
510 
511 
512  // ===========================================================
514  // ===========================================================
516 
517 public:
518 
523 
527  void initialize_subposet_id_space();
528 
532  bool subposet_id_space_initialized() const;
533 
537  scoped_index subposet_ext_id(const scoped_index& xid) const;
538 
542  scoped_index subposet_ext_id(pod_index_type xid) const;
543 
547  subposet_index_space_type& subposet_id_space();
548 
552  const subposet_index_space_type& subposet_id_space() const;
553 
557  std::vector<subposet*>& subposets();
558 
562  const std::vector<subposet*>& subposets() const;
563 
568  void convert_subposet_id_to_record_id(void* xbuf);
569 
574  void convert_record_id_to_subposet_id(void* xbuf);
575 
576 protected:
577 
578 private:
579 
583  subposet_index_space_type _subposet_id_space;
584 
588  std::vector<subposet*> _subposets;
589 
593  void initialize_subposets();
594 
596 
597 
598  // ===========================================================
600  // ===========================================================
602 
603 public:
604 
609 
613  void initialize_dof_tuple_id_space();
614 
618  bool dof_tuple_id_space_initialized() const;
619 
623  scoped_index dof_tuple_ext_id(const scoped_index& xid) const;
624 
628  scoped_index dof_tuple_ext_id(pod_index_type xid) const;
629 
633  dof_tuple_index_space_type& dof_tuple_id_space();
634 
638  const dof_tuple_index_space_type& dof_tuple_id_space() const;
639 
643  pod_index_type dof_tuple_scratch_id() const;
644 
648  void put_dof_tuple_scratch_id(pod_index_type xid);
649 
653  typedef unordered::unordered_map<pod_index_type, dof_tuple_type> dof_tuple_types_type;
654 
658  dof_tuple_types_type& dof_tuple_types();
659 
663  const dof_tuple_types_type& dof_tuple_types() const;
664 
668  typedef unordered::unordered_map<pod_index_type, std::string> dof_tuple_class_names_type;
669 
673  dof_tuple_class_names_type& dof_tuple_class_names();
674 
678  const dof_tuple_class_names_type& dof_tuple_class_names() const;
679 
683  typedef unordered::unordered_map<pod_index_type, int> dof_tuple_schema_versions_type;
684 
688  dof_tuple_schema_versions_type& dof_tuple_schema_versions();
689 
693  const dof_tuple_schema_versions_type& dof_tuple_schema_versions() const;
694 
699  bool dof_tuple_schema_versions_contains(pod_index_type xdof_tuple_ext_id) const;
700 
705  int dof_tuple_schema_version(pod_index_type xext_id) const;
706 
710  typedef unordered::unordered_map<pod_index_type, pod_index_type> dof_tuple_schema_ids_type;
711 
715  dof_tuple_schema_ids_type& dof_tuple_schema_ids();
716 
720  const dof_tuple_schema_ids_type& dof_tuple_schema_ids() const;
721 
726  bool dof_tuple_schema_ids_contains(pod_index_type xdof_tuple_ext_id) const;
727 
731  pod_index_type dof_tuple_schema_id(pod_index_type xdof_tuple_ext_id) const;
732 
736  pod_index_type dof_tuple_schema_int_id(pod_index_type xdof_tuple_ext_id) const;
737 
741  typedef unordered::unordered_map<pod_index_type, poset_bounds_descriptor>
743 
747  dof_tuple_col_bounds_type& dof_tuple_col_bounds();
748 
752  const dof_tuple_col_bounds_type& dof_tuple_col_bounds() const;
753 
758  bool dof_tuple_col_bounds_contains(pod_index_type xdof_tuple_ext_id) const;
759 
764  const poset_bounds_descriptor& dof_tuple_col_bound(pod_index_type xdof_tuple_ext_id) const;
765 
771  void put_dof_tuple_col_bound(pod_index_type xdof_tuple_ext_id);
772 
776  void translate_dof_tuple_col_bounds();
777 
778  // Note: dof_tuple_domain_offsets uses map rather than unordered_map
779  // because there is no default hash function for pairs.
780  // Best case performance is not as good as unordered_map, but
781  // should be adequate.
782 
786  typedef std::map<std::pair<pod_index_type, pod_index_type>, pod_index_type>
788 
792  dof_tuple_domain_offsets_type& dof_tuple_domain_offsets();
793 
797  const dof_tuple_domain_offsets_type& dof_tuple_domain_offsets() const;
798 
803  bool dof_tuple_domain_offsets_contains(pod_index_type xdof_tuple_ext_id,
804  pod_index_type xdomain_key) const;
808  pod_index_type dof_tuple_domain_offset(pod_index_type xdof_tuple_ext_id,
809  pod_index_type xdomain_key) const;
810 
811 protected:
812 
813 private:
814 
818  dof_tuple_index_space_type _dof_tuple_id_space;
819 
823  pod_index_type _dof_tuple_scratch_id;
824 
828  dof_tuple_types_type _dof_tuple_types;
829 
833  dof_tuple_class_names_type _dof_tuple_class_names;
834 
838  dof_tuple_schema_versions_type _dof_tuple_schema_versions;
839 
843  dof_tuple_schema_ids_type _dof_tuple_schema_ids;
844 
848  dof_tuple_col_bounds_type _dof_tuple_col_bounds;
849 
853  dof_tuple_domain_offsets_type _dof_tuple_domain_offsets;
854 
856 
857 
858  // ===========================================================
860  // ===========================================================
862 
863 public:
864 
869 
874 
878  id_spaces_type& id_spaces();
879 
883  const id_spaces_type& id_spaces() const;
884 
885 protected:
886 
887 private:
888 
892  id_spaces_type _id_spaces;
893 
895 
896 
897  // ===========================================================
899  // ===========================================================
901 
902 public:
903 
909  virtual poset_scaffold* clone() const;
910 
914  virtual bool invariant() const;
915 
919  virtual bool is_ancestor_of(const any* other) const;
920 
921 protected:
922 
923 private:
924 
926 
927 };
928 
929 } // namespace sheaf
930 
931 #endif // ifndef POSET_SCAFFOLD_H
932 
933 
934 
935 
936 
937 
938 
An implementation of class scattered_insertion_index_space_handle that has a interval id space state...
A client handle for a subposet.
Definition: subposet.h:86
unordered::unordered_map< pod_index_type, int > dof_tuple_schema_versions_type
Type of dof tuple versions map.
interval_index_space_handle subposet_index_space_type
Type for subposet index space.
The default name space; a poset which contains other posets as members.
unordered::unordered_map< pod_index_type, std::string > dof_tuple_class_names_type
Type of dof tuple class names map.
A client handle for a general, abstract partially order set.
A partial multi-valued relation with total injective inverse between names and indices of type index_...
Definition: name_multimap.h:63
unordered::unordered_map< pod_index_type, poset_bounds_descriptor > dof_tuple_col_bounds_type
Type of dof tuple col bounds map.
A (lower, upper) bounds pair for a poset. Specifies a portion of a poset for a bounded i/o operation...
Definition: poset_bounds.h:50
unordered::unordered_map< pod_index_type, pod_index_type > dof_tuple_schema_ids_type
Type of dof tuple schema ids map.
unordered::unordered_map< pod_index_type, dof_tuple_type > dof_tuple_types_type
Type of dof tuple types map.
A auto_block initialization policy that initializes the values to zero.
Definition: auto_block.h:102
Abstract base class with useful features for all objects.
Definition: any.h:39
A poset specific collection of data converters, various buffers and other data used while transferrin...
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
A description of a (lower, upper) bounds pair for a poset. Specifies a portion of a poset for a bound...
name_multimap member_name_map_type
Type for member name map.
auto_block< scattered_insertion_index_space_handle *, init_type > id_spaces_type
The type of the id space block.
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
Namespace for the sheaves component of the sheaf system.
A collection of data converters that map data types between internal and external representations...
Definition: data_type_map.h:49
A poset specific collection of data converters, various buffers and other data used while transferrin...
unordered::unordered_map< pod_index_type, std::pair< std::string, size_type > > member_class_names_type
Type of member class names map.
interval_index_space_handle dof_tuple_index_space_type
Type for dof tuple index space.
zero_block_initialization_policy< scattered_insertion_index_space_handle * > init_type
The initialization type of the id space block.
An auto_block with a no-initialization initialization policy.
The set of subsets of a poset.
A client handle for a poset member which has been prepared for use as a schema.
interval_index_space_handle member_index_space_type
Type for member index space.
The data structure representing the table containing the dof tuples of the members of a poset...
std::map< std::pair< pod_index_type, pod_index_type >, pod_index_type > dof_tuple_domain_offsets_type
Type of dof tuple domain offsets map.