srecord 1.65.0
 
Loading...
Searching...
No Matches
split.h
Go to the documentation of this file.
1//
2// srecord - manipulate eprom load files
3// Copyright (C) 1998, 1999, 2001, 2002, 2005-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_INPUT_FILTER_SPLIT_H
21#define SRECORD_INPUT_FILTER_SPLIT_H
22
24#include <srecord/record.h>
25
26namespace srecord
27{
28
29/**
30 * The srecord::input_filter_split class is used to represent a filter
31 * which splits ints input source into piceces. The data of each
32 * swathe then has the address adjusted to fill in the gaps.
33 *
34 * For example, this filter can be used to create each of the images
35 * for 8-bit EPROMS for systems which use a 16-bit bus.
36 *
37 * Note that you need to invoke this filter N times when you have N
38 * swathes, once for each swathe.
39 *
40 * <pre>
41 * --> | modulus | <--
42 * Input data: | |
43 * ~-+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-~
44 * | | X | X | 0 | 1 | X | X | 4 | 5 | X | X | 8 | 9 | X | X | |
45 * ~-+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-~
46 * | | / / / /
47 * | | / / / /
48 * | | / / / /
49 * | | / / / / This diagram shows
50 * | | / / / / offset zero. You
51 * | | / / / / would need a second
52 * Output data: | |/ // / pass with an offset
53 * ~-+---+---+---+---+---+---+---+---+---+---+---+-~ of two for the other
54 * | | | | 0 | 1 | 4 | 5 | 8 | 9 | | | half of the data.
55 * ~-+---+---+---+---+---+---+---+---+---+---+---+-~
56 * | |
57 * --> | width | <-- </pre>
58 */
59class input_filter_split:
60 public input_filter
61{
62public:
63 /**
64 * The destructor.
65 */
67
68private:
69 /**
70 * The constructor.
71 *
72 * @param deeper
73 * The deeper input source to be filtered.
74 * @param modulus
75 * The number of bytes wide each swathe is.
76 * @param offset
77 * The offset within the swathe.
78 * @param width
79 * The width of each stripe within the swathe.
80 */
81 input_filter_split(const input::pointer &deeper, int modulus,
82 int offset, int width);
83
84public:
85 /**
86 * The create class method is used to create new dynamically
87 * allocated instances of this class.
88 *
89 * @param deeper
90 * The incoming data source to be filtered
91 * @param modulus
92 * The number of bytes wide each swathe is.
93 * @param offset
94 * The offset within the swathe.
95 * @param width
96 * The width of each stripe within the swathe.
97 */
98 static pointer create(const input::pointer &deeper, int modulus,
99 int offset, int width);
100
101protected:
102 // See base class for documentation.
104
105private:
106 /**
107 * The modulus instance variable is used to remember the number of
108 * bytes wide each swathe is.
109 */
110 record::address_t modulus;
111
112 /**
113 * The offset instance variable is used to remember the offset
114 * within the swathe.
115 */
116 record::address_t offset;
117
118 /**
119 * The width instance variable is used to remember the width of
120 * each stripe within the swathe.
121 */
122 record::address_t width;
123
124 /**
125 * The buffer instance variable is used to remember the last lot
126 * of data read from the deeper inputs source, and currently being
127 * processed.
128 */
129 record buffer;
130
131 /**
132 * The buffer_pos instance variable is used to remember where we
133 * are up to in the "buffer" instance varaible.
134 */
135 size_t buffer_pos;
136
137 /**
138 * The default constructor. Do not use.
139 */
140 input_filter_split();
141
142 /**
143 * The copy constructor. Do not use.
144 */
145 input_filter_split(const input_filter_split &);
146
147 /**
148 * The assignment operator. Do not use.
149 */
150 input_filter_split &operator=(const input_filter_split &);
151};
152
153};
154
155#endif // SRECORD_INPUT_FILTER_SPLIT_H
virtual ~input_filter_split()
The destructor.
static pointer create(const input::pointer &deeper, int modulus, int offset, int width)
The create class method is used to create new dynamically allocated instances of this class.
bool read(record &record)
The read method is used to read one record from the input.
input_filter(input::pointer deeper)
The constructor.
std::shared_ptr< input > pointer
Definition input.h:41
The srecord::record class is used to represent a data record read from a file.
Definition record.h:35
uint32_t address_t
The type of record addresses.
Definition record.h:58