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

data_serialize.h
1 /* file: data_serialize.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 /*
43 //++
44 // Declaration and implementation of the serialization class
45 //--
46 */
47 
48 #ifndef __DAAL_SERIALIZE_H__
49 #define __DAAL_SERIALIZE_H__
50 
51 #include "services/base.h"
52 #include "services/daal_memory.h"
53 #include "services/error_handling.h"
54 
55 namespace daal
56 {
57 namespace data_management
58 {
59 
60 namespace interface1
61 {
68 class InputDataArchive;
69 class OutputDataArchive;
70 
76 class DAAL_EXPORT SerializationIface : public Base
77 {
78 public:
79  virtual ~SerializationIface() {}
80 
85  void serialize(interface1::InputDataArchive &archive);
86 
91  void deserialize(interface1::OutputDataArchive &archive);
92 
97  virtual int getSerializationTag() const = 0;
98 
103  virtual services::Status serializeImpl(interface1::InputDataArchive *archive) = 0;
104 
109  virtual services::Status deserializeImpl(const interface1::OutputDataArchive *archive) = 0;
110 };
111 
113 
114 class DAAL_EXPORT SerializationDesc
115 {
116 public:
117  typedef SerializationIface* (*creatorFunc)();
118  SerializationDesc(creatorFunc func, int tag);
119  int tag() const { return _tag; }
120  creatorFunc creator() const { return _f; }
121  const SerializationDesc* next() const { return _next; }
122  static const SerializationDesc* first();
123 
124 private:
125  creatorFunc _f;
126  const int _tag;
127  SerializationDesc* _next;
128 };
130 
132 } // namespace interface1
133 using interface1::SerializationIface;
134 using interface1::SerializationDesc;
135 
136 }
137 }
138 #define DECLARE_SERIALIZABLE_IMPL() \
139  services::Status serializeImpl (data_management::InputDataArchive *arch) DAAL_C11_OVERRIDE \
140  { return serialImpl<data_management::InputDataArchive, false>( arch ); } \
141  services::Status deserializeImpl(const data_management::OutputDataArchive *arch) DAAL_C11_OVERRIDE \
142  { return serialImpl<const data_management::OutputDataArchive, true>( arch ); }
143 
144 #define DECLARE_SERIALIZABLE() \
145 private: \
146  static data_management::SerializationDesc _desc; \
147 public: \
148  DECLARE_SERIALIZABLE_IMPL() \
149  static int serializationTag(); \
150  virtual int getSerializationTag() const DAAL_C11_OVERRIDE;
151 
152 #define DECLARE_SERIALIZABLE_IFACE() \
153 private: \
154  static data_management::SerializationDesc _desc; \
155 public: \
156  static int serializationTag(); \
157  virtual int getSerializationTag() const DAAL_C11_OVERRIDE;
158 
159 #define DECLARE_SERIALIZABLE_TAG() \
160 public: \
161  static int serializationTag(); \
162  virtual int getSerializationTag() const DAAL_C11_OVERRIDE;
163 
164 #define DECLARE_SERIALIZABLE_CAST(ClassName) \
165  DECLARE_SERIALIZABLE(); \
166  DAAL_CAST_OPERATOR(ClassName);
167 
168 #define DECLARE_MODEL(DstClassName, SrcClassName) \
169  DECLARE_SERIALIZABLE(); \
170  DAAL_CAST_OPERATOR(DstClassName); \
171  DAAL_DOWN_CAST_OPERATOR(DstClassName, SrcClassName)
172 
173 #define DECLARE_MODEL_IFACE(DstClassName, SrcClassName) \
174  DECLARE_SERIALIZABLE_IFACE(); \
175  DAAL_CAST_OPERATOR(DstClassName); \
176  DAAL_DOWN_CAST_OPERATOR(DstClassName, SrcClassName)
177 
178 #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::OutputDataArchive
Provides methods to restore an object from its serialized counterpart and access the restored object...
Definition: data_archive.h:967
daal::Base
Base class for Intel(R) Data Analytics Acceleration Library objects
Definition: base.h:65
daal::data_management::interface1::SerializationIface
Abstract interface class that defines the interface for serialization and deserialization.
Definition: data_serialize.h:76

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