DUDS
Distributed Update of Data from Something
GenericValue.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of the DUDS project. It is subject to the BSD-style
3  * license terms in the LICENSE file found in the top-level directory of this
4  * distribution and at https://github.com/jjackowski/duds/blob/master/LICENSE.
5  * No part of DUDS, including this file, may be copied, modified, propagated,
6  * or distributed except according to the terms contained in the LICENSE file.
7  *
8  * Copyright (C) 2017 Jeff Jackowski
9  */
10 #ifndef VALUE_HPP
11 #define VALUE_HPP
12 
13 // Avoids dependency on the Boost type traits library. Not sure this is a good
14 // idea, but it must have made some sense back when I wrote this.
15 #define BOOST_UUID_NO_TYPE_TRAITS
18 #include <boost/uuid/uuid.hpp>
19 #include <boost/variant.hpp>
20 //#include <array>
21 #undef BOOST_UUID_NO_TYPE_TRAITS
22 
23 namespace duds { namespace data {
24 
25 // forward declaration to make the following typedef work
27 
84 typedef boost::variant<
85  // strings
86  std::string,
88  // integers
89  //std::array<std::int16_t, 8>, // limited usefulness
90  std::array<std::int32_t, 4>,
91  std::array<std::int64_t, 2>,
92  duds::data::int128_w, // no implicit conversions; doubles do not become ints
93  // floating point
94  std::array<float, 4>,
95  std::array<double, 2>, // maybe remove
96  double, // numeric assignments go here, even integers
98  boost::recursive_wrapper<duds::data::QuantityNddArray>,
99  //duds::ExtendedQuantity<double>,
100  // time
105  // identification
106  boost::uuids::uuid,
107  // complex hierarchical data
108  boost::recursive_wrapper<duds::data::GenericValueTable>,
109  //std::shared_ptr<GenericValueTable>,
110 
111  // maybe a table with UUID keys?
112 
113  // arbitrary data; remove?
114  std::shared_ptr< std::vector<char> >
115 
116 > GenericValue;
117 
118 typedef std::map<std::string, GenericValue> generic_value_table_base_t;
119 
128 class GenericValueTable : public generic_value_table_base_t {
130  template <class A>
131  void serialize(A &a, const unsigned int) {
132  a & BOOST_SERIALIZATION_BASE_OBJECT_NVP(generic_value_table_base_t);
133  }
134 };
135 
136 } }
137 
138 #endif // #ifndef VALUE_HPP
boost::variant< std::string, duds::general::LanguageTaggedString, std::array< std::int32_t, 4 >, std::array< std::int64_t, 2 >, duds::data::int128_w, std::array< float, 4 >, std::array< double, 2 >, double, duds::data::Quantity, boost::recursive_wrapper< duds::data::QuantityNddArray >, duds::time::interstellar::Femtoseconds, duds::time::interstellar::Nanoseconds, duds::time::interstellar::FemtoTime, duds::time::interstellar::NanoTime, boost::uuids::uuid, boost::recursive_wrapper< duds::data::GenericValueTable >, std::shared_ptr< std::vector< char > >> GenericValue
A general value of a type can be serialized for transmission over a network and can be used with a re...
A container for a value and a unit to better describe the value.
Definition: Quantity.hpp:37
std::map< std::string, GenericValue > generic_value_table_base_t
LargeIntWrapper< int128_t, boost::multiprecision::int128_t > int128_w
A 128-bit integer wrapped by LargeIntWrapper to make the Boost serialized result interchangable betwe...
Definition: Int128.hpp:205
Holds a string and its associated language.
std::chrono::duration< int128_t, std::femto > Femtoseconds
Stores a duration in femtoseconds.
FemtoClock::time_point FemtoTime
A point in time in Interstellar Time stored in Femtoseconds.
friend class boost::serialization::access
A set of key-value pairs where the value can be one of several types.
std::chrono::duration< std::uint64_t, std::nano > Nanoseconds
Stores a duration in nanoseconds.
void serialize(A &a, const unsigned int)
NanoClock::time_point NanoTime
A point in time in Interstellar Time stored in Nanoseconds.