23 #ifndef GRAPHLAB_CONDITIONAL_ADDITION_WRAPPER_HPP
24 #define GRAPHLAB_CONDITIONAL_ADDITION_WRAPPER_HPP
26 #include <graphlab/serialization/oarchive.hpp>
27 #include <graphlab/serialization/iarchive.hpp>
34 struct conditional_addition_wrapper {
38 conditional_addition_wrapper() : has_value(false), value(T()) {};
39 explicit conditional_addition_wrapper(
const T& t,
40 bool has_value =
true)
41 :has_value(has_value), value(t) {};
43 void set(
const T& t) {
60 bool not_empty()
const {
65 conditional_addition_wrapper&
66 operator+=(
const conditional_addition_wrapper<T>& c) {
67 if (has_value && c.has_value) {
71 else if (!has_value && c.has_value) {
79 conditional_addition_wrapper& operator+=(
const T& c) {
83 else if (!has_value) {
92 void save(oarchive& oarc)
const {
94 if (has_value) oarc << value;
98 void load(iarchive& iarc) {
100 if (has_value) iarc >> value;