124 lines
2.7 KiB
C++
124 lines
2.7 KiB
C++
// -*- C++ -*-
|
|
/*
|
|
* File: PeerState.h
|
|
* Author: jgaebler
|
|
*
|
|
* Created on September 20, 2010, 5:01 PM
|
|
*/
|
|
#pragma once
|
|
|
|
#ifndef PEERSTATE_H
|
|
#define PEERSTATE_H
|
|
|
|
#include "common/Defines.h"
|
|
|
|
namespace ubeeme {
|
|
namespace moversight {
|
|
|
|
/**
|
|
* @brief Defines valid states of a moversight peer.
|
|
*/
|
|
enum State {
|
|
DISJOINED = 0,
|
|
INVITING,
|
|
WAITING_FOR_ROSTER,
|
|
JOINED,
|
|
PENDING,
|
|
REJOIN,
|
|
DISCONNECTED,
|
|
LEAVING,
|
|
EXCLUDED,
|
|
DEAD,
|
|
};
|
|
|
|
/**
|
|
* @brief Defines valid sub-states of a moversight peer.
|
|
*/
|
|
enum SubState {
|
|
NO_SUB_STATE = 0,
|
|
//TC
|
|
WAITING_FOR_FLUSH,
|
|
FLUSHING,
|
|
WAITING_FOR_MERGE,
|
|
MERGING,
|
|
//PD
|
|
WAITING_FOR_REJOIN,
|
|
REJOIN_IN_PROGRESS,
|
|
SYNCHRONIZING
|
|
};
|
|
|
|
/**
|
|
* @brief Defines valid state operations of a moversight peer.
|
|
*/
|
|
enum StateOperation {
|
|
NO_STATE_OPERATION = 0,
|
|
LOCKED
|
|
};
|
|
|
|
class PeerState {
|
|
|
|
public:
|
|
|
|
PeerState();
|
|
|
|
PeerState(const State & st);
|
|
|
|
PeerState(const PeerState & orig);
|
|
|
|
virtual ~PeerState();
|
|
|
|
virtual const State & getState() const;
|
|
|
|
virtual void setState(const State & s);
|
|
|
|
virtual const SubState & getSubState() const;
|
|
|
|
virtual void setSubState(const SubState & sub);
|
|
|
|
virtual const StateOperation & getStateOperation() const;
|
|
|
|
virtual void setStateOperation(const StateOperation & op);
|
|
|
|
virtual bool operator==(const PeerState& ps) const;
|
|
|
|
virtual bool operator==(const State& s) const;
|
|
|
|
virtual bool operator==(const SubState& sub) const;
|
|
|
|
virtual bool operator==(const StateOperation& op) const;
|
|
|
|
virtual bool operator!=(const PeerState& ps) const;
|
|
|
|
virtual bool operator!=(const State& s) const;
|
|
|
|
virtual bool operator!=(const SubState& sub) const;
|
|
|
|
virtual bool operator!=(const StateOperation& op) const;
|
|
|
|
virtual void reset();
|
|
|
|
private:
|
|
|
|
State state;
|
|
SubState subState;
|
|
StateOperation stateOp;
|
|
|
|
|
|
};
|
|
|
|
std::ostream& operator<<(std::ostream& out, const PeerState & ps);
|
|
|
|
std::ostream& operator<<(std::ostream& out, const State & s);
|
|
|
|
std::ostream& operator<<(std::ostream& out, const SubState & s);
|
|
|
|
std::ostream& operator<<(std::ostream& out, const StateOperation & op);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
#endif /* PEERSTATE_H */
|
|
|