SheafSystem  0.0.0.0
variable_length_record.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 variable_length_record
19 
20 #ifndef VARIABLE_LENGTH_RECORD_H
21 #define VARIABLE_LENGTH_RECORD_H
22 
23 #ifndef SHEAF_DLL_SPEC_H
24 #include "SheafSystem/sheaf_dll_spec.h"
25 #endif
26 
27 #ifndef RECORD_H
28 #include "SheafSystem/record.h"
29 #endif
30 
31 namespace sheaf
32 {
33 
39 class SHEAF_DLL_SPEC variable_length_record : public record
40 {
41 public:
42 
43  // CANONICAL MEMBERS
44 
50 
56  virtual variable_length_record* clone() const;
57 
61  virtual ~variable_length_record();
62 
66  virtual bool invariant() const;
67 
71  virtual bool is_ancestor_of(const any* other) const;
72 
73  // VARIABLE_LENGTH_RECORD INTERFACE
74 
78  variable_length_record(const poset_scaffold& xscaffold);
79 
83  void* buf() const;
84 
88  size_t buf_ub() const;
89 
90 protected:
91 
92  // Default constructor.
93  // Default construction prohibited because scaffold must be initialized
94  // inline variable_length_record() {} ;
95 
100  void put_buf(const void* xbuf, size_t xub);
101 
105  inline bool delete_buffer()
106  {
107  return _delete_buffer;
108  };
109 
113  inline void put_delete_buffer(bool xval)
114  {
115  _delete_buffer = xval;
116  };
117 
118 
119 
123  inline void* item(size_t xoffset) const
124  {
125  return reinterpret_cast<char*>(_buf) + xoffset;
126  };
127 
128 
129 
133  inline bool is_internal() const
134  {
135  return _is_internal;
136  };
137 
141  inline void put_is_internal(bool xis_internal)
142  {
143  _is_internal = xis_internal;
144  };
145 
146 
147 
151  inline bool is_external() const
152  {
153  return _is_external;
154  };
155 
159  inline void put_is_external(bool xis_external)
160  {
161  _is_external = xis_external;
162  };
163 
164 
165 private:
166 
167  // The buffer for this record
168 
169  void* _buf;
170 
171  // The length of the buffer, in bytes.
172 
173  size_t _buf_ub;
174 
175  // True if this allocated the buffer and the dtor should delet it.
176 
177  bool _delete_buffer;
178 
179  // True if the internal buffer has been initialized.
180 
181  bool _is_internal;
182 
183  // True if the external buffer has been initialized;
184 
185  bool _is_external;
186 
187 };
188 
189 } // namespace sheaf
190 
191 #endif // ifndef VARIABLE_LENGTH_RECORD_H
192 
193 
194 
195 
196 
197 
198 
void * item(size_t xoffset) const
Pointer to record item beginning at offset xoffset.
bool delete_buffer()
True if this allocated the buffer and the dtor should delete it.
The general variable length record wrapper/adapter for transferring data between the kernel and the i...
void put_delete_buffer(bool xval)
Sets delete_buffer to value xval.
Abstract base class with useful features for all objects.
Definition: any.h:39
bool is_internal() const
True if the internal buffer has been initialized.
The general variable length record wrapper/adapter for transferring data between the kernel and the i...
Definition: record.h:48
void put_is_internal(bool xis_internal)
Sets is_internal to xis_internal.
Namespace for the sheaves component of the sheaf system.
A poset specific collection of data converters, various buffers and other data used while transferrin...
bool is_external() const
True if the external buffer has been initialized.
void put_is_external(bool xis_external)
Sets is_external to xis_external.