00001
00025 #ifndef _EVENT_H__
00026 #define _EVENT_H__
00027
00028
00029 #include "comDefs.h"
00030 #include "BaseEvent.h"
00031
00038 template <typename S, typename A>
00039 class Event: public BaseEvent<S, A> {
00040 public:
00046 enum Type {
00047 REGULAR_EVENT, NULL_EVENT
00048 };
00049
00050 private:
00051
00052
00054 Type type;
00055
00069 Event (size_t id, const S& sendObj, const S& recvObj, const A& action, const Type type, const SimTime& sendTime, const SimTime& recvTime)
00070 : BaseEvent <S, A> (id, sendObj, recvObj, action, sendTime, recvTime), type (type) {}
00071
00072
00073
00074 friend class AbstractSimObject;
00075 public:
00076
00080 const Type& getType () const {
00081 return type;
00082 }
00083
00087 const std::string detailedString () const {
00088 switch (type) {
00089 case REGULAR_EVENT:
00090 return BaseEvent<S, A>::detailedString () + "type: REGULAR_EVENT";
00091 case NULL_EVENT:
00092 return BaseEvent<S, A>::detailedString () + "type: NULL_EVENT";
00093
00094 }
00095 }
00096
00097 };
00098
00099
00124 template <typename EventTy>
00125 struct EventRecvTimeLocalTieBrkCmp {
00126
00143 int compare (const EventTy& left, const EventTy& right) const {
00144 int res;
00145 if ( left.getRecvTime () < right.getRecvTime ()) {
00146 res = -1;
00147
00148 } else if (left.getRecvTime () > right.getRecvTime ()) {
00149 res = 1;
00150
00151 } else {
00152
00153 res = left.getSendObj ()->getId () - right.getSendObj ()->getId ();
00154
00155 if (res == 0) {
00156 res = left.getId () - right.getId ();
00157 }
00158
00159 }
00160
00161 return res;
00162
00163 }
00164
00170 bool operator () (const EventTy& left, const EventTy& right) const {
00171 return compare (left, right) > 0;
00172 }
00173
00174 };
00175
00176 #endif