CNORXZ
Container with Native Operation Routines and Expressions
Loading...
Searching...
No Matches
cer_ranges.cc.h
Go to the documentation of this file.
1// -*- C++ -*-
12#ifndef __cxz_cereal_ranges_cc_h__
13#define __cxz_cereal_ranges_cc_h__
14
15#include <cereal/cereal.hpp>
16#include <cereal/types/vector.hpp>
17
18#include "base/base.h"
19#include "ranges/crange.h"
20#include "ranges/urange.h"
21#include "ranges/yrange.h"
22
23namespace CNORXZ
24{
25 /*============+
26 | save |
27 +============*/
28
29 template <class Archive>
30 void save(Archive& ar, const Uuid& id)
31 {
32 ar(CEREAL_NVP(id.i1));
33 ar(CEREAL_NVP(id.i2));
34 }
35
36 template <class Archive>
37 void CRange::save(Archive& ar, const std::uint32_t version) const
38 {
39 CXZ_ASSERT(version == 1u, "format version = " << version << " not supported");
40 ar(cereal::make_nvp("uuid", RB::mId));
41 ar(cereal::make_nvp("this", RB::mThis));
42 ar(cereal::make_nvp("size", mSize));
43 }
44
45 template <class MetaT>
46 template <class Archive>
47 void URange<MetaT>::save(Archive& ar, const std::uint32_t version) const
48 {
49 CXZ_ASSERT(version == 1u, "format version = " << version << " not supported");
50 ar(cereal::make_nvp("uuid", RB::mId));
51 ar(cereal::make_nvp("this", RB::mThis));
52 ar(cereal::make_nvp("meta", mSpace));
53 }
54
55 template <class Archive>
56 void YRange::save(Archive& ar, const std::uint32_t version) const
57 {
58 CXZ_ASSERT(version == 1u, "format version = " << version << " not supported");
59 ar(cereal::make_nvp("uuid", RB::mId));
60 ar(cereal::make_nvp("this", RB::mThis));
61 ar(cereal::make_nvp("sub", mRVec));
62 }
63
64 /*============+
65 | load |
66 +============*/
67
68 template <class Archive>
69 void load(Archive& ar, Uuid& id)
70 {
71 ar(CEREAL_NVP(id.i1));
72 ar(CEREAL_NVP(id.i2));
73 }
74
75 template <class Archive>
76 void CRange::load(Archive& ar, const std::uint32_t version)
77 {
78 CXZ_ASSERT(version == 1u, "format version = " << version << " not supported");
79 ar(cereal::make_nvp("uuid", RB::mId));
80 ar(cereal::make_nvp("this", RB::mThis));
81 ar(cereal::make_nvp("size", mSize));
82 CXZ_ASSERT(RangePtr(RB::mThis).get() == this, "got corrupted range data"); // yes, cereal is that awesome! :)
83 }
84
85 template <class MetaT>
86 template <class Archive>
87 void URange<MetaT>::load(Archive& ar, const std::uint32_t version)
88 {
89 CXZ_ASSERT(version == 1u, "format version = " << version << " not supported");
90 ar(cereal::make_nvp("uuid", RB::mId));
91 ar(cereal::make_nvp("this", RB::mThis));
92 ar(cereal::make_nvp("meta", mSpace));
93 CXZ_ASSERT(RangePtr(RB::mThis).get() == this, "got corrupted range data");
94 }
95
96 template <class Archive>
97 void YRange::load(Archive& ar, const std::uint32_t version)
98 {
99 CXZ_ASSERT(version == 1u, "format version = " << version << " not supported");
100 ar(cereal::make_nvp("uuid", RB::mId));
101 ar(cereal::make_nvp("this", RB::mThis));
102 ar(cereal::make_nvp("sub", mRVec));
103 CXZ_ASSERT(RangePtr(RB::mThis).get() == this, "got corrupted range data");
104 // register range:
105 for(auto& r: mRVec){
106 r = RangeFactoryBase::getRegistered(r->type(), r);
107 }
108 }
109}
110
111#endif
#define CXZ_ASSERT(statement, errmsg)
Definition assert.h:40
basic headers
SizeT get(SizeT pos) const
Definition crange.cc:200
SizeT mSize
Definition crange.h:207
Wptr< RangeBase > mThis
Definition range_base.h:173
static RangePtr getRegistered(const TypeInfo &info, const RangePtr &r)
Definition range_base.cc:49
CRange and CIndex declaration.
void load(Archive &ar, Uuid &id)
Sptr< RangeBase > RangePtr
Definition types.h:157
Sptr< Range > rangeCast(const RangePtr r)
void save(Archive &ar, const Uuid &id)
URange, URangeFactory and UIndex declaration.
YRange and YIndex declaration.