Skip to content
Snippets Groups Projects
NeuronLogisticSerialization.h 3.66 KiB

#ifndef LIB4NEURO_NEURONLOGISTICSERIALIZATION_H
#define LIB4NEURO_NEURONLOGISTICSERIALIZATION_H

#include <boost/serialization/base_object.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/export.hpp>

#include "../constants.h"
#include "NeuronLogistic.h"
#include "NeuronSerialization.h"

BOOST_CLASS_EXPORT_KEY(lib4neuro::NeuronLogistic);
BOOST_CLASS_EXPORT_KEY(lib4neuro::NeuronLogistic_d1);
BOOST_CLASS_EXPORT_KEY(lib4neuro::NeuronLogistic_d2);

namespace lib4neuro {
    struct NeuronLogistic::access {
        template<class Archive>
        static void serialize(Archive& ar,
                              NeuronLogistic& n,
                              const unsigned int version) {
            ar & boost::serialization::base_object<Neuron>(n);
        }
    };

    struct NeuronLogistic_d1::access {
        template<class Archive>
        static void serialize(Archive& ar,
                              NeuronLogistic_d1& n,
                              const unsigned int version) {
            ar & boost::serialization::base_object<NeuronLogistic>(n);
        }
    };

    struct NeuronLogistic_d2::access {
        template<class Archive>
        static void serialize(Archive& ar,
                              NeuronLogistic_d2& n,
                              const unsigned int version) {
            ar & boost::serialization::base_object<NeuronLogistic_d1>(n);
        }
    };

}

namespace boost {
    namespace serialization {

        /**
         * Serialization function
         * @tparam Archive Boost library template
         * @param ar Boost parameter - filled automatically during serialization!
         * @param n NeuronLogistic instance
         * @param version Boost parameter - filled automatically during serialization!
         */
        template<class Archive>
        void serialize(Archive& ar,
                       lib4neuro::NeuronLogistic& n,
                       const unsigned int version) {
            lib4neuro::NeuronLogistic::access::serialize(ar,
                                                         n,
                                                         version);
        }

        /**
         * Serialization function
         * @tparam Archive Boost library template
         * @param ar Boost parameter - filled automatically during serialization!
         * @param n NeuronLogistic_d1 instance
         * @param version Boost parameter - filled automatically during serialization!
         */
        template<class Archive>
        void serialize(Archive& ar,
                       lib4neuro::NeuronLogistic_d1& n,
                       const unsigned int version) {
            lib4neuro::NeuronLogistic_d1::access::serialize(ar,
                                                            n,
                                                            version);
        }

        /**
         * Serialization function
         * @tparam Archive Boost library template
         * @param ar Boost parameter - filled automatically during serialization!
         * @param n NeuronLogistic_d2 instance
         * @param version Boost parameter - filled automatically during serialization!
         */
        template<class Archive>
        void serialize(Archive& ar,
                       lib4neuro::NeuronLogistic_d2& n,
                       const unsigned int version) {
            lib4neuro::NeuronLogistic_d2::access::serialize(ar,
                                                            n,
                                                            version);
        }

    } // namespace serialization
} // namespace boost

#endif //LIB4NEURO_NEURONLOGISTICSERIALIZATION_H