00001
00002 #include "pose.h"
00003
00005 Event::Event() : spawnedList(NULL),msg (NULL), commitBfr(NULL),cpData(NULL),
00006 serialCPdataSz(0), serialCPdata(NULL),
00007 next(NULL),prev(NULL), commitBfrLen(0), commitErr(0),
00008 done (0), fnIdx(-1), timestamp(POSE_UnsetTS),
00009 srt(0.0), svt (0)
00010 {
00011
00012 }
00013
00015 Event::~Event()
00016 {
00017 SpawnedEvent *tmp;
00018
00019 delete msg;
00020
00021
00022
00023 if (commitBfr) free(commitBfr);
00024 while (spawnedList) {
00025 tmp = spawnedList;
00026 spawnedList = spawnedList->next;
00027 delete tmp;
00028 }
00029
00030 }
00031
00033 void Event::pup(PUP::er &p)
00034 {
00035 int msgSize, spawn = 0;
00036 SpawnedEvent *tmp = NULL;
00037
00038 evID.pup(p); p(fnIdx); p(timestamp); p(done); p(commitBfrLen); p(commitErr);
00039 p(srt); p(ert); p(svt); p(evt);
00040
00041 if (p.isUnpacking() && (commitBfrLen > 0)) {
00042 commitBfr = new char[commitBfrLen];
00043 p(commitBfr, commitBfrLen);
00044 }
00045 else if (commitBfrLen > 0)
00046 p(commitBfr, commitBfrLen);
00047 else
00048 commitBfr = NULL;
00049
00050
00051 if (p.isUnpacking()) {
00052 p(msgSize);
00053 if (msgSize > 0) {
00054 msg = (eventMsg *)CmiAlloc(msgSize);
00055 p((char *)msg, msgSize);
00056 msg = (eventMsg *)EnvToUsr((envelope *)msg);
00057 }
00058 else
00059 msg = NULL;
00060 }
00061 else {
00062 if (msg != NULL) {
00063 msgSize = (UsrToEnv(msg))->getTotalsize();
00064 p(msgSize);
00065 p((char *)(UsrToEnv(msg)), msgSize);
00066 }
00067 else {
00068 msgSize = 0;
00069 p(msgSize);
00070 }
00071 }
00072
00073
00074 if (p.isUnpacking()) {
00075 p(spawn);
00076 if (spawn > 0) spawnedList = tmp = new SpawnedEvent();
00077 else spawnedList = NULL;
00078 while (spawn > 0) {
00079 tmp->pup(p);
00080 tmp->next = NULL;
00081 spawn--;
00082 if (spawn > 0) {
00083 tmp->next = new SpawnedEvent();
00084 tmp = tmp->next;
00085 }
00086 }
00087 }
00088 else {
00089 tmp = spawnedList;
00090 while (tmp != NULL) {
00091 spawn++;
00092 tmp = tmp->next;
00093 }
00094 p(spawn);
00095 tmp = spawnedList;
00096 while (tmp != NULL) {
00097 tmp->pup(p);
00098 tmp = tmp->next;
00099 }
00100 }
00101
00102 if (p.isUnpacking()) {
00103 cpData = NULL;
00104 serialCPdata = NULL;
00105 serialCPdataSz = 0;
00106 }
00107 }
00108
00110 void Event::sanitize()
00111 {
00112 if ((fnIdx != -99) && (fnIdx != -100)) {
00113 evID.sanitize();
00114 msg->sanitize();
00115
00116
00118 CmiAssert((done == 0) || (done == 1) || (done == 2));
00119 CmiAssert((commitErr == 0) || (commitErr == 1));
00120 CmiAssert(((commitBfrLen == 0) && (commitBfr == NULL)) ||
00121 ((commitBfrLen > 0) && (commitBfr != NULL)));
00127
00128
00129 }
00130 }