16 #ifndef __CFINGERPRINT_H 17 #define __CFINGERPRINT_H 20 #include "simkerneldefs.h" 24 #include "cmatchexpression.h" 45 virtual void initialize(
const char *expectedFingerprints,
cConfiguration *cfg,
int index=-1) = 0;
49 virtual void addEvent(
cEvent *event) = 0;
50 virtual void addScalarResult(
const cComponent *component,
const char *name,
double value) = 0;
51 virtual void addStatisticResult(
const cComponent *component,
const char *name,
const cStatistic *value) = 0;
52 virtual void addVectorResult(
const cComponent *component,
const char *name,
const simtime_t& t,
double value) = 0;
54 virtual void addExtraData(
const char *data,
size_t length) = 0;
55 virtual void addExtraData(
char data) = 0;
56 virtual void addExtraData(
short data) = 0;
57 virtual void addExtraData(
int data) = 0;
58 virtual void addExtraData(
long data) = 0;
59 virtual void addExtraData(
long long data) = 0;
60 virtual void addExtraData(
unsigned char data) = 0;
61 virtual void addExtraData(
unsigned short data) = 0;
62 virtual void addExtraData(
unsigned int data) = 0;
63 virtual void addExtraData(
unsigned long data) = 0;
64 virtual void addExtraData(
unsigned long long data) = 0;
65 virtual void addExtraData(
double data) = 0;
66 virtual void addExtraData(
const char *data) = 0;
73 virtual bool checkFingerprint()
const = 0;
76 #ifdef USE_OMNETPP4x_FINGERPRINTS 90 std::string expectedFingerprints;
94 cOmnetpp4xFingerprintCalculator();
95 virtual ~cOmnetpp4xFingerprintCalculator();
97 virtual cOmnetpp4xFingerprintCalculator *dup()
const override {
return new cOmnetpp4xFingerprintCalculator(); }
98 virtual std::string str()
const override {
return hasher->
str(); }
99 virtual void initialize(
const char *expectedFingerprints,
cConfiguration *cfg,
int index=-1)
override;
101 virtual void addEvent(
cEvent *event)
override;
102 virtual void addScalarResult(
const cComponent *component,
const char *name,
double value)
override {}
103 virtual void addStatisticResult(
const cComponent *component,
const char *name,
const cStatistic *value)
override {}
104 virtual void addVectorResult(
const cComponent *component,
const char *name,
const simtime_t& t,
double value)
override {}
106 virtual void addExtraData(
const char *buffer,
size_t length)
override { hasher->add(buffer, length); }
107 virtual void addExtraData(
char data)
override { hasher->add(data); }
108 virtual void addExtraData(
short data)
override { hasher->add(data); }
109 virtual void addExtraData(
int data)
override { hasher->add(data); }
110 virtual void addExtraData(
long data)
override { hasher->add(data); }
111 virtual void addExtraData(
long long data)
override { hasher->add(data); }
112 virtual void addExtraData(
unsigned char data)
override { hasher->add(data); }
113 virtual void addExtraData(
unsigned short data)
override { hasher->add(data); }
114 virtual void addExtraData(
unsigned int data)
override { hasher->add(data); }
115 virtual void addExtraData(
unsigned long data)
override { hasher->add(data); }
116 virtual void addExtraData(
unsigned long long data)
override { hasher->add(data); }
117 virtual void addExtraData(
double data)
override { hasher->add(data); }
118 virtual void addExtraData(
const char *data)
override { hasher->add(data); }
120 virtual bool checkFingerprint()
const override;
124 #else // if !USE_OMNETPP4x_FINGERPRINTS 158 enum FingerprintIngredient {
160 SIMULATION_TIME =
't',
161 MESSAGE_FULL_NAME =
'n',
162 MESSAGE_CLASS_NAME =
'c',
164 MESSAGE_BIT_LENGTH =
'l',
165 MESSAGE_CONTROL_INFO_CLASS_NAME =
'o',
168 MODULE_FULL_NAME =
'm',
169 MODULE_FULL_PATH =
'p',
170 MODULE_CLASS_NAME =
'a',
171 RANDOM_NUMBERS_DRAWN =
'r',
173 RESULT_STATISTIC =
'z',
183 mutable std::string attributeValue;
186 MatchableObject(
const cObject *
object) : object(
object) {}
188 virtual const char *getAsString()
const;
189 virtual const char *getAsString(
const char *attribute)
const;
193 std::string expectedFingerprints;
194 std::string ingredients;
200 bool addScalarResults;
201 bool addStatisticResults;
202 bool addVectorResults;
206 virtual FingerprintIngredient validateIngredient(
char ch);
207 virtual void parseIngredients(
const char *s);
208 virtual void parseEventMatcher(
const char *s);
209 virtual void parseModuleMatcher(
const char *s);
210 virtual void parseResultMatcher(
const char *s);
211 virtual bool addEventIngredient(
cEvent *event, FingerprintIngredient ingredient);
218 virtual std::string str()
const override;
219 virtual void initialize(
const char *expectedFingerprints,
cConfiguration *cfg,
int index=-1)
override;
221 virtual void addEvent(
cEvent *event)
override;
222 virtual void addScalarResult(
const cComponent *component,
const char *name,
double value)
override;
223 virtual void addStatisticResult(
const cComponent *component,
const char *name,
const cStatistic *value)
override;
224 virtual void addVectorResult(
const cComponent *component,
const char *name,
const simtime_t& t,
double value)
override;
226 virtual void addExtraData(
const char *buffer,
size_t length)
override {
if (addExtraData_) hasher->add(buffer, length); }
227 virtual void addExtraData(
char data)
override {
if (addExtraData_) hasher->add(data); }
228 virtual void addExtraData(
short data)
override {
if (addExtraData_) hasher->add(data); }
229 virtual void addExtraData(
int data)
override {
if (addExtraData_) hasher->add(data); }
230 virtual void addExtraData(
long data)
override {
if (addExtraData_) hasher->add(data); }
231 virtual void addExtraData(
long long data)
override {
if (addExtraData_) hasher->add(data); }
232 virtual void addExtraData(
unsigned char data)
override {
if (addExtraData_) hasher->add(data); }
233 virtual void addExtraData(
unsigned short data)
override {
if (addExtraData_) hasher->add(data); }
234 virtual void addExtraData(
unsigned int data)
override {
if (addExtraData_) hasher->add(data); }
235 virtual void addExtraData(
unsigned long data)
override {
if (addExtraData_) hasher->add(data); }
236 virtual void addExtraData(
unsigned long long data)
override {
if (addExtraData_) hasher->add(data); }
237 virtual void addExtraData(
double data)
override {
if (addExtraData_) hasher->add(data); }
238 virtual void addExtraData(
const char *data)
override {
if (addExtraData_) hasher->add(data); }
240 virtual bool checkFingerprint()
const override;
257 std::vector<cFingerprintCalculator *> elements;
264 virtual std::string str()
const override;
265 virtual void initialize(
const char *expectedFingerprints,
cConfiguration *cfg,
int index=-1)
override;
267 virtual void addEvent(
cEvent *event)
override;
268 virtual void addScalarResult(
const cComponent *component,
const char *name,
double value)
override;
269 virtual void addStatisticResult(
const cComponent *component,
const char *name,
const cStatistic *value)
override;
270 virtual void addVectorResult(
const cComponent *component,
const char *name,
const simtime_t& t,
double value)
override;
272 #define for_each_element(CODE) for (std::vector<cFingerprintCalculator *>::iterator it = elements.begin(); it != elements.end(); ++it) { cFingerprintCalculator *element = *it; CODE; } 273 virtual void addExtraData(
const char *data,
size_t length)
override { for_each_element(element->addExtraData(data, length)); }
274 virtual void addExtraData(
char data)
override { for_each_element(element->addExtraData(data)); }
275 virtual void addExtraData(
short data)
override { for_each_element(element->addExtraData(data)); }
276 virtual void addExtraData(
int data)
override { for_each_element(element->addExtraData(data)); }
277 virtual void addExtraData(
long data)
override { for_each_element(element->addExtraData(data)); }
278 virtual void addExtraData(
long long data)
override { for_each_element(element->addExtraData(data)); }
279 virtual void addExtraData(
unsigned char data)
override { for_each_element(element->addExtraData(data)); }
280 virtual void addExtraData(
unsigned short data)
override { for_each_element(element->addExtraData(data)); }
281 virtual void addExtraData(
unsigned int data)
override { for_each_element(element->addExtraData(data)); }
282 virtual void addExtraData(
unsigned long data)
override { for_each_element(element->addExtraData(data)); }
283 virtual void addExtraData(
unsigned long long data)
override { for_each_element(element->addExtraData(data)); }
284 virtual void addExtraData(
double data)
override { for_each_element(element->addExtraData(data)); }
285 virtual void addExtraData(
const char *data)
override { for_each_element(element->addExtraData(data)); }
286 #undef for_each_element 288 virtual bool checkFingerprint()
const override;
291 #endif // !USE_OMNETPP4x_FINGERPRINTS Common base for module and channel classes.
Definition: ccomponent.h:48
Root of the OMNeT++ class hierarchy. cObject is a lightweight class without any data members...
Definition: cobject.h:58
int64_t-based, base-10 fixed-point simulation time.
Definition: simtime.h:66
Objects to be matched must implement this interface.
Definition: cmatchexpression.h:64
This class calculates the "fingerprint" of a simulation.
Definition: cfingerprint.h:155
Represents an event in the discrete event simulator.
Definition: cevent.h:43
virtual cSingleFingerprintCalculator * dup() const override
Definition: cfingerprint.h:217
virtual cObject * dup() const
virtual cMultiFingerprintCalculator * dup() const override
Definition: cfingerprint.h:263
Utility class to calculate the hash of some data.
Definition: chasher.h:37
Utility class, to make it impossible to call the operator= and copy constructor of any class derived ...
Definition: cobject.h:311
This class defines the interface for fingerprint calculators.
Definition: cfingerprint.h:34
Definition: cabstracthistogram.h:21
cStatistic is an abstract class for computing statistical properties of a random variable.
Definition: cstatistic.h:34
This class calculates multiple fingerprints simultaneously.
Definition: cfingerprint.h:253
Represents the configuration, as accessed by the simulation kernel.
Definition: cconfiguration.h:70
Decides whether an object matches an expression.
Definition: cmatchexpression.h:57