1 #ifndef CondCore_CondDB_Serialization_h
2 #define CondCore_CondDB_Serialization_h
23 #include <boost/shared_ptr.hpp>
34 if( userTypeName != payloadTypeName )
51 void write(
const std::type_info& sourceType,
const void* sourceInstance);
59 write(
typeid(
T), &instance );
66 RootInputArchive( std::istream& binaryData, std::istream& binaryStreamerInfo );
74 void read(
const std::type_info& destinationType,
void* destinationInstance);
83 read(
typeid(
T), &instance );
92 template <
typename T> std::pair<Binary,Binary>
serialize(
const T& payload,
bool packingOnly =
false ){
93 std::pair<Binary,Binary>
ret;
96 std::ostringstream dataBuffer;
97 std::ostringstream streamerInfoBuffer;
101 ret.first.copy( dataBuffer.str() );
102 ret.second.copy( streamerInfoBuffer.str() );
105 ret.first =
Binary( payload );
113 const Binary& payloadData,
114 const Binary& streamerInfoData,
115 bool unpackingOnly ){
116 boost::shared_ptr<T> payload;
117 if( !unpackingOnly ){
118 std::stringbuf sdataBuf;
119 sdataBuf.pubsetbuf( static_cast<char*>(const_cast<void*>(payloadData.
data())), payloadData.
size() );
120 std::stringbuf sstreamerInfoBuf;
121 sstreamerInfoBuf.pubsetbuf( static_cast<char*>(const_cast<void*>(streamerInfoData.
data())), streamerInfoData.
size() );
123 std::istream dataBuffer( &sdataBuf );
124 std::istream streamerInfoBuffer( &sstreamerInfoBuf );
126 payload.reset( createPayload<T>(payloadType) );
137 const Binary& payloadData,
138 const Binary& streamerInfoData,
139 bool unpackingOnly =
false){
140 return default_deserialize<T>( payloadType, payloadData, streamerInfoData, unpackingOnly );
145 #define DESERIALIZE_BASE_CASE( BASETYPENAME ) \
146 if( payloadType == #BASETYPENAME ){ \
147 return default_deserialize<BASETYPENAME>( payloadType, payloadData, streamerInfoData, unpackingOnly ); \
150 #define DESERIALIZE_POLIMORPHIC_CASE( BASETYPENAME, DERIVEDTYPENAME ) \
151 if( payloadType == #DERIVEDTYPENAME ){ \
152 return boost::dynamic_pointer_cast<BASETYPENAME>( default_deserialize<DERIVEDTYPENAME>( payloadType, payloadData, streamerInfoData, unpackingOnly ) ); \
eos::portable_oarchive OutputArchive
boost::shared_ptr< void > makeShared() const
static PFTauRenderPlugin instance
cond::serialization::InputArchive CondInputArchive
eos::portable_iarchive InputArchive
std::ostream & m_streamerInfoBuffer
RootOutputArchive(std::ostream &dataDest, std::ostream &streamerInfoDest)
std::string demangledName(const std::type_info &typeInfo)
void write(const std::type_info &sourceType, const void *sourceInstance)
T * createPayload(const std::string &payloadTypeName)
ora::Object oraObject() const
const void * data() const
RootOutputArchive & operator<<(const T &instance)
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)
std::ostream & m_dataBuffer
boost::shared_ptr< T > default_deserialize(const std::string &payloadType, const Binary &payloadData, const Binary &streamerInfoData, bool unpackingOnly)