File: PingObjectState.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 (40 lines) | stat: -rw-r--r-- 999 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
#ifndef PINGOBJECTSTATE_H
#define PINGOBJECTSTATE_H

#include <warped/State.h>

class PingObjectState : public State {
public :
  PingObjectState() :
    numBallsStarted( 0 ),
    numBallsRecvd( 0 ),
    numBallsSent( 0 ){};

  ~PingObjectState(){};
  
  void copyState( const State *toCopy ){
    ASSERT( toCopy != 0 );
    const PingObjectState *pingState = dynamic_cast<const PingObjectState *>(toCopy);
    numBallsRecvd = pingState->numBallsRecvd;
    numBallsSent = pingState->numBallsSent;
    numBallsStarted = pingState->numBallsStarted;
  }

  void ballStarted(){ numBallsStarted++; }
  void ballSent(){ numBallsSent++; }
  void ballReceived(){ numBallsRecvd++; }

  int getNumStarted(){ return numBallsStarted; }

  const string getSummaryString(){
    return "received " + intToString(numBallsRecvd) + ", sent " +
      intToString(numBallsSent ) + ", and started " + intToString(numBallsStarted);
  }

private:
  int numBallsStarted;
  int numBallsRecvd;
  int numBallsSent;
};

#endif