C++ API Reference for Intel® Data Analytics Acceleration Library 2020 Update 1

memory_block.h
1 /* file: memory_block.h */
2 /*******************************************************************************
3 * Copyright 2014-2020 Intel Corporation
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 #ifndef __MEMORY_BLOCK_H__
19 #define __MEMORY_BLOCK_H__
20 
21 #include "services/daal_defines.h"
22 #include "data_management/data/data_serialize.h"
23 #include "data_management/data/data_archive.h"
24 #include "services/daal_shared_ptr.h"
25 
26 namespace daal
27 {
28 namespace data_management
29 {
30 
31 namespace interface1
32 {
33 
38 class DAAL_EXPORT MemoryBlock : public SerializationIface
39 {
40 public:
41  DECLARE_SERIALIZABLE_TAG();
42 
43  DAAL_CAST_OPERATOR(MemoryBlock);
44 
46  MemoryBlock() : _size(0), _value(NULL)
47  {
48  }
49 
53  MemoryBlock(size_t n);
54 
55  virtual ~MemoryBlock();
56 
62  void reserve(size_t n);
63 
68  byte* get()
69  {
70  return _value;
71  }
72 
77  const byte* get() const
78  {
79  return _value;
80  }
81 
86  size_t size() const
87  {
88  return _size;
89  }
90 
94  void release();
95 
96 protected:
97  virtual services::Status serializeImpl(interface1::InputDataArchive *arch) DAAL_C11_OVERRIDE
98  {
99  arch->set(_size);
100  if(_size)
101  arch->set(_value, _size);
102 
103  return services::Status();
104  }
105 
106  virtual services::Status deserializeImpl(const interface1::OutputDataArchive *arch) DAAL_C11_OVERRIDE
107  {
108  size_t sz = 0;
109  arch->set(sz);
110  reserve(sz);
111  if(sz)
112  arch->set(_value, sz);
113 
114  return services::Status();
115  }
116 
117 protected:
118  size_t _size;
119  byte* _value;
120 };
121 typedef services::SharedPtr<MemoryBlock> MemoryBlockPtr;
122 
123 } // namespace interface1
124 using interface1::MemoryBlock;
125 using interface1::MemoryBlockPtr;
126 
127 }
128 }
129 
130 #endif
daal::data_management::interface1::MemoryBlock
Serializable memory block, owner of the memory.
Definition: memory_block.h:38
daal_defines.h
daal::data_management::interface1::SerializationIface
Abstract interface class that defines the interface for serialization and deserialization.
Definition: data_serialize.h:52
daal::data_management::interface1::MemoryBlock::size
size_t size() const
Definition: memory_block.h:86
daal::data_management::interface1::MemoryBlock::MemoryBlock
MemoryBlock()
Definition: memory_block.h:46
daal::data_management::interface1::OutputDataArchive
Provides methods to restore an object from its serialized counterpart and access the restored object...
Definition: data_archive.h:988
daal::data_management::interface1::MemoryBlock::serializeImpl
virtual services::Status serializeImpl(interface1::InputDataArchive *arch) DAAL_C11_OVERRIDE
Definition: memory_block.h:97
daal::data_management::interface1::InputDataArchive
Provides methods to create an archive data object (serialized) and access this object.
Definition: data_archive.h:725
daal::data_management::interface1::MemoryBlock::deserializeImpl
virtual services::Status deserializeImpl(const interface1::OutputDataArchive *arch) DAAL_C11_OVERRIDE
Definition: memory_block.h:106

For more complete information about compiler optimizations, see our Optimization Notice.