CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Serialization.cc
Go to the documentation of this file.
5 //
6 #include <sstream>
7 // root includes
8 #include "TBufferFile.h"
9 #include "TClass.h"
10 #include "Cintex/Cintex.h"
11 
12 namespace cond {
13 
16  ROOT::Cintex::Cintex::Enable();
17  }
18  };
19 
20  // initialize Cintex and load dictionary when required
21  TClass* lookUpDictionary( const std::type_info& sourceType ){
22  static const CintexIntializer initializer;
23  TClass* rc = TClass::GetClass(sourceType);
24  if( !rc ){
25  static std::string const prefix("LCGReflex/");
26  std::string name = demangledName(sourceType);
27  edmplugin::PluginCapabilities::get()->load(prefix + name);
28  rc = TClass::GetClass(sourceType);
29  }
30  return rc;
31  }
32 }
33 
35  m_buffer( dest ){
36 }
37 
38 void cond::RootOutputArchive::write( const std::type_info& sourceType, const void* sourceInstance){
39  TClass* r_class = lookUpDictionary( sourceType );
40  if (!r_class) throwException( "No ROOT class registered for \"" + demangledName(sourceType)+"\"", "RootOutputArchive::write");
41  TBufferFile buffer(TBufferFile::kWrite);
42  buffer.InitMap();
43  buffer.StreamObject(const_cast<void*>(sourceInstance), r_class);
44  // copy the stream into the target buffer
45  m_buffer.write( static_cast<const char*>(buffer.Buffer()), buffer.Length() );
46 }
47 
49  m_buffer( std::istreambuf_iterator<char>(source), std::istreambuf_iterator<char>()),
50  m_streamer( new TBufferFile( TBufferFile::kRead, m_buffer.size(), const_cast<char*>(m_buffer.c_str()), kFALSE ) ){
51  m_streamer->InitMap();
52 }
53 
55  delete m_streamer;
56 }
57 
58 void cond::RootInputArchive::read( const std::type_info& destinationType, void* destinationInstance){
59  TClass* r_class = lookUpDictionary( destinationType );
60  if (!r_class) throwException( "No ROOT class registered for \"" + demangledName(destinationType) +"\"","RootInputArchive::read");
61  m_streamer->StreamObject(destinationInstance, r_class);
62 }
63 
void read(const std::type_info &destinationType, void *destinationInstance)
TBufferFile * m_streamer
Definition: Serialization.h:74
std::string demangledName(const std::type_info &typeInfo)
Definition: ClassUtils.cc:82
void write(const std::type_info &sourceType, const void *sourceInstance)
static PluginCapabilities * get()
RootInputArchive(std::istream &source)
RootOutputArchive(std::ostream &destination)
TClass * lookUpDictionary(const std::type_info &sourceType)
void throwException(std::string const &message, std::string const &methodName)
Definition: Exception.cc:17
void load(const std::string &iName)
static std::string const source
Definition: EdmProvDump.cc:43
tuple size
Write out results.