SheafSystem  0.0.0.0
poset_dof_map.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_dof_map;
19 // map from client dof id to dof value
20 
21 #ifndef POSET_DOF_MAP_H
22 #define POSET_DOF_MAP_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 DOF_TUPLE_TYPE_H
33 #include "SheafSystem/dof_tuple_type.h"
34 #endif
35 
36 #ifndef PRIMITIVE_VALUE_H
37 #include "SheafSystem/primitive_value.h"
38 #endif
39 
40 #ifndef SCOPED_INDEX_H
41 #include "SheafSystem/scoped_index.h"
42 #endif
43 
44 #ifndef STD_STRING_H
45 #include "SheafSystem/std_string.h"
46 #endif
47 
48 namespace sheaf
49 {
50 
51 class poset_state_handle;
52 class schema_poset_member;
53 class arg_list;
54 class dof_map_factory;
55 
59 class SHEAF_DLL_SPEC poset_dof_map : public any
60 {
61 
62  friend class poset_table_state;
63  friend class poset_state_handle;
64  friend SHEAF_DLL_SPEC size_t deep_size(const poset_dof_map& xp, bool xinclude_shallow);
65 
66 public:
67 
71  virtual const std::string& class_name() const;
72 
76  static const std::string& static_class_name();
77 
82  static poset_dof_map*
83  new_dof_map(const std::string& xclass_name, dof_tuple_type xsheaf_base_class_id);
84 
85  // CANONICAL MEMBERS
86 
90  virtual poset_dof_map* clone() const = 0;
91 
95  virtual poset_dof_map* copy() const = 0;
96 
100  poset_dof_map& operator=(const poset_dof_map& xother);
101 
105  virtual ~poset_dof_map();
106 
110  virtual bool invariant() const;
111 
112 
113  // MAP INTERFACE
114 
120  virtual void init_row_dof_map(const poset_state_handle* xhost,
121  pod_index_type xschema_mbr_id,
122  int xschema_version);
123 
129  void init_row_dof_map(const poset_state_handle* xhost,
130  const scoped_index& xschema_mbr_id,
131  int xschema_version);
132 
136  virtual dof_tuple_type type_id() const = 0;
137 
142  bool is_initialized() const;
143 
147  virtual poset_state_handle* host() const;
148 
152  const scoped_index& index() const;
153 
154  // $$SCRIBBLE: there's no need for schema() to be virtual.
155  // It's only overridden in one place, section_dof_map, and
156  // the over ride only does a down cast on the return type.
157  // Should be non-virtual and inline and section_dof_map
158  // should just hide poset_dof_map; more efficient.
159 
163  virtual schema_poset_member& schema();
164 
168  virtual const schema_poset_member& schema() const;
169 
173  bool is_table_dof_map() const;
174 
178  int dof_ct() const;
179 
180  // ===========================================================
181  // NEW DOF ACCESS FACET
182  // ===========================================================
183 
187  primitive_value dof(pod_index_type xdof_id) const;
188 
192  primitive_value dof(const scoped_index& xdof_id) const;
193 
197  primitive_value dof(const std::string& xname) const;
198 
202  void put_dof(pod_index_type xdof_id, const primitive_value& xdof);
203 
207  void put_dof(const scoped_index& xdof_id, const primitive_value& xdof);
208 
212  void put_dof(const std::string& xname, const primitive_value& xdof);
213 
217  virtual void get_dof(pod_index_type xdof_id, void* xdof, size_type xdof_size) const;
218 
222  void get_dof(const scoped_index& xdof_id, void* xdof, size_type xdof_size) const;
223 
227  virtual void put_dof(pod_index_type xdof_id, const void* xdof, size_type xdof_size);
228 
232  void put_dof(const scoped_index& xdof_id, const void* xdof, size_type xdof_size);
233 
234 
235  // ===========================================================
236  // END NEW DOF ACCESS FACET
237  // ===========================================================
238 
242  size_t dof_tuple_ub() const;
243 
247  virtual void* dof_tuple() = 0;
248 
252  virtual const void* dof_tuple() const = 0;
253 
257  virtual void get_dof_tuple(void* xbuf, size_t xbuflen) const = 0;
258 
262  virtual void put_dof_tuple(const void* xbuf, size_t xbuflen) = 0;
263 
267  void get_dof_tuple(arg_list& xargs) const;
268 
272  void put_dof_tuple(const arg_list& xargs);
273 
277  void copy_dof_tuple(const poset_dof_map& xother);
278 
282  virtual void put_defaults();
283 
287  unsigned int ref_ct() const;
288 
292  void inc_ref_ct();
293 
297  void dec_ref_ct();
298 
302  int version() const;
303 
308  virtual const index_space_handle& client_id_space() const;
309 
313  std::string to_string(const schema_poset_member& xschema) const;
314 
318  std::string to_string() const;
319 
320  // ===========================================================
321  // I/O SUPPORT FACET
322  // ===========================================================
323 
328  virtual bool supports_xfr_opt() const;
329 
330 protected:
331 
335  static dof_map_factory& factory();
336 
337  // CANONICAL MEMBERS
338 
342  poset_dof_map();
343 
347  poset_dof_map(const poset_dof_map& xother);
348 
349  // OTHER CONSTRUCTORS
350 
355  poset_dof_map(const poset_state_handle* xhost, bool xis_table_dof_map);
356 
361  poset_dof_map(const schema_poset_member* xschema, bool xis_table_dof_map);
362 
363  // MAP INTERFACE
364 
368  virtual void put_host(const poset_state_handle* xhost);
369 
373  void put_index(const scoped_index& xindex);
374 
378  void put_dof_ct(int xdof_ct);
379 
383  void put_dof_tuple_ub(size_t xub);
384 
388  void put_ref_ct(int xref_ct);
389 
394 
399 
404 
409 
413  int _dof_ct;
414 
419 
424  unsigned int _ref_ct;
425 
429  virtual void allocate_dofs() = 0;
430 
431 };
432 
433 // ===========================================================
434 // NONMEMBER FUNCTIONS
435 // ===========================================================
436 
440 SHEAF_DLL_SPEC
441 std::ostream& operator << (std::ostream &os, const poset_dof_map& p);
442 
446 SHEAF_DLL_SPEC
447 size_t deep_size(const poset_dof_map& xp, bool xinclude_shallow = true);
448 
449 } // namespace sheaf
450 
451 #endif // ifndef POSET_DOF_MAP_H
452 
unsigned int _ref_ct
The number of references to this map /.
A client handle for a general, abstract partially order set.
bool _is_table_dof_map
True if this is a table dof map.
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
size_t _dof_tuple_ub
The size of the dof tuple.
Abstract base class with useful features for all objects.
Definition: any.h:39
A whitespace separated list of arguments. Insertion operaters are used to insert arguments into the l...
Definition: arg_list.h:63
A factory for instanting descendants of an abstract type T, given the class name of the descendant...
Definition: eval_family.h:49
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.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
scoped_index _index
The poset member for which this stores the dofs.
dof_tuple_type
Identifiers for dof tuple types.
int _dof_ct
The number of dofs in this map.
schema_poset_member * _schema
The schema on which this is instantiated.
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.
Abstract object wrapper for an instance of a primitive type.
poset_state_handle * _host
The host of the poset member for which this stores the dofs.
A factory for creating dof maps.
A client handle for a poset member which has been prepared for use as a schema.
The data structure representing the table containing the dof tuples of the members of a poset...