IT++ Logo

crc.h

Go to the documentation of this file.
00001 
00030 #ifndef CRC_H
00031 #define CRC_H
00032 
00033 #include <itpp/base/vec.h>
00034 #include <itpp/base/mat.h>
00035 
00036 
00037 namespace itpp
00038 {
00039 
00065 class CRC_Code
00066 {
00067 public:
00068 
00070   CRC_Code() { reverse_parity = false; }
00071 
00079   CRC_Code(const std::string &code) { reverse_parity = false; set_code(code); }
00080 
00082   void set_generator(const bvec &poly);
00083 
00085   void set_code(const std::string &code);
00086 
00088   void parity(const bvec &in_bits, bvec &out) const;
00089 
00091   bool check_parity(const bvec &coded_bits) const;
00092 
00094   void encode(const bvec &in_bits, bvec &out) const;
00095 
00097   bvec encode(const bvec &in_bits) const;
00098 
00100   bool decode(const bvec &coded_bits, bvec &out) const;
00101 
00103   bool decode(bvec &bits) const;
00104 
00105 private:
00106   bool reverse_parity;
00107   bvec polynomial;
00108   int no_parity;
00109 };
00110 
00111 } // namespace itpp
00112 
00113 #endif // #ifndef CRC_H
SourceForge Logo

Generated on Thu Apr 23 20:04:04 2009 for IT++ by Doxygen 1.5.8