SheafSystem  0.0.0.0
poset_data_type_map.cc
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 // Implementation for class poset_data_type_map
19 
20 #include "SheafSystem/poset_data_type_map.h"
21 
22 #include "SheafSystem/assert_contract.h"
23 #include "SheafSystem/data_converter.h"
24 
25 // ===========================================================
26 // ANY FACET
27 // ===========================================================
28 
32 clone() const
33 {
34  poset_data_type_map* result;
35 
36  // Preconditions:
37 
38  // Body:
39 
40  result = new poset_data_type_map(*this);
41 
42  // Postconditions:
43 
44  ensure(result != 0);
45  ensure(is_same_type(result));
46 
47  // Exit:
48 
49  return result;
50 }
51 
52 
54 bool
56 invariant() const
57 {
58  bool result = true;
59 
60  // Preconditions:
61 
62  // Body:
63 
64  // Must satisfy base class invariant
65 
66  result = result && data_type_map::invariant();
67 
68  if(invariant_check())
69  {
70  // Prevent recursive calls to invariant
71 
73 
74  result = result && ((0 <= _toc_index) && (_toc_index < PRIMITIVE_TYPE_END));
75  result = result && ((0 <= _dof_tuple_id_index) && (_dof_tuple_id_index < PRIMITIVE_TYPE_END));
76  result = result && ((0 <= _offset_index) && (_offset_index < PRIMITIVE_TYPE_END));
77 
78  // Finished, turn invariant checking back on.
79 
81  }
82 
83  // Postconditions:
84 
85  // Exit
86 
87  return result;
88 }
89 
91 bool
93 is_ancestor_of(const any* other) const
94 {
95 
96  // Preconditions:
97 
98  require(other != 0);
99 
100  // Body:
101 
102  // True if other conforms to this
103 
104  bool result = dynamic_cast<const poset_data_type_map*>(other) != 0;
105 
106  // Postconditions:
107 
108  return result;
109 
110 }
111 
112 
113 
114 // ===========================================================
115 // POSET_DATA_TYPE_MAP FACET
116 // ===========================================================
117 
118 
120 sheaf::poset_data_type_map::
121 poset_data_type_map(const data_type_map& xprim_map)
122  : data_type_map(xprim_map)
123 {
124 
125  // Preconditions:
126 
127  // Body:
128 
129  // Use default values for member record types.
130 
131  _toc_index = CHAR;
132  _dof_tuple_id_index = INT;
133  _offset_index = SIZE_TYPE;
134 
135  // Postconditions:
136 
137  ensure(invariant());
138 
139  // Exit
140 
141  return;
142 }
143 
145 sheaf::poset_data_type_map::
146 poset_data_type_map(const poset_data_type_map& xother)
147  : data_type_map(xother)
148 {
149 
150  // Preconditions:
151 
152  // Body:
153 
154  _toc_index = xother._toc_index;
155  _dof_tuple_id_index = xother._dof_tuple_id_index;
156  _offset_index = xother._offset_index;
157 
158  // Postconditions:
159 
160  ensure(invariant());
161 }
162 
163 
164 
168 {
169 
170  // Preconditions:
171 
172  // Body:
173 
174  // Do nothing.
175  // All the data converters and HDF objects are owned
176  // by the file data type map; it will delete them.
177 
178  // Postconditions:
179 
180  // Exit:
181 
182  return;
183 }
184 
185 
187 void
189 // put_member_record_type_aliases(const scoped_index& xtoc_index,
190 // const scoped_index& xdof_tuple_id_index,
191 // const scoped_index& xoffset_index)
192 put_member_record_type_aliases(int xtoc_index,
193  int xdof_tuple_id_index,
194  int xoffset_index)
195 {
196 
197  // Preconditions:
198 
199  require(is_primitive_index(xtoc_index));
200  require(is_primitive_index(xdof_tuple_id_index));
201  require(is_primitive_index(xoffset_index));
202 
203  // Body:
204 
205  _toc_index = xtoc_index;
206  _dof_tuple_id_index = xdof_tuple_id_index;
207  _offset_index = xoffset_index;
208 
209  // Postconditions:
210 
211  ensure(invariant());
212 }
213 
214 
215 
216 
217 // PRIVATE MEMBER FUNCTIONS
218 
219 sheaf::poset_data_type_map::
220 poset_data_type_map()
221 {
222 
223  // Preconditions:
224 
225 
226  // Body:
227 
228 
229  // Postconditions:
230 
231  ensure(invariant());
232 
233  // Exit:
234 
235  return;
236 }
virtual bool invariant() const
Class invariant.
virtual ~poset_data_type_map()
Destructor.
virtual poset_data_type_map * clone() const
Virtual constructor; makes a new instance of the same type as this.
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...
void put_member_record_type_aliases(int xtoc_index, int xdof_tuple_id_index, int xoffset_index)
Sets the member record specific data types These features are logically members of class member_recor...
SHEAF_DLL_SPEC bool is_primitive_index(pod_index_type xindex)
True if xindex is a valid primitive index.
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
Definition: any.h:97
bool invariant_check() const
True if invariant checking is enabled.
Definition: any.h:79
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
A collection of data converters that map data types between internal and external representations...
Definition: data_type_map.h:49
virtual bool invariant() const
Class invariant.
bool is_same_type(const any *other) const
True if other is the same type as this.
Definition: any.cc:79
void enable_invariant_check() const
Enable invariant checking.
Definition: any.h:87