CMS 3D CMS Logo

cscPackerCompare.h
Go to the documentation of this file.
1 #include <iostream>
2 #include <typeinfo>
4 
8 template <class T>
9 bool cscPackerCompare(const T &t1, const T &t2) {
10  bool result = true;
11  if (t1 != t2) {
12  std::cerr << "Mismatch:\n" << t1 << "\n" << t2 << std::endl;
13  result = false;
14  }
15  return result;
16 }
17 
18 template <class T>
20  boost::dynamic_bitset<> firstPack = t.pack();
21  unsigned char data[10000];
22  bitset_utilities::bitsetToChar(firstPack, data);
23  return T((unsigned short int *)data);
24 }
25 
26 // packs a class, then unpacks, packs again, and compares
27 template <class T>
29  boost::dynamic_bitset<> firstPack = t.pack();
30  unsigned char data[1000];
31  bitset_utilities::bitsetToChar(firstPack, data);
32  T newObject((unsigned short int *)data);
33  boost::dynamic_bitset<> secondPack = newObject.pack();
34  if (firstPack != secondPack) {
35  std::cerr << "Mismatch in " << typeid(t).name() << "\n";
37  bitset_utilities::printWords(secondPack);
38  return false;
39  }
40  return true;
41 }
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:79
long double T