Source

COS 520 Lamport 2 / Message.hpp

Full commit
#ifndef MESSAGE_HPP_
#define MESSAGE_HPP_

#include "types.hpp"

class Message
{
  friend bool operator<(const Message &LHS, const Message &RHS);

public:
  // Possible values for a message vote; null means hasn't been voted on.
  class vote
  {
  public:
      enum type { null, accept, reject };
  };

  Message(type::process_id to, type::process_id from, type::time time, type::requestID requestID, vote::type v=vote::null);

  void display() const;
  void tick() const;
  type::process_id getTo() const;
  type::process_id getFrom() const;
  type::time getRequestTime() const;
  type::requestID getRequestID() const;
  vote::type getVote() const;
  type::time getTTA() const;
  bool hasArrived() const;

private:
  type::process_id to;
  type::process_id from;
  type::time requestTime;
  type::requestID requestID;
  vote::type messageVote;
  mutable type::time TTA;
  static const type::time MaximumTTA = 10;

};


bool operator<(const Message &LHS, const Message &RHS);

#endif