srecord  1.65.0
crc16.h
Go to the documentation of this file.
1 //
2 // srecord - manipulate eprom load files
3 // Copyright (C) 2000, 2002, 2006-2010 Peter Miller
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this program. If not, see
17 // <http://www.gnu.org/licenses/>.
18 //
19 
20 #ifndef SRECORD_MEMORY_WALKER_CRC16_H
21 #define SRECORD_MEMORY_WALKER_CRC16_H
22 
23 #include <srecord/crc16.h>
24 #include <srecord/memory/walker.h>
25 
26 namespace srecord
27 {
28 
29 /**
30  * The srecord::memory_walker_crc16 class is used to represent the parse
31  * state of a memory walker which calculates a running CRC16 checksum.
32  */
34  public memory_walker
35 {
36 public:
37  typedef std::shared_ptr<memory_walker_crc16> pointer;
38 
39  /**
40  * The destructror.
41  */
43 
44 private:
45  /**
46  * The default constructor. It is private on purpose, use the
47  * #create class method instead.
48  *
49  * @param seed_mode
50  * The selector for the initial seed for the calculation
51  * @param augment_flag
52  * Whether or not to augment the calculation
53  * @param polynomial
54  * The CRC polynomial to be used.
55  * @param bitdir
56  * the bit direction of the CRC.
57  */
58  memory_walker_crc16(crc16::seed_mode_t seed_mode, bool augment_flag,
59  unsigned short polynomial, crc16::bit_direction_t bitdir);
60 
61 public:
62  /**
63  * The create class method is used to create new dynamically
64  * allocated instances of this class.
65  *
66  * @param seed_mode
67  * The selector for the initial seed for the calculation
68  * @param augment_flag
69  * Whether or not to augment the calculation
70  * @param polynomial
71  * The CRC polynomial to be used.
72  * @param bitdir
73  * the bit direction of the CRC
74  */
75  static pointer create(crc16::seed_mode_t seed_mode, bool augment_flag,
76  unsigned short polynomial, crc16::bit_direction_t bitdir);
77 
78  /**
79  * The get method is used to get the CRC16 checksum once all memory
80  * chunks have been processed by calls to our observe method.
81  */
82  unsigned get() const;
83 
84 protected:
85  // See base class for documentation.
86  void observe(unsigned long, const void *, int);
87 
88 private:
89  /**
90  * The checksum instance variable is used to remember the running
91  * state of the CRC16 checksum calculation.
92  */
93  crc16 *checksum;
94 
95  /**
96  * The copy constructor. No not use.
97  */
99 
100  /**
101  * The assignment operator. No not use.
102  */
103  memory_walker_crc16 &operator=(const memory_walker_crc16 &);
104 };
105 
106 };
107 
108 #endif // SRECORD_MEMORY_WALKER_CRC16_H
The crc16 class is used to represent the running value of a 16-bit cyclic redundancy check of series ...
Definition: crc16.h:43
The srecord::memory_walker_crc16 class is used to represent the parse state of a memory walker which ...
Definition: crc16.h:35
std::shared_ptr< memory_walker_crc16 > pointer
Definition: crc16.h:37
static pointer create(crc16::seed_mode_t seed_mode, bool augment_flag, unsigned short polynomial, crc16::bit_direction_t bitdir)
The create class method is used to create new dynamically allocated instances of this class.
unsigned get() const
The get method is used to get the CRC16 checksum once all memory chunks have been processed by calls ...
virtual ~memory_walker_crc16()
The destructror.
void observe(unsigned long, const void *, int)
The observe method is used by the memory walker to provide data.
The srecord::memory_walker class is used to represent an abstract handler for the action to perform w...
Definition: walker.h:34
std::shared_ptr< memory_walker > pointer
Definition: walker.h:36