File: PingEvent.cpp

package info (click to toggle)
warped 20031216-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,276 kB
  • ctags: 2,616
  • sloc: cpp: 16,610; sh: 7,071; makefile: 318
file content (79 lines) | stat: -rw-r--r-- 2,489 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright (c) The University of Cincinnati.  
// All rights reserved.

// UC MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF 
// THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE, OR NON-INFRINGEMENT.  UC SHALL NOT BE LIABLE
// FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
// RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
// DERIVATIVES.

// By using or copying this Software, Licensee agrees to abide by the
// intellectual property laws, and all other applicable laws of the
// U.S., and the terms of this license.

// Authors: Malolan Chetlur             mal@ececs.uc.edu
//          Jorgen Dahl                 dahlj@ececs.uc.edu
//          Dale E. Martin              dmartin@ececs.uc.edu
//          Radharamanan Radhakrishnan  ramanan@ececs.uc.edu
//          Dhananjai Madhava Rao       dmadhava@ececs.uc.edu
//          Philip A. Wilsey            phil.wilsey@uc.edu

//---------------------------------------------------------------------------
// 
// $Id: PingEvent.cpp
// 
//---------------------------------------------------------------------------

#include "PingEvent.h"
#include <cstdlib>
#include <clutils/AllocatorStack.h>
#include <warped/SerializedInstance.h>

void 
PingEvent::serialize( SerializedInstance *addTo ) const {
  Event::serialize( addTo );
  addTo->addString( myOwner );
}

Serializable *
PingEvent::deserialize( SerializedInstance *instance ){
  VTime *sendTime = dynamic_cast<VTime *>(instance->getSerializable());
  VTime *receiveTime = dynamic_cast<VTime *>(instance->getSerializable());
  string sender = instance->getString();
  string receiver = instance->getString();
  unsigned int eventId = instance->getUnsigned();
  string owner = instance->getString();

  PingEvent *event = new PingEvent( *sendTime,
				    *receiveTime,
				    sender,
				    receiver,
				    eventId,
				    owner );
  delete sendTime;
  delete receiveTime;

  return event;
}

bool
PingEvent::eventCompare( const Event* event ){
  if( compareEvents( this, event ) == true ){
    if( myOwner == dynamic_cast<const PingEvent *>(event)->getOwner() ){
      return true;
    }
  }
  return false;
}

void *
PingEvent::operator new( size_t size ){
  return AllocatorStack<sizeof(PingEvent)>::pop();
}

void
PingEvent::operator delete( void *toDelete ){
  return AllocatorStack<sizeof(PingEvent)>::push( toDelete );
}