CMS 3D CMS Logo

cscPackerCompare.h
Go to the documentation of this file.
1 #include <iostream>
2 #include <typeinfo>
4 
5 
9 template <class T>
10 bool cscPackerCompare(const T & t1, const T & t2)
11 {
12  bool result = true;
13  if(t1 != t2) {
14  std::cerr << "Mismatch:\n"<< t1 << "\n" << t2 << std::endl;
15  result = false;
16  }
17  return result;
18 }
19 
20 
21 template <class T>
23 {
24  boost::dynamic_bitset<> firstPack = t.pack();
25  unsigned char data[10000];
26  bitset_utilities::bitsetToChar(firstPack, data);
27  return T((unsigned short int *)data);
28 }
29 
30 
31 // packs a class, then unpacks, packs again, and compares
32 template <class T>
34 {
35  boost::dynamic_bitset<> firstPack = t.pack();
36  unsigned char data[1000];
37  bitset_utilities::bitsetToChar(firstPack, data);
38  T newObject((unsigned short int *)data);
39  boost::dynamic_bitset<> secondPack = newObject.pack();
40  if(firstPack != secondPack)
41  {
42  std::cerr << "Mismatch in " << typeid(t).name() << "\n";
44  bitset_utilities::printWords(secondPack);
45  return false;
46  }
47  return true;
48 }
49 
bool cscClassPackerCompare(T &t)
void printWords(const boost::dynamic_bitset<> &bs)
void bitsetToChar(const boost::dynamic_bitset<> &bs, unsigned char *result)
this method takes bitset obj and returns char * array
bool cscPackerCompare(const T &t1, const T &t2)
T cscPackAndUnpack(T &t)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
long double T