Turi Create  4.0
unsupported_serialize.hpp
1 /* Copyright © 2017 Apple Inc. All rights reserved.
2  *
3  * Use of this source code is governed by a BSD-3-clause license that can
4  * be found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
5  */
6 #ifndef TURI_UNSUPPORTED_SERIALIZE_HPP
7 #define TURI_UNSUPPORTED_SERIALIZE_HPP
8 
9 #include <core/storage/serialization/iarchive.hpp>
10 #include <core/storage/serialization/oarchive.hpp>
11 #include <core/logging/logger.hpp>
12 
13 namespace turi {
14 
15  /**
16  * \ingroup group_serialization
17  * \brief Inheritting from this class will prevent the serialization
18  * of the derived class. Used for debugging purposes.
19  *
20  * Inheritting from this class will result in an assertion failure
21  * if any attempt is made to serialize or deserialize the derived
22  * class. This is largely used for debugging purposes to enforce
23  * that certain types are never serialized
24  */
26  void save(oarchive& archive) const {
27  ASSERT_MSG(false, "trying to serialize an unserializable object");
28  }
29  void load(iarchive& archive) {
30  ASSERT_MSG(false, "trying to deserialize an unserializable object");
31  }
32  }; // end of struct
33 };
34 
35 
36 /**
37 \ingroup group_serialization
38 \brief A macro which disables the serialization of type so that
39 it will fault at runtime.
40 
41 Writing TURI_UNSERIALIZABLE(T) for some typename T in the global namespace
42 will result in an assertion failure if any attempt is made to serialize or
43 deserialize the type T. This is largely used for debugging purposes to enforce
44 that certain types are never serialized.
45 */
46 #define TURI_UNSERIALIZABLE(tname) \
47  BEGIN_OUT_OF_PLACE_LOAD(arc, tname, tval) \
48  ASSERT_MSG(false, "trying to deserialize an unserializable object"); \
49  END_OUT_OF_PLACE_LOAD() \
50  \
51  BEGIN_OUT_OF_PLACE_SAVE(arc, tname, tval) \
52  ASSERT_MSG(false, "trying to serialize an unserializable object"); \
53  END_OUT_OF_PLACE_SAVE() \
54 
55 
56 #endif
The serialization input archive object which, provided with a reference to an istream, will read from the istream, providing deserialization capabilities.
Definition: iarchive.hpp:60
Inheritting from this class will prevent the serialization of the derived class. Used for debugging p...
The serialization output archive object which, provided with a reference to an ostream, will write to the ostream, providing serialization capabilities.
Definition: oarchive.hpp:80