Project

General

Profile

Revision 18befb2d

ID18befb2d221b81a1c559d2453678c96e609537d0
Parent 04a70d7c
Child f22bd539

Added by Mirko Stoffers over 7 years ago

Module will now create new entries into the event type list when new event types occur

View differences:

configure.user
68 68
# With gcc, do NOT use --omit-frame-pointer (it crashes when coroutines and
69 69
# C++ exceptions (throw/catch) are used together)!
70 70
#
71
#CFLAGS_DEBUG='-g -Wall'
72
#CFLAGS_RELEASE='-O2 -DNDEBUG=1'
71
CFLAGS_DEBUG+='-std=c++0x -g -Wall'
72
CFLAGS_RELEASE+='-std=c++0x -O2 -DNDEBUG=1'
73 73

  
74 74
#
75 75
# Linker switches used for linking.
include/cmodule.h
204 204
  private:
205 205
    static std::string lastmodulefullpath; // cached result of last getFullPath() call
206 206
    static const cModule *lastmodulefullpathmod; // module of lastmodulefullpath
207
	typedef std::vector<EventType> knownEventTypes_t;
208
	knownEventTypes_t knownEventTypes;
207 209

  
208 210
  private:
209 211
    enum {
include/eventtype.h
19 19
#include "simkerneldefs.h"
20 20
#include "pdf.h"
21 21

  
22
#include "cmessage.h"
23

  
22 24
class SuccessorEvent
23 25
{
24 26
	private:
......
48 50
	private:
49 51
		succList_t succs;
50 52
		int modId;
53
		int kind;
54
		int sender;
51 55

  
52 56
	public:
57
		EventType(const cMessage* const msg)
58
		{
59
			modId=msg->getArrivalModuleId();
60
			kind=msg->getKind();
61
			sender=msg->getSenderModuleId();
62
		}
63

  
64
		bool operator==(const cMessage& msg)
65
		{
66
			return
67
				msg.getArrivalModuleId()==modId
68
				&& msg.getKind()==kind
69
				&& msg.getSenderModuleId()==sender
70
				;
71
		}
72

  
53 73
		const succList_t& getSuccessors() const
54 74
		{
55 75
			return succs;
......
59 79
		{
60 80
			return modId;
61 81
		}
62

  
63
		void setModId(int modId)
64
		{
65
			this->modId=modId;
66
		}
67 82
};
68 83

  
69 84

  
src/sim/cmodule.cc
1406 1406

  
1407 1407
EventType* cModule::getEventType(cMessage* msg)
1408 1408
{
1409
	// TODO: right now only pseudo event type!
1410
	EventType* type=new EventType();
1411
	type->setModId(getId());
1412
	return type;
1409
	// Event type exists?
1410
	for(knownEventTypes_t::iterator it=knownEventTypes.begin();it!=knownEventTypes.end();++it)
1411
	{
1412
		if(*it==*msg)
1413
		{
1414
			return &(*it);
1415
		}
1416
	}
1417

  
1418
	// If event type does not exist, create it:
1419
	knownEventTypes.emplace_back(msg);
1420
	return &knownEventTypes.back();
1413 1421
}
1414 1422

  

Also available in: Unified diff