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

memory_block.h
1 /* file: memory_block.h */
2 /*******************************************************************************
3 * Copyright 2014-2017 Intel Corporation
4 * All Rights Reserved.
5 *
6 * If this software was obtained under the Intel Simplified Software License,
7 * the following terms apply:
8 *
9 * The source code, information and material ("Material") contained herein is
10 * owned by Intel Corporation or its suppliers or licensors, and title to such
11 * Material remains with Intel Corporation or its suppliers or licensors. The
12 * Material contains proprietary information of Intel or its suppliers and
13 * licensors. The Material is protected by worldwide copyright laws and treaty
14 * provisions. No part of the Material may be used, copied, reproduced,
15 * modified, published, uploaded, posted, transmitted, distributed or disclosed
16 * in any way without Intel's prior express written permission. No license under
17 * any patent, copyright or other intellectual property rights in the Material
18 * is granted to or conferred upon you, either expressly, by implication,
19 * inducement, estoppel or otherwise. Any license under such intellectual
20 * property rights must be express and approved by Intel in writing.
21 *
22 * Unless otherwise agreed by Intel in writing, you may not remove or alter this
23 * notice or any other notice embedded in Materials by Intel or Intel's
24 * suppliers or licensors in any way.
25 *
26 *
27 * If this software was obtained under the Apache License, Version 2.0 (the
28 * "License"), the following terms apply:
29 *
30 * You may not use this file except in compliance with the License. You may
31 * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
32 *
33 *
34 * Unless required by applicable law or agreed to in writing, software
35 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
36 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37 *
38 * See the License for the specific language governing permissions and
39 * limitations under the License.
40 *******************************************************************************/
41 
42 #ifndef __MEMORY_BLOCK_H__
43 #define __MEMORY_BLOCK_H__
44 
45 #include "services/daal_defines.h"
46 #include "data_management/data/data_serialize.h"
47 #include "data_management/data/data_archive.h"
48 #include "services/daal_shared_ptr.h"
49 
50 namespace daal
51 {
52 namespace data_management
53 {
54 
55 namespace interface1
56 {
57 
62 class DAAL_EXPORT MemoryBlock : public SerializationIface
63 {
64 public:
65  DECLARE_SERIALIZABLE_TAG();
66 
67  DAAL_CAST_OPERATOR(MemoryBlock);
68 
70  MemoryBlock() : _size(0), _value(NULL)
71  {
72  }
73 
77  MemoryBlock(size_t n);
78 
79  virtual ~MemoryBlock();
80 
86  void reserve(size_t n);
87 
92  byte* get()
93  {
94  return _value;
95  }
96 
101  const byte* get() const
102  {
103  return _value;
104  }
105 
110  size_t size() const
111  {
112  return _size;
113  }
114 
118  void release();
119 
120 protected:
121  virtual services::Status serializeImpl(interface1::InputDataArchive *arch) DAAL_C11_OVERRIDE
122  {
123  arch->set(_size);
124  if(_size)
125  arch->set(_value, _size);
126 
127  return services::Status();
128  }
129 
130  virtual services::Status deserializeImpl(const interface1::OutputDataArchive *arch) DAAL_C11_OVERRIDE
131  {
132  size_t sz = 0;
133  arch->set(sz);
134  reserve(sz);
135  if(sz)
136  arch->set(_value, sz);
137 
138  return services::Status();
139  }
140 
141 protected:
142  size_t _size;
143  byte* _value;
144 };
145 typedef services::SharedPtr<MemoryBlock> MemoryBlockPtr;
146 
147 } // namespace interface1
148 using interface1::MemoryBlock;
149 using interface1::MemoryBlockPtr;
150 
151 }
152 }
153 
154 #endif
daal
Definition: algorithm_base_common.h:57
daal::data_management::interface1::InputDataArchive
Provides methods to create an archive data object (serialized) and access this object.
Definition: data_archive.h:715
daal::data_management::interface1::MemoryBlock
Serializable memory block, owner of the memory.
Definition: memory_block.h:62
daal_defines.h
daal::data_management::interface1::MemoryBlock::size
size_t size() const
Definition: memory_block.h:110
daal::data_management::interface1::OutputDataArchive
Provides methods to restore an object from its serialized counterpart and access the restored object...
Definition: data_archive.h:967
daal::data_management::interface1::MemoryBlock::MemoryBlock
MemoryBlock()
Definition: memory_block.h:70
daal::data_management::interface1::MemoryBlock::serializeImpl
virtual services::Status serializeImpl(interface1::InputDataArchive *arch) DAAL_C11_OVERRIDE
Definition: memory_block.h:121
daal::data_management::interface1::SerializationIface
Abstract interface class that defines the interface for serialization and deserialization.
Definition: data_serialize.h:76
daal::data_management::interface1::MemoryBlock::deserializeImpl
virtual services::Status deserializeImpl(const interface1::OutputDataArchive *arch) DAAL_C11_OVERRIDE
Definition: memory_block.h:130

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