mi024

College project "Projet IAD" master 1
git clone https://esimon.eu/repos/mi024.git
Log | Files | Refs | README

nmlp_criterion_iostream.ipp (1356B)


      1 /**
      2  * @file
      3  * @brief nmlp criterions iostream function definitions.
      4  */
      5 
      6 #include "nmlp_base_iostream.hpp"
      7 #include "nmlp_criterion_iostream.hpp"
      8 #include "robber.hpp"
      9 
     10 template<class Archive>
     11 void serialize(Archive&,CPUMaxLoss&,unsigned const){
     12 	boost::serialization::void_cast_register<CPUMaxLoss, Criterion>();
     13 }
     14 
     15 #define DEFINE_FUNCTION_CRITERION_IO( NAME ) \
     16 	struct NAME ## _size_robber_tag: Tag_base<NAME ## _size_robber_tag, int NAME::*>{}; \
     17 	template struct Rob<NAME ## _size_robber_tag, &NAME::size>; \
     18 	template<class Archive> \
     19 	void save_construct_data(Archive &ar, NAME const *rhs, unsigned const){ \
     20 		ar << const_cast<NAME*>(rhs)->*get(NAME ## _size_robber_tag()); \
     21 	} \
     22 	template<class Archive> \
     23 	void load_construct_data(Archive &ar, NAME *rhs, unsigned const){ \
     24 		int size; \
     25 		ar >> size; \
     26 		new(rhs) NAME(size); \
     27 	} \
     28 	template<class Archive> \
     29 	void save(Archive&,NAME const&,unsigned const){ \
     30 		boost::serialization::void_cast_register<NAME, Criterion>(); \
     31 	} \
     32 	template<class Archive> \
     33 	void load(Archive&,NAME&,unsigned const){ \
     34 		boost::serialization::void_cast_register<NAME, Criterion>(); \
     35 	}
     36 
     37 DEFINE_FUNCTION_CRITERION_IO( CPUSquareLoss )
     38 DEFINE_FUNCTION_CRITERION_IO( CPUHingeLoss )
     39 DEFINE_FUNCTION_CRITERION_IO( GPUSquareLoss )
     40 DEFINE_FUNCTION_CRITERION_IO( GPUHingeLoss )
     41 
     42 #undef DEFINE_FUNCTION_CRITERION_IO
     43