1 #ifndef CondCore_CondDB_Serialization_h
2 #define CondCore_CondDB_Serialization_h
23 #include <boost/shared_ptr.hpp>
32 if( userTypeName != payloadTypeName )
55 template <
typename T> std::pair<Binary,Binary>
serialize(
const T& payload,
bool packingOnly =
false ){
56 std::pair<Binary,Binary>
ret;
61 std::ostringstream dataBuffer;
65 ret.first.copy( dataBuffer.str() );
66 ret.second.copy( streamerInfo );
69 throwException(
"Serialization failed: "+em+
". Serialization info:"+streamerInfo,
"serialize");
73 ret.first =
Binary( payload );
82 const Binary& streamerInfoData,
84 boost::shared_ptr<T> payload;
86 std::stringbuf sstreamerInfoBuf;
87 sstreamerInfoBuf.pubsetbuf( static_cast<char*>(const_cast<void*>(streamerInfoData.
data())), streamerInfoData.
size() );
90 std::stringbuf sdataBuf;
91 sdataBuf.pubsetbuf( static_cast<char*>(const_cast<void*>(payloadData.
data())), payloadData.
size() );
92 std::istream dataBuffer( &sdataBuf );
94 payload.reset( createPayload<T>(payloadType) );
99 if( em ==
"unsupported version" ) {
101 ") is unable to read the payload. Data might have been serialized with an incompatible version.";
102 }
else if( em ==
"input stream error" ) {
103 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.";
107 if( !streamerInfo.empty() ) errorMsg +=
" Payload serialization info: "+streamerInfo;
119 const Binary& payloadData,
120 const Binary& streamerInfoData,
121 bool unpackingOnly =
false){
122 return default_deserialize<T>(
payloadType, payloadData, streamerInfoData, unpackingOnly );
127 #define DESERIALIZE_BASE_CASE( BASETYPENAME ) \
128 if( payloadType == #BASETYPENAME ){ \
129 return default_deserialize<BASETYPENAME>( payloadType, payloadData, streamerInfoData, unpackingOnly ); \
132 #define DESERIALIZE_POLIMORPHIC_CASE( BASETYPENAME, DERIVEDTYPENAME ) \
133 if( payloadType == #DERIVEDTYPENAME ){ \
134 return boost::dynamic_pointer_cast<BASETYPENAME>( default_deserialize<DERIVEDTYPENAME>( payloadType, payloadData, streamerInfoData, unpackingOnly ) ); \
eos::portable_oarchive OutputArchive
static char const * CMSSW_VERSION_LABEL
static std::string techVersion()
boost::shared_ptr< void > makeShared() const
static char const * TECH_LABEL
cond::serialization::InputArchive CondInputArchive
eos::portable_iarchive InputArchive
std::string demangledName(const std::type_info &typeInfo)
T * createPayload(const std::string &payloadTypeName)
static char const * TECHNOLOGY
ora::Object oraObject() const
static char const * TECH_VERSION_LABEL
const void * data() const
static std::string jsonString()
cond::serialization::OutputArchive CondOutputArchive
void throwException(std::string const &message, std::string const &methodName)
boost::shared_ptr< T > deserialize(const std::string &payloadType, const Binary &payloadData, const Binary &streamerInfoData, bool unpackingOnly=false)
std::pair< Binary, Binary > serialize(const T &payload, bool packingOnly=false)
static char const * ARCH_LABEL
boost::shared_ptr< T > default_deserialize(const std::string &payloadType, const Binary &payloadData, const Binary &streamerInfoData, bool unpackingOnly)