SheafSystem  0.0.0.0
record.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 
19 // Implementation for class record
20 
21 #include "SheafSystem/record.h"
22 #include "SheafSystem/assert_contract.h"
23 
24 // PUBLIC MEMBER FUNCTIONS
25 
26 // CANONICAL MEMBERS
27 
28 // No default constructor
29 
30 // Copy constructor
33 record(const record& xother)
34  : _index(xother._index), _scaffold(xother._scaffold)
35 {
36 
37  // Preconditions:
38 
39  // Body:
40 
41  // Postconditions:
42 
43  ensure(invariant());
44 }
45 
46 
47 
48 // Virtual constructor
52 clone() const
53 {
54  record* result;
55 
56  // Preconditions:
57 
58  // Body:
59 
60  result = new record(*this);
61 
62  // Postconditions:
63 
64  ensure(result != 0);
65  ensure(is_same_type(result));
66 
67  // Exit:
68 
69  return result;
70 }
71 
72 
73 // Destructor
77 {
78 
79  // Preconditions:
80 
81  // Body:
82 
83  // Postconditions:
84 
85  // Exit:
86 
87  return;
88 }
89 
90 
91 // Class invariant
93 bool
95 invariant() const
96 {
97  bool result = true;
98 
99  // Preconditions:
100 
101  // Body:
102 
103  // Must satisfy base class invariant
104 
105  result = result && any::invariant();
106 
107  if(invariant_check())
108  {
109  // Prevent recursive calls to invariant
110 
112 
113  // Finished, turn invariant checking back on.
114 
116  }
117 
118  // Postconditions:
119 
120  // Exit
121 
122  return result;
123 }
124 
125 // Conformance test
127 bool
129 is_ancestor_of(const any* other) const
130 {
131 
132  // Preconditions:
133 
134  require(other != 0);
135 
136  // Body:
137 
138  // True if other conforms to this
139 
140  bool result = dynamic_cast<const record*>(other) != 0;
141 
142  // Postconditions:
143 
144  return result;
145 
146 }
147 
148 
149 
150 // RECORD INTERFACE
151 
152 
153 
156 record(const poset_scaffold& xscaffold)
157  : _scaffold(const_cast<poset_scaffold&>(xscaffold))
158 {
159  // Preconditions:
160 
161  // Body:
162 
163  _index.invalidate();
164 
165  // Postconditions:
166 
167  ensure(invariant());
168  ensure(!external_index().is_valid());
169  ensure(&(scaffold()) == &xscaffold);
170 
171  // Exit
172 
173  return;
174 }
175 
176 
177 
virtual bool invariant() const
Class invariant, intended to be redefined in each descendant. See below for template for invariant in...
Definition: any.cc:153
poset_scaffold & scaffold()
The scaffold for the poset associated with this record (mutable version).
Definition: record.h:112
virtual bool invariant() const
Class invariant.
Definition: record.cc:95
virtual ~record()
Destructor.
Definition: record.cc:76
record_index external_index() const
The external index of this record.
Definition: record.h:94
void invalidate()
Make this id invalid.
Definition: scoped_index.h:852
Abstract base class with useful features for all objects.
Definition: any.h:39
The general variable length record wrapper/adapter for transferring data between the kernel and the i...
Definition: record.h:48
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
Definition: record.cc:129
record(const record &xother)
Copy constructor.
Definition: record.cc:33
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
A poset specific collection of data converters, various buffers and other data used while transferrin...
SHEAF_DLL_SPEC bool is_valid(pod_index_type xpod_index)
True if an only if xpod_index is valid.
Definition: pod_types.cc:37
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
virtual record * clone() const
Virtual constructor; makes a new instance of the same type as this.
Definition: record.cc:52