srecord
1.65.0
checksum.h
Go to the documentation of this file.
1
//
2
// srecord - manipulate eprom load files
3
// Copyright (C) 1998, 1999, 2001, 2002, 2005-2008, 2010, 2013 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_INPUT_FILTER_CHECKSUM_H
21
#define SRECORD_INPUT_FILTER_CHECKSUM_H
22
23
24
#include <
srecord/endian.h
>
25
#include <
srecord/interval.h
>
26
#include <
srecord/input/filter.h
>
27
#include <
srecord/record.h
>
28
29
namespace
srecord
{
30
31
/**
32
* The srecord::input_filter_checksum class is an abstraction of various
33
* checksums to be ammplied to input sources.
34
*/
35
class
input_filter_checksum
:
36
public
input_filter
37
{
38
public
:
39
/**
40
* The destructor.
41
*/
42
virtual
~input_filter_checksum
();
43
44
protected
:
45
// See bas class for documentation.
46
bool
read
(
record
&
record
);
47
48
/**
49
* The constructor.
50
* May only be called by derived classes.
51
*
52
* @param deeper
53
* The deeper input source being checksummed.
54
* @param address
55
* The address to place the checksum.
56
* @param length
57
* The number of bytes of checksum to be placed into the result.
58
* @param end
59
* The byte order
60
* @param width
61
* The width of the values being summed. Usually 1 byte, but
62
* wider combinations are possible. If you use something
63
* wider, it is assumed that they are alligned on multiples of
64
* that width, no provision for an offset is provided.
65
*/
66
input_filter_checksum
(
input::pointer
deeper,
int
address,
67
int
length
,
endian_t
end
,
int
width
= 1);
68
69
typedef
unsigned
long
sum_t
;
70
71
/**
72
* The checksum_address instance variable is used to remember where
73
* to place the checksum at the end of the data.
74
*/
75
int
checksum_address
;
76
77
/**
78
* The length instance variable is used to remember how many bytes
79
* of checksum are to be emitted.
80
*/
81
int
length
;
82
83
/**
84
* The end instance variable is used to remember whether the
85
* summation for the checksum is bigendian or little endian.
86
*/
87
endian_t
end
;
88
89
/**
90
* The sum instance variable is used to remember the running
91
* checksum of the incoming data source.
92
*/
93
sum_t
sum
;
94
95
/**
96
* The width instance variable is used to remember the swathe width
97
* as the incoming bytes are added to the running sum.
98
* That is, now many bytes wide.
99
*/
100
int
width
;
101
102
/**
103
* The calculate method is used to calculate the checksum to be
104
* written into the output, based on the "sum" instance variable.
105
*/
106
virtual
sum_t
calculate
(
void
) = 0;
107
108
/**
109
* The generate method is used to generate the final data record,
110
* once all of the deeper input has been passed through, based on
111
* the calculated checksum.
112
*
113
* @param record
114
* Where to place the returned data.
115
* @returns
116
* bool; false if end-of-file, true if data available
117
*/
118
bool
generate
(
record
&
record
);
119
120
private
:
121
/**
122
* The default constructor. Do not use.
123
*/
124
input_filter_checksum
();
125
126
/**
127
* The copy constructor. Do not use.
128
*/
129
input_filter_checksum
(
const
input_filter_checksum
&);
130
131
/**
132
* The assignment operator. Do not use.
133
*/
134
input_filter_checksum
&operator=(
const
input_filter_checksum
&);
135
};
136
137
};
138
139
#endif
// SRECORD_INPUT_FILTER_CHECKSUM_H
140
// vim: set ts=8 sw=4 et :
srecord::input_filter_checksum
The srecord::input_filter_checksum class is an abstraction of various checksums to be ammplied to inp...
Definition:
checksum.h:37
srecord::input_filter_checksum::generate
bool generate(record &record)
The generate method is used to generate the final data record, once all of the deeper input has been ...
srecord::input_filter_checksum::read
bool read(record &record)
The read method is used to read one record from the input.
srecord::input_filter_checksum::sum_t
unsigned long sum_t
Definition:
checksum.h:69
srecord::input_filter_checksum::length
int length
The length instance variable is used to remember how many bytes of checksum are to be emitted.
Definition:
checksum.h:81
srecord::input_filter_checksum::input_filter_checksum
input_filter_checksum(input::pointer deeper, int address, int length, endian_t end, int width=1)
The constructor.
srecord::input_filter_checksum::end
endian_t end
The end instance variable is used to remember whether the summation for the checksum is bigendian or ...
Definition:
checksum.h:87
srecord::input_filter_checksum::width
int width
The width instance variable is used to remember the swathe width as the incoming bytes are added to t...
Definition:
checksum.h:100
srecord::input_filter_checksum::calculate
virtual sum_t calculate(void)=0
The calculate method is used to calculate the checksum to be written into the output,...
srecord::input_filter_checksum::~input_filter_checksum
virtual ~input_filter_checksum()
The destructor.
srecord::input_filter_checksum::sum
sum_t sum
The sum instance variable is used to remember the running checksum of the incoming data source.
Definition:
checksum.h:93
srecord::input_filter_checksum::checksum_address
int checksum_address
The checksum_address instance variable is used to remember where to place the checksum at the end of ...
Definition:
checksum.h:75
srecord::input_filter
The srecord::input_filter class is an abstract interface for all of the various filters that can be a...
Definition:
filter.h:37
srecord::input::pointer
std::shared_ptr< input > pointer
Definition:
input.h:41
srecord::record
The srecord::record class is used to represent a data record read from a file.
Definition:
record.h:35
endian.h
filter.h
interval.h
srecord
Definition:
adler16.h:25
srecord::endian_t
endian_t
Definition:
endian.h:27
record.h
input
filter
checksum.h
Generated by
1.9.1