Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:11

0001 #ifndef CondFormats_External_CLHEP_H
0002 #define CondFormats_External_CLHEP_H
0003 
0004 #include <boost/serialization/base_object.hpp>
0005 #include <boost/serialization/nvp.hpp>
0006 #include <boost/serialization/split_free.hpp>
0007 
0008 // std::vector used in DataFormats/EcalDetId/interface/EcalContainer.h
0009 #include <boost/serialization/vector.hpp>
0010 #include <boost/serialization/string.hpp>
0011 #include <boost/serialization/map.hpp>
0012 
0013 #include "CLHEP/Vector/EulerAngles.h"
0014 #include "CLHEP/Vector/ThreeVector.h"
0015 
0016 namespace boost {
0017   namespace serialization {
0018 
0019     /*
0020  * Note regarding object tracking: all autos used here
0021  * must resolve to untracked types, since we use local
0022  * variables in the stack which could end up with the same
0023  * address. For the moment, all types resolved by auto here
0024  * are primitive types, which are untracked by default
0025  * by Boost Serialization.
0026  */
0027 
0028     // CLHEP/Vector/ThreeVector.h
0029     template <class Archive>
0030     void save(Archive& ar, const CLHEP::Hep3Vector& obj, const unsigned int) {
0031       auto dx = obj.x();
0032       auto dy = obj.y();
0033       auto dz = obj.z();
0034       ar& BOOST_SERIALIZATION_NVP(dx);
0035       ar& BOOST_SERIALIZATION_NVP(dy);
0036       ar& BOOST_SERIALIZATION_NVP(dz);
0037     }
0038 
0039     template <class Archive>
0040     void load(Archive& ar, CLHEP::Hep3Vector& obj, const unsigned int) {
0041       decltype(obj.x()) dx;
0042       decltype(obj.y()) dy;
0043       decltype(obj.z()) dz;
0044       ar& BOOST_SERIALIZATION_NVP(dx);
0045       ar& BOOST_SERIALIZATION_NVP(dy);
0046       ar& BOOST_SERIALIZATION_NVP(dz);
0047       obj.set(dx, dy, dz);
0048     }
0049 
0050     template <class Archive>
0051     void serialize(Archive& ar, CLHEP::Hep3Vector& obj, const unsigned int v) {
0052       split_free(ar, obj, v);
0053     }
0054 
0055     // CLHEP/Vector/EulerAngles.h
0056     template <class Archive>
0057     void save(Archive& ar, const CLHEP::HepEulerAngles& obj, const unsigned int) {
0058       auto phi_ = obj.phi();
0059       auto theta_ = obj.theta();
0060       auto psi_ = obj.psi();
0061       ar& BOOST_SERIALIZATION_NVP(phi_);
0062       ar& BOOST_SERIALIZATION_NVP(theta_);
0063       ar& BOOST_SERIALIZATION_NVP(psi_);
0064     }
0065 
0066     template <class Archive>
0067     void load(Archive& ar, CLHEP::HepEulerAngles& obj, const unsigned int) {
0068       decltype(obj.phi()) phi_;
0069       decltype(obj.theta()) theta_;
0070       decltype(obj.psi()) psi_;
0071       ar& BOOST_SERIALIZATION_NVP(phi_);
0072       ar& BOOST_SERIALIZATION_NVP(theta_);
0073       ar& BOOST_SERIALIZATION_NVP(psi_);
0074       obj.set(phi_, theta_, psi_);
0075     }
0076 
0077     template <class Archive>
0078     void serialize(Archive& ar, CLHEP::HepEulerAngles& obj, const unsigned int v) {
0079       split_free(ar, obj, v);
0080     }
0081 
0082   }  // namespace serialization
0083 }  // namespace boost
0084 
0085 #endif