C++ API Reference for Intel® Data Analytics Acceleration Library 2019 Update 4

memory_block.h
1 /* file: memory_block.h */
2 /*******************************************************************************
3 * Copyright 2014-2019 Intel Corporation.
4 *
5 * This software and the related documents are Intel copyrighted materials, and
6 * your use of them is governed by the express license under which they were
7 * provided to you (License). Unless the License provides otherwise, you may not
8 * use, modify, copy, publish, distribute, disclose or transmit this software or
9 * the related documents without Intel's prior written permission.
10 *
11 * This software and the related documents are provided as is, with no express
12 * or implied warranties, other than those that are expressly stated in the
13 * License.
14 *******************************************************************************/
15 
16 #ifndef __MEMORY_BLOCK_H__
17 #define __MEMORY_BLOCK_H__
18 
19 #include "services/daal_defines.h"
20 #include "data_management/data/data_serialize.h"
21 #include "data_management/data/data_archive.h"
22 #include "services/daal_shared_ptr.h"
23 
24 namespace daal
25 {
26 namespace data_management
27 {
28 
29 namespace interface1
30 {
31 
36 class DAAL_EXPORT MemoryBlock : public SerializationIface
37 {
38 public:
39  DECLARE_SERIALIZABLE_TAG();
40 
41  DAAL_CAST_OPERATOR(MemoryBlock);
42 
44  MemoryBlock() : _size(0), _value(NULL)
45  {
46  }
47 
51  MemoryBlock(size_t n);
52 
53  virtual ~MemoryBlock();
54 
60  void reserve(size_t n);
61 
66  byte* get()
67  {
68  return _value;
69  }
70 
75  const byte* get() const
76  {
77  return _value;
78  }
79 
84  size_t size() const
85  {
86  return _size;
87  }
88 
92  void release();
93 
94 protected:
95  virtual services::Status serializeImpl(interface1::InputDataArchive *arch) DAAL_C11_OVERRIDE
96  {
97  arch->set(_size);
98  if(_size)
99  arch->set(_value, _size);
100 
101  return services::Status();
102  }
103 
104  virtual services::Status deserializeImpl(const interface1::OutputDataArchive *arch) DAAL_C11_OVERRIDE
105  {
106  size_t sz = 0;
107  arch->set(sz);
108  reserve(sz);
109  if(sz)
110  arch->set(_value, sz);
111 
112  return services::Status();
113  }
114 
115 protected:
116  size_t _size;
117  byte* _value;
118 };
119 typedef services::SharedPtr<MemoryBlock> MemoryBlockPtr;
120 
121 } // namespace interface1
122 using interface1::MemoryBlock;
123 using interface1::MemoryBlockPtr;
124 
125 }
126 }
127 
128 #endif
daal
Definition: algorithm_base_common.h:31
daal::data_management::interface1::InputDataArchive
Provides methods to create an archive data object (serialized) and access this object.
Definition: data_archive.h:689
daal::data_management::interface1::MemoryBlock
Serializable memory block, owner of the memory.
Definition: memory_block.h:36
daal_defines.h
daal::data_management::interface1::MemoryBlock::size
size_t size() const
Definition: memory_block.h:84
daal::data_management::interface1::OutputDataArchive
Provides methods to restore an object from its serialized counterpart and access the restored object...
Definition: data_archive.h:952
daal::data_management::interface1::MemoryBlock::MemoryBlock
MemoryBlock()
Definition: memory_block.h:44
daal::data_management::interface1::MemoryBlock::serializeImpl
virtual services::Status serializeImpl(interface1::InputDataArchive *arch) DAAL_C11_OVERRIDE
Definition: memory_block.h:95
daal::data_management::interface1::SerializationIface
Abstract interface class that defines the interface for serialization and deserialization.
Definition: data_serialize.h:50
daal::data_management::interface1::MemoryBlock::deserializeImpl
virtual services::Status deserializeImpl(const interface1::OutputDataArchive *arch) DAAL_C11_OVERRIDE
Definition: memory_block.h:104

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