LDMX Software
CRC.h
1#ifndef PACKING_UTILITY_CRC_H_
2#define PACKING_UTILITY_CRC_H_
3
4#include <boost/crc.hpp>
5#include <vector>
6
7namespace packing {
8namespace utility {
9
51class CRC {
52 public:
64 template <typename WordType,
65 std::enable_if_t<std::is_integral<WordType>::value, bool> = true>
66 CRC& operator<<(const WordType& w) {
67 crc_.process_bytes(&w, sizeof(WordType));
68 return *this;
69 }
70
85 template <typename ObjectType,
86 std::enable_if_t<std::is_class<ObjectType>::value, bool> = true>
87 CRC& operator<<(const ObjectType& o) {
88 return o.add(*this);
89 }
90
101 template <typename ContentType>
102 CRC& operator<<(const std::vector<ContentType>& vec) {
103 for (auto const& w : vec) *this << w;
104 return *this;
105 }
106
111 uint32_t get() { return crc_.checksum(); }
112
113 private:
115 boost::crc_32_type crc_;
116}; // CRC
117
118} // namespace utility
119} // namespace packing
120
121#endif // PACKING_UTILITY_CRC_H_
The HGC ROC and FPGA use a CRC checksum to double check that the data transfer has been done correctl...
Definition CRC.h:51
CRC & operator<<(const WordType &w)
Stream an integral type into the calculator.
Definition CRC.h:66
boost::crc_32_type crc_
the object from Boost doing the summing
Definition CRC.h:115
uint32_t get()
Get the calculate checksum from the calculator.
Definition CRC.h:111
CRC & operator<<(const std::vector< ContentType > &vec)
Stream a vector of objects into the calculator.
Definition CRC.h:102
CRC & operator<<(const ObjectType &o)
Stream an instance of a class into the calculator.
Definition CRC.h:87