OMNeT++ Simulation Library  6.0.3
cresultlistener.h
1 //==========================================================================
2 // CRESULTLISTENER.H - part of
3 // OMNeT++/OMNEST
4 // Discrete System Simulation in C++
5 //
6 //==========================================================================
7 
8 /*--------------------------------------------------------------*
9  Copyright (C) 1992-2017 Andras Varga
10  Copyright (C) 2006-2017 OpenSim Ltd.
11 
12  This file is distributed WITHOUT ANY WARRANTY. See the file
13  `license' for details on this and other legal matters.
14 *--------------------------------------------------------------*/
15 
16 #ifndef __OMNETPP_CRESULTLISTENER_H
17 #define __OMNETPP_CRESULTLISTENER_H
18 
19 #include "simkerneldefs.h"
20 #include "clistener.h"
21 #include "cobject.h"
22 
23 namespace omnetpp {
24 
25 class cResultFilter;
26 class cComponent;
27 
28 
34 class SIM_API cResultListener : public cObject, public cIListener
35 {
36  friend class cResultFilter;
37  private:
38  int delegatedCount = 0;
39  public:
40  // simplified API that better supports chaining (needs to be public due to DemuxFilter)
41  virtual void receiveSignal(cResultFilter *prev, simtime_t_cref t, bool b, cObject *details) = 0;
42  virtual void receiveSignal(cResultFilter *prev, simtime_t_cref t, intval_t l, cObject *details) = 0;
43  virtual void receiveSignal(cResultFilter *prev, simtime_t_cref t, uintval_t l, cObject *details) = 0;
44  virtual void receiveSignal(cResultFilter *prev, simtime_t_cref t, double d, cObject *details) = 0;
45  virtual void receiveSignal(cResultFilter *prev, simtime_t_cref t, const SimTime& v, cObject *details) = 0;
46  virtual void receiveSignal(cResultFilter *prev, simtime_t_cref t, const char *s, cObject *details) = 0;
47  virtual void receiveSignal(cResultFilter *prev, simtime_t_cref t, cObject *obj, cObject *details) = 0;
48  virtual void subscribedTo(cResultFilter *prev);
49  virtual void unsubscribedFrom(cResultFilter *prev);
50  virtual void callFinish(cResultFilter *prev) {finish(prev);}
51  virtual void finish(cResultFilter *prev) {}
52 
53  virtual void callEmitInitialValue() {emitInitialValue();}
54  virtual void emitInitialValue() {}
55 
56  // original listener API delegates to simplified API:
57  virtual void receiveSignal(cComponent *source, simsignal_t signalID, bool b, cObject *details) override;
58  virtual void receiveSignal(cComponent *source, simsignal_t signalID, intval_t l, cObject *details) override;
59  virtual void receiveSignal(cComponent *source, simsignal_t signalID, uintval_t l, cObject *details) override;
60  virtual void receiveSignal(cComponent *source, simsignal_t signalID, double d, cObject *details) override;
61  virtual void receiveSignal(cComponent *source, simsignal_t signalID, const SimTime& v, cObject *details) override;
62  virtual void receiveSignal(cComponent *source, simsignal_t signalID, const char *s, cObject *details) override;
63  virtual void receiveSignal(cComponent *source, simsignal_t signalID, cObject *obj, cObject *details) override;
64  virtual void subscribedTo(cComponent *component, simsignal_t signalID) override;
65  virtual void unsubscribedFrom(cComponent *component, simsignal_t signalID) override;
66  virtual void finish(cComponent *component, simsignal_t signalID) override;
67 
68  virtual int getSubscribeCount() const override {return cIListener::getSubscribeCount() + delegatedCount;}
69  virtual int getDelegatedCount() const {return delegatedCount;}
70 
71  // make a "clean" copy which inherits configuration but not result collection state
72  virtual cResultListener *clone() const = 0;
73 };
74 
75 } // namespace omnetpp
76 
77 #endif
78 
79 
omnetpp::simtime_t_cref
const typedef simtime_t & simtime_t_cref
Constant reference to a simtime_t.
Definition: simtime_t.h:48
omnetpp::simsignal_t
int simsignal_t
Signal handle.
Definition: clistener.h:27
omnetpp::cObject
cObject is a lightweight class which serves as the root of the OMNeT++ class hierarchy....
Definition: cobject.h:92
omnetpp::cIListener
Interface for listeners in a simulation model.
Definition: clistener.h:71
omnetpp::cResultListener::getSubscribeCount
virtual int getSubscribeCount() const override
Definition: cresultlistener.h:68
omnetpp::SimTime
int64_t-based, base-10 fixed-point simulation time.
Definition: simtime.h:66
omnetpp::uintval_t
uint64_t uintval_t
Unsigned integer type which is guaranteed to be at least 64 bits wide. It is used throughout the libr...
Definition: simkerneldefs.h:109
omnetpp::intval_t
int64_t intval_t
Signed integer type which is guaranteed to be at least 64 bits wide. It is used throughout the librar...
Definition: simkerneldefs.h:101
omnetpp::cComponent
Common base for module and channel classes.
Definition: ccomponent.h:49
omnetpp::cResultFilter
Base class for result filters.
Definition: cresultfilter.h:72
omnetpp::cResultListener
Common abstract base class for result filters and result recorders.
Definition: cresultlistener.h:34
omnetpp::cIListener::getSubscribeCount
virtual int getSubscribeCount() const
Definition: clistener.h:178