#pragma once

#include "network.h"

//##########################################################################
//##########################    EntityID    ################################
//##########################################################################

class EntityID
{
public:
	#if defined(USE_SIGNATURE)
		friend int Is_Signature_Bad(const volatile EntityID *);
	#endif

	typedef Enumeration LocalID;

	EntityID();
	EntityID(const EntityID&);
	EntityID(HostID);
	EntityID(HostID, LocalID);

	Logical TestInstance() const;
	HostID GetHostID()	{ return hostID; }

	Logical operator!() const
	{
		Check(this);
		return operator==(Null);
	}
	EntityID& operator=(const EntityID&);

	EntityID operator-(const EntityID&) const;

	EntityID& operator+=(const EntityID&);
	EntityID& operator-=(const EntityID&);

	EntityID& operator+=(LocalID);
	EntityID& operator-=(LocalID);

	Logical operator<(const EntityID&) const;
	Logical operator<=(const EntityID&) const;
	Logical operator>(const EntityID&) const;
	Logical operator>=(const EntityID&) const;
	Logical operator==(const EntityID&) const;
	Logical operator!=(const EntityID&) const;

	operator int() const;

	static EntityID Null;
	static LocalID LocalNull;

	friend std::ostream& operator<<(std::ostream& stream, const EntityID& v)
	{
		return stream << v.hostID << ':' << v.localID;
	}

private:
	HostID hostID;
	LocalID localID;
};