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

data_serialize.h
1 /* file: data_serialize.h */
2 /*******************************************************************************
3 * Copyright 2014-2018 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 /*
17 //++
18 // Declaration and implementation of the serialization class
19 //--
20 */
21 
22 #ifndef __DAAL_SERIALIZE_H__
23 #define __DAAL_SERIALIZE_H__
24 
25 #include "services/base.h"
26 #include "services/daal_memory.h"
27 #include "services/error_handling.h"
28 
29 namespace daal
30 {
31 namespace data_management
32 {
33 
34 namespace interface1
35 {
42 class InputDataArchive;
43 class OutputDataArchive;
44 
50 class DAAL_EXPORT SerializationIface : public Base
51 {
52 public:
53  virtual ~SerializationIface() {}
54 
59  void serialize(interface1::InputDataArchive &archive);
60 
65  void deserialize(interface1::OutputDataArchive &archive);
66 
71  virtual int getSerializationTag() const = 0;
72 
77  virtual services::Status serializeImpl(interface1::InputDataArchive *archive) = 0;
78 
83  virtual services::Status deserializeImpl(const interface1::OutputDataArchive *archive) = 0;
84 };
85 
87 
88 class DAAL_EXPORT SerializationDesc
89 {
90 public:
91  typedef SerializationIface* (*creatorFunc)();
92  SerializationDesc(creatorFunc func, int tag);
93  int tag() const { return _tag; }
94  creatorFunc creator() const { return _f; }
95  const SerializationDesc* next() const { return _next; }
96  static const SerializationDesc* first();
97 
98 private:
99  creatorFunc _f;
100  const int _tag;
101  const SerializationDesc* _next;
102 };
104 
106 } // namespace interface1
107 using interface1::SerializationIface;
108 using interface1::SerializationDesc;
109 
110 }
111 }
112 #define DECLARE_SERIALIZABLE_IMPL() \
113  services::Status serializeImpl (data_management::InputDataArchive *arch) DAAL_C11_OVERRIDE \
114  { return serialImpl<data_management::InputDataArchive, false>( arch ); } \
115  services::Status deserializeImpl(const data_management::OutputDataArchive *arch) DAAL_C11_OVERRIDE \
116  { return serialImpl<const data_management::OutputDataArchive, true>( arch ); }
117 
118 #define DECLARE_SERIALIZABLE() \
119 private: \
120  static data_management::SerializationDesc _desc; \
121 public: \
122  DECLARE_SERIALIZABLE_IMPL() \
123  static int serializationTag(); \
124  virtual int getSerializationTag() const DAAL_C11_OVERRIDE;
125 
126 #define DECLARE_SERIALIZABLE_IFACE() \
127 private: \
128  static data_management::SerializationDesc _desc; \
129 public: \
130  static int serializationTag(); \
131  virtual int getSerializationTag() const DAAL_C11_OVERRIDE;
132 
133 #define DECLARE_SERIALIZABLE_TAG() \
134 public: \
135  static int serializationTag(); \
136  virtual int getSerializationTag() const DAAL_C11_OVERRIDE;
137 
138 #define DECLARE_SERIALIZABLE_CAST(ClassName) \
139  DECLARE_SERIALIZABLE(); \
140  DAAL_CAST_OPERATOR(ClassName);
141 
142 #define DECLARE_MODEL(DstClassName, SrcClassName) \
143  DECLARE_SERIALIZABLE(); \
144  DAAL_CAST_OPERATOR(DstClassName); \
145  DAAL_DOWN_CAST_OPERATOR(DstClassName, SrcClassName)
146 
147 #define DECLARE_MODEL_IFACE(DstClassName, SrcClassName) \
148  DECLARE_SERIALIZABLE_IFACE(); \
149  DAAL_CAST_OPERATOR(DstClassName); \
150  DAAL_DOWN_CAST_OPERATOR(DstClassName, SrcClassName)
151 
152 #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::OutputDataArchive
Provides methods to restore an object from its serialized counterpart and access the restored object...
Definition: data_archive.h:952
daal::Base
Base class for Intel(R) Data Analytics Acceleration Library objects
Definition: base.h:39
daal::data_management::interface1::SerializationIface
Abstract interface class that defines the interface for serialization and deserialization.
Definition: data_serialize.h:50

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