00001
00024 #ifndef _BASE_EVENT_H_
00025 #define _BASE_EVENT_H_
00026
00027 #include <string>
00028 #include <sstream>
00029
00030 #include "comDefs.h"
00031
00038 template <typename S, typename A>
00039 class BaseEvent {
00040
00041 private:
00043 size_t id;
00044
00046 S sendObj;
00047
00049 S recvObj;
00050
00052 A action;
00053
00055 SimTime sendTime;
00056
00058 SimTime recvTime;
00059
00060
00061
00062
00063 protected:
00074 BaseEvent (size_t id, const S& sendObj, const S& recvObj, const A& action, const SimTime& sendTime, const SimTime& recvTime):
00075 id (id), sendObj (sendObj), recvObj (recvObj), action (action), sendTime (sendTime), recvTime (recvTime) {}
00076
00077
00078 public:
00079
00083 BaseEvent (const BaseEvent<S,A>& that): id (that.id), sendObj (that.sendObj), recvObj (that.recvObj), action (that.action)
00084 , sendTime (that.sendTime), recvTime (that.recvTime) {}
00085
00089 BaseEvent<S, A>& operator = (const BaseEvent<S, A>& that) {
00090 if (this != &that) {
00091 id = that.id;
00092 sendObj = that.sendObj;
00093 recvObj = that.recvObj;
00094 action = that.action;
00095 sendTime = that.sendTime;
00096 recvTime = that.recvTime;
00097 }
00098 return (*this);
00099 }
00100
00106 const std::string detailedString() const {
00107 std::ostringstream ss;
00108 ss << "Event-" << id << ":" << "sendTime = " << sendTime << "sendObj = " << &sendObj << std::endl
00109 << "recvTime = " << recvTime << "recvObj = " << &recvObj << std::endl
00110 << "action = " << action.toString () << std::endl;
00111 return ss.str ();
00112 }
00113
00117 const std::string toString () const {
00118 std::ostringstream ss;
00119 ss << getRecvTime ();
00120 return ss.str ();
00121 }
00122
00128 const S& getSendObj() const {
00129 return sendObj;
00130 }
00131
00132
00138 const S& getRecvObj() const {
00139 return recvObj;
00140 }
00141
00142
00148 const SimTime& getSendTime() const {
00149 return sendTime;
00150 }
00151
00157 const SimTime& getRecvTime() const {
00158 return recvTime;
00159 }
00165 const A& getAction() const {
00166 return action;
00167 }
00168
00169
00175 size_t getId() const {
00176 return id;
00177 }
00178
00179 };
00180
00181
00182
00183
00184
00185 #endif