LDMX Software
CRC.h
1#ifndef PACKING_UTILITY_CRC_H_
2#define PACKING_UTILITY_CRC_H_
3
4#include <boost/crc.hpp>
5
6namespace packing {
7namespace utility {
8
50class CRC {
51 public:
63 template <typename WordType,
64 std::enable_if_t<std::is_integral<WordType>::value, bool> = true>
65 CRC& operator<<(const WordType& w) {
66 crc.process_bytes(&w, sizeof(WordType));
67 return *this;
68 }
69
84 template <typename ObjectType,
85 std::enable_if_t<std::is_class<ObjectType>::value, bool> = true>
86 CRC& operator<<(const ObjectType& o) {
87 return o.add(*this);
88 }
89
100 template <typename ContentType>
101 CRC& operator<<(const std::vector<ContentType>& vec) {
102 for (auto const& w : vec) *this << w;
103 return *this;
104 }
105
110 uint32_t get() { return crc.checksum(); }
111
112 private:
114 boost::crc_32_type crc;
115}; // CRC
116
117} // namespace utility
118} // namespace packing
119
120#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:50
CRC & operator<<(const WordType &w)
Stream an integral type into the calculator.
Definition CRC.h:65
uint32_t get()
Get the calculate checksum from the calculator.
Definition CRC.h:110
CRC & operator<<(const std::vector< ContentType > &vec)
Stream a vector of objects into the calculator.
Definition CRC.h:101
CRC & operator<<(const ObjectType &o)
Stream an instance of a class into the calculator.
Definition CRC.h:86
boost::crc_32_type crc
the object from Boost doing the summing
Definition CRC.h:114