test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
Test.h File Reference
#include <string>
#include <iostream>
#include <fstream>
#include <utility>
#include <stdexcept>
#include "CondFormats/Serialization/interface/Archive.h"
#include "CondFormats/Serialization/interface/Equal.h"

Go to the source code of this file.

Functions

template<typename T >
void testSerialization ()
 

Function Documentation

template<typename T >
void testSerialization ( )

Definition at line 47 of file Test.h.

References gather_cfg::cout, lut2db_cfg::filename, recoMuon::in, mergeVDriftHistosByStation::name, dbtoconf::out, and AlCaHLTBitMon_QueryRunRegistry::string.

48 {
49  const std::string filename(std::string(typeid(T).name()) + ".bin");
50 
51  // C++ does not allow to construct const objects
52  // of non-POD types without user-provided default constructor
53  // (since it would be uninitialized), so we always create
54  // a non-const object.
55  T originalObject;
56  const T & originalObjectRef = originalObject;
57  {
58  std::ofstream ofs(filename, std::ios::out | std::ios::binary);
60  std::cout << "Serializing " << typeid(T).name() << " ..." << std::endl;
61  oa << originalObjectRef;
62  }
63 
64  T deserializedObject;
65  {
66  std::ifstream ifs(filename, std::ios::in | std::ios::binary);
68  std::cout << "Deserializing " << typeid(T).name() << " ..." << std::endl;
69  ia >> deserializedObject;
70  }
71 
72  // TODO: First m,ake the Boost IO compile and run properly,
73  // then focus again on the equal() functions.
74  //std::cout << "Checking " << typeid(T).name() << " ..." << std::endl;
75  //if (not cond::serialization::equal(originalObject, deserializedObject))
76  // throw std::logic_error("Object is not equal.");
77 }
eos::portable_oarchive OutputArchive
Definition: Archive.h:13
eos::portable_iarchive InputArchive
Definition: Archive.h:12
tuple out
Definition: dbtoconf.py:99
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:121
long double T