srecord: memory/walker/fletcher16.h Source File

srecord 1.65.0

Loading...
Searching...
No Matches
fletcher16.h
Go to the documentation of this file.
1//
2// srecord - Manipulate EPROM load files
3// Copyright (C) 2009-2011 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 (at
8// 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 GNU
13// 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 <http://www.gnu.org/licenses/>.
17//
18
19#ifndef SRECORD_MEMORY_WALKER_FLETCHER16_H
20#define SRECORD_MEMORY_WALKER_FLETCHER16_H
21
22#include <srecord/fletcher16.h>
23#include <srecord/memory/walker.h>
24
25namespace srecord
26{
27
28/**
29 * The srecord::memory_walker_fletcher16 class is used to represent the parse
30 * state of a memory walker which calculates a running Fletcher-16 checksum.
31 */
32 class memory_walker_fletcher16:
33 public memory_walker
34{
35public:
36 typedef std::shared_ptr<memory_walker_fletcher16> pointer;
37
38 /**
39 * The destructor.
40 */
41 virtual ~memory_walker_fletcher16();
42
43private:
44 /**
45 * The constructor. It is private on purpose, use the
46 * #create method instead.
47 *
48 * @param sum1
49 * The seed value for sum1. Defaults to zero.
50 * @param sum2
51 * The seed value for sum2. Defaults to zero.
52 * @param answer
53 * Set this to -1 to be completely ignored.
54 * If >= 0, this is the desired outcome if the checksum
55 * includes the checksum itself. The checksum returned will be
56 * calculated to return this desired outcome, when traversed,
57 * rather than a pure Fletcher-16 checksum.
58 * @param end
59 * The endian-ness of the checksum. This is needed to
60 * manipulate the answer. Ignored if answer is ignored.
61 */
62 memory_walker_fletcher16(int sum1, int sum2, int answer, endian_t end);
63
64public:
65 /**
66 * The create class method is used to create new dynamically
67 * allocated instances of this class.
68 *
69 * @param sum1
70 * The seed value for sum1. Defaults to zero.
71 * @param sum2
72 * The seed value for sum2. Defaults to zero.
73 * @param answer
74 * Set this to -1 to be completely ignored.
75 * If >= 0, this is the desired outcome if the checksum
76 * includes the checksum itself. The checksum returned will be
77 * calculated to return this desired outcome, when traversed,
78 * rather than a pure Fletcher-16 checksum.
79 * @param end
80 * The endian-ness of the checksum. This is needed to
81 * manipulate the answer. Ignored if answer is ignored.
82 */
83 static pointer create(int sum1, int sum2, int answer, endian_t end);
84
85 /**
86 * The get method is used to get the Fletcher-16 checksum once all memory
87 * chunks have been processed by calls to our #observe method.
88 */
89 unsigned get(void) const;
90
91protected:
92 // See base class for documentation.
93 void observe(unsigned long address, const void *data, int data_size);
94
95private:
96 /**
97 * The checksum instance variable is used to remember the running
98 * state of the Fletcher-16 checksum calculation.
99 */
100 fletcher16 checksum;
101
102 /**
103 * The default constructor. Do not use.
104 */
105 memory_walker_fletcher16();
106
107 /**
108 * The copy constructor. Do not use.
109 */
110 memory_walker_fletcher16(const memory_walker_fletcher16 &);
111
112 /**
113 * The assignment operator. Do not use.
114 */
115 memory_walker_fletcher16 &operator=(const memory_walker_fletcher16 &);
116};
117
118};
119
120// vim: set ts=8 sw=4 et :
121#endif // SRECORD_MEMORY_WALKER_FLETCHER16_H
srecord::fletcher16
The fletcher16 class is used to represent the running value of a 16-bit Fletcher's Checksum of series...
Definition fletcher16.h:59
srecord::memory_walker_fletcher16::create
static pointer create(int sum1, int sum2, int answer, endian_t end)
The create class method is used to create new dynamically allocated instances of this class.
srecord::memory_walker_fletcher16::~memory_walker_fletcher16
virtual ~memory_walker_fletcher16()
The destructor.
srecord::memory_walker_fletcher16::observe
void observe(unsigned long address, const void *data, int data_size)
The observe method is used by the memory walker to provide data.
srecord::memory_walker_fletcher16::pointer
std::shared_ptr< memory_walker_fletcher16 > pointer
Definition fletcher16.h:36
srecord::memory_walker_fletcher16::get
unsigned get(void) const
The get method is used to get the Fletcher-16 checksum once all memory chunks have been processed by ...
srecord::memory_walker::memory_walker
memory_walker()
The default constructor.
fletcher16.h
srecord
Definition adler16.h:25
srecord::endian_t
endian_t
Definition endian.h:27
walker.h