srecord  1.65.0
compare.h
Go to the documentation of this file.
1 //
2 // srecord - manipulate eprom load files
3 // Copyright (C) 2000, 2002, 2005-2008, 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_COMPARE_H
21 #define SRECORD_MEMORY_WALKER_COMPARE_H
22 
23 #include <srecord/interval.h>
24 #include <srecord/memory/walker.h>
25 
26 namespace srecord
27 {
28 
29 class memory; // forward
30 
31 /**
32  * The srecord::memory_walker_compare class is used to represent a memory
33  * walker which compares memory data with another memory instance.
34  *
35  * Note that this is strictly an improper subset comparison. I.e. that
36  * all bytes passed to the observe method exists in the other memory
37  * instance.
38  *
39  * For a complete equality test, you need to use this comparison both
40  * ways round.
41  */
43  public memory_walker
44 {
45 public:
46  typedef std::shared_ptr<memory_walker_compare> pointer;
47 
48  /**
49  * The destructor.
50  */
52 
53 private:
54  /**
55  * The constructor. It is private on purpose, use thr #create
56  * class method instead.
57  *
58  * @param other
59  * The other memory instance to be checked against this one.
60  * @param check_wrong
61  * Whether or not to check that the data agrees as well as the
62  * address ranges.
63  */
64  memory_walker_compare(const memory &other, bool check_wrong);
65 
66 public:
67  /**
68  * The create class method is used to create new dynamically
69  * allocated instances of this class.
70  *
71  * @param other
72  * The other memory instance to be checked against this one.
73  * @param check_wrong
74  * Whether or not to check that the data agrees as well as the
75  * address ranges.
76  */
77  static pointer create(const memory &other, bool check_wrong);
78 
79  // See base class for documentation.
80  virtual void observe(unsigned long, const void *, int);
81 
82  /**
83  * The print method is used to print the results of the comparison
84  * on the standard output.
85  *
86  * @param caption
87  * The text to place at the start of the listing.
88  */
89  void print(const char *caption) const;
90 
91  /**
92  * The same method is used to discover whether the result of the
93  * comparison indicate that the two memory instances are the same.
94  */
95  bool same() const;
96 
97 private:
98  /**
99  * The other instance variable is used to remember the other memory
100  * instance to be checked against this one.
101  */
102  const memory &other;
103 
104  /**
105  * The check_wrong instance variable is used to remember whether or
106  * not to check that the data agrees as well as the address ranges.
107  */
108  bool check_wrong;
109 
110  /**
111  * The unset instance variable is used to remember which bytes of
112  * data given to the observe method are NOT present in the other
113  * memory instance.
114  */
115  interval unset;
116 
117  /**
118  * The wrong instance variable is used to remember which bytes of
119  * data given to the observer method were different than the ones
120  * in the other memory instance.
121  */
122  interval wrong;
123 
124  /**
125  * The default constructor. Do not use.
126  */
128 
129  /**
130  * The copy constructor. Do not use.
131  */
133 
134  /**
135  * The assignment operator. Do not use.
136  */
137  memory_walker_compare &operator=(const memory_walker_compare &);
138 };
139 
140 };
141 
142 #endif // SRECORD_MEMORY_WALKER_COMPARE_H
The interval class is used to represent a set of integer values, usually composed of runs of adjacent...
Definition: interval.h:36
The srecord::memory_walker_compare class is used to represent a memory walker which compares memory d...
Definition: compare.h:44
virtual ~memory_walker_compare()
The destructor.
static pointer create(const memory &other, bool check_wrong)
The create class method is used to create new dynamically allocated instances of this class.
void print(const char *caption) const
The print method is used to print the results of the comparison on the standard output.
virtual void observe(unsigned long, const void *, int)
The observe method is used by the memory walker to provide data.
bool same() const
The same method is used to discover whether the result of the comparison indicate that the two memory...
std::shared_ptr< memory_walker_compare > pointer
Definition: compare.h:46
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
The srecord::memory class is used to simulate memory contents.
Definition: memory.h:40