File: PingObject.h

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 (85 lines) | stat: -rw-r--r-- 2,468 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
80
81
82
83
84
85
#ifndef PINGOBJECT_HH
#define PINGOBJECT_HH

// 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

#include <warped/warped.h>
#include <warped/SimulationObject.h>

/**
   This class is the simulation object for the Ping Pong simulation.  The
   entire point of this simulation is to have pathologically low
   granularity.  Don't expect to get parallel speedup on this one.  :-)
*/
class PingObject : public SimulationObject {
  
public :
  /**
     Constructor
     @param initObjectId      The name of this object
     @param initDestName      Who we're hitting our ball at.
     @param initNumberOfBalls How many balls we expect to receive.
  */
  PingObject( const int initObjectId,
	      const string &destName,
	      const int numberOfBalls,
	      bool master,
	      bool randomDelays );
  
  ~PingObject();
  
  void initialize();
  void finalize();
  
  void executeProcess();
  
  State *allocateState();
  void deallocateState( const State* state );
  
  void reclaimEvent(const Event *event);

  static string getName( int forId );

  const string &getName() const { return myObjectName; }
  
private :
  const string myObjectName;
  const string myDestObjectName;
  const int numBalls;
  SimulationObject *sendTo;
  const bool isMaster;
  const bool randomDelays;
  double lastX;

  /**
     Handles the sending of our event to our neighbor.
  */
  void sendEvent( const string &ownerName );

  /**
     Starts a new "ball" in the system.
  */
  void startBall();
};

#endif