1 #ifndef CondCore_CondDB_Serialization_h
2 #define CondCore_CondDB_Serialization_h
23 #include <boost/shared_ptr.hpp>
32 if( userTypeName != payloadTypeName )
54 template <
typename T> std::pair<Binary,Binary>
serialize(
const T& payload ){
55 std::pair<Binary,Binary>
ret;
59 std::ostringstream dataBuffer;
63 ret.first.copy( dataBuffer.str() );
64 ret.second.copy( streamerInfo );
67 throwException(
"Serialization failed: "+em+
". Serialization info:"+streamerInfo,
"serialize");
75 const Binary& streamerInfoData ){
76 boost::shared_ptr<T> payload;
77 std::stringbuf sstreamerInfoBuf;
78 sstreamerInfoBuf.pubsetbuf( static_cast<char*>(const_cast<void*>(streamerInfoData.
data())), streamerInfoData.
size() );
81 std::stringbuf sdataBuf;
82 sdataBuf.pubsetbuf( static_cast<char*>(const_cast<void*>(payloadData.
data())), payloadData.
size() );
83 std::istream dataBuffer( &sdataBuf );
85 payload.reset( createPayload<T>(payloadType) );
90 if( em ==
"unsupported version" ) {
92 ") is unable to read the payload. Data might have been serialized with an incompatible version.";
93 }
else if( em ==
"input stream error" ) {
94 errorMsg +=
"data size does not fit with the current class layout. The Class "+payloadType+
" might have been changed with respect to the layout used in the upload.";
98 if( !streamerInfo.empty() ) errorMsg +=
" Payload serialization info: "+streamerInfo;
106 const Binary& payloadData,
107 const Binary& streamerInfoData ){
108 return default_deserialize<T>(
payloadType, payloadData, streamerInfoData );
113 #define DESERIALIZE_BASE_CASE( BASETYPENAME ) \
114 if( payloadType == #BASETYPENAME ){ \
115 return default_deserialize<BASETYPENAME>( payloadType, payloadData, streamerInfoData ); \
118 #define DESERIALIZE_POLIMORPHIC_CASE( BASETYPENAME, DERIVEDTYPENAME ) \
119 if( payloadType == #DERIVEDTYPENAME ){ \
120 return boost::dynamic_pointer_cast<BASETYPENAME>( default_deserialize<DERIVEDTYPENAME>( payloadType, payloadData, streamerInfoData ) ); \
eos::portable_oarchive OutputArchive
tuple ret
prodAgent to be discontinued
static char const * CMSSW_VERSION_LABEL
static std::string techVersion()
std::pair< Binary, Binary > serialize(const T &payload)
static char const * TECH_LABEL
cond::serialization::InputArchive CondInputArchive
eos::portable_iarchive InputArchive
void throwException(const std::string &message, const std::string &methodName)
std::string demangledName(const std::type_info &typeInfo)
boost::shared_ptr< T > deserialize(const std::string &payloadType, const Binary &payloadData, const Binary &streamerInfoData)
T * createPayload(const std::string &payloadTypeName)
static char const * TECHNOLOGY
static char const * TECH_VERSION_LABEL
const void * data() const
static std::string jsonString()
cond::serialization::OutputArchive CondOutputArchive
boost::shared_ptr< T > default_deserialize(const std::string &payloadType, const Binary &payloadData, const Binary &streamerInfoData)
static char const * ARCH_LABEL