/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2012 University of California, Los Angeles
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation;
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
 *         卞超轶 Chaoyi Bian <bcy@pku.edu.cn>
 *	   Alexander Afanasyev <alexander.afanasyev@ucla.edu>
 */

#ifndef SYNC_SEQ_NO_H
#define SYNC_SEQ_NO_H

#include <boost/cstdint.hpp>

namespace Sync {

/**
 * @brief Sequence number abstraction
 *
 * 
 */
struct SeqNo
{
public:
  /**
   * @brief Constructor with just sequence number. Session assumed to be zero
   * @param seq Sequence number
   */
  SeqNo (uint32_t seq)
    : m_session (0)
    , m_seq (seq)
  { }

  /**
   * @brief Constructor with session and sequence id
   * @param session Session ID
   * @param seq Sequence number
   */
  SeqNo (uint32_t session, uint32_t seq)
    : m_session (session)
    , m_seq (seq)
  { }
  
  /**
   * @brief Session ID (e.g., after crash, application will choose new session ID.
   *
   * Note that session IDs for the same name should always increase. So, the good choice
   * for the session ID is client's timestamp
   */
  uint32_t m_session;

  /**
   * @brief Sequence number
   *
   * Sequence number for a session always starts with 0 and goes to max value.
   *
   * For now, wrapping sequence number after max to zero is not supported
   */
  uint32_t m_seq;

  /**
   * @brief Compare if one sequence number is lower
   * @param seq Another sequence number to compare with
   *
   * tuple (session1, seq1) is less than (session2, seq2) in two cases:
   * 1. session1 < session2
   * 2. session1 == session2 and seq1 < seq2
   */
  bool
  operator < (const SeqNo &seq) const
  {
    return m_session < seq.m_session || (m_session == seq.m_session && m_seq < seq.m_seq);
  }

  /**
   * @brief Compare if two sequence numbers are equal
   * @param seq Another sequence number to compare with
   */
  bool
  operator == (const SeqNo &seq) const
  {
    return m_session == seq.m_session && m_seq == seq.m_seq;
  }
};

} // Sync

#endif // SYNC_SEQ_NO_H
