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

data_serialize.h
1 /* file: data_serialize.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 /*
19 //++
20 // Declaration and implementation of the serialization class
21 //--
22 */
23 
24 #ifndef __DAAL_SERIALIZE_H__
25 #define __DAAL_SERIALIZE_H__
26 
27 #include "services/base.h"
28 #include "services/daal_memory.h"
29 #include "services/error_handling.h"
30 
31 namespace daal
32 {
33 namespace data_management
34 {
35 
36 namespace interface1
37 {
44 class InputDataArchive;
45 class OutputDataArchive;
46 
52 class DAAL_EXPORT SerializationIface : public Base
53 {
54 public:
55  virtual ~SerializationIface() {}
56 
61  void serialize(interface1::InputDataArchive &archive);
62 
67  void deserialize(interface1::OutputDataArchive &archive);
68 
73  virtual int getSerializationTag() const = 0;
74 
79  virtual services::Status serializeImpl(interface1::InputDataArchive *archive) = 0;
80 
85  virtual services::Status deserializeImpl(const interface1::OutputDataArchive *archive) = 0;
86 };
87 
89 
90 class DAAL_EXPORT SerializationDesc
91 {
92 public:
93  typedef SerializationIface* (*creatorFunc)();
94  SerializationDesc(creatorFunc func, int tag);
95  int tag() const { return _tag; }
96  creatorFunc creator() const { return _f; }
97  const SerializationDesc* next() const { return _next; }
98  static const SerializationDesc* first();
99 
100 private:
101  creatorFunc _f;
102  const int _tag;
103  const SerializationDesc* _next;
104 };
106 
108 } // namespace interface1
109 using interface1::SerializationIface;
110 using interface1::SerializationDesc;
111 
112 }
113 }
114 #define DECLARE_SERIALIZABLE_IMPL() \
115  services::Status serializeImpl (data_management::InputDataArchive *arch) DAAL_C11_OVERRIDE \
116  { return serialImpl<data_management::InputDataArchive, false>( arch ); } \
117  services::Status deserializeImpl(const data_management::OutputDataArchive *arch) DAAL_C11_OVERRIDE \
118  { return serialImpl<const data_management::OutputDataArchive, true>( arch ); }
119 
120 #define DECLARE_SERIALIZABLE() \
121 private: \
122  static data_management::SerializationDesc _desc; \
123 public: \
124  DECLARE_SERIALIZABLE_IMPL() \
125  static int serializationTag(); \
126  virtual int getSerializationTag() const DAAL_C11_OVERRIDE;
127 
128 #define DECLARE_SERIALIZABLE_IFACE() \
129 private: \
130  static data_management::SerializationDesc _desc; \
131 public: \
132  static int serializationTag(); \
133  virtual int getSerializationTag() const DAAL_C11_OVERRIDE;
134 
135 #define DECLARE_SERIALIZABLE_TAG() \
136 public: \
137  static int serializationTag(); \
138  virtual int getSerializationTag() const DAAL_C11_OVERRIDE;
139 
140 #define DECLARE_SERIALIZABLE_CAST(ClassName) \
141  DECLARE_SERIALIZABLE(); \
142  DAAL_CAST_OPERATOR(ClassName);
143 
144 #define DECLARE_MODEL(DstClassName, SrcClassName) \
145  DECLARE_SERIALIZABLE(); \
146  DAAL_CAST_OPERATOR(DstClassName); \
147  DAAL_DOWN_CAST_OPERATOR(DstClassName, SrcClassName)
148 
149 #define DECLARE_MODEL_IFACE(DstClassName, SrcClassName) \
150  DECLARE_SERIALIZABLE_IFACE(); \
151  DAAL_CAST_OPERATOR(DstClassName); \
152  DAAL_DOWN_CAST_OPERATOR(DstClassName, SrcClassName)
153 
154 #endif
daal::Base
Base class for Intel(R) Data Analytics Acceleration Library objects
Definition: base.h:41
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::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::InputDataArchive
Provides methods to create an archive data object (serialized) and access this object.
Definition: data_archive.h:725

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