12 #ifndef hifi_SimulationOwner_h
13 #define hifi_SimulationOwner_h
15 #include <QtCore/QDebug>
16 #include <QtCore/QByteArray>
18 #include <SharedUtil.h>
109 class SimulationOwner {
111 static const int NUM_BYTES_ENCODED;
114 SimulationOwner(
const QUuid&
id, uint8_t priority);
115 SimulationOwner(
const SimulationOwner &) =
default;
117 const QUuid& getID()
const {
return _id; }
118 const uint64_t& getExpiry()
const {
return _expiry; }
119 uint8_t getPriority()
const {
return _priority; }
121 QByteArray toByteArray()
const;
122 bool fromByteArray(
const QByteArray& data);
126 void setPriority(uint8_t priority);
129 bool setID(
const QUuid&
id);
130 bool set(
const QUuid&
id, uint8_t priority);
131 bool set(
const SimulationOwner& owner);
133 bool isNull()
const {
return _id.isNull(); }
134 bool matchesValidID(
const QUuid&
id)
const {
return _id ==
id && !_id.isNull(); }
137 bool hasExpired()
const {
return usecTimestampNow() > _expiry; }
139 void clearCurrentOwner();
141 bool operator>=(uint8_t priority)
const {
return _priority >= priority; }
142 bool operator==(
const SimulationOwner& other) {
return (_id == other._id && _priority == other._priority); }
144 bool operator!=(
const SimulationOwner& other);
145 SimulationOwner& operator=(
const SimulationOwner& other);
147 friend QDebug& operator<<(QDebug& d,
const SimulationOwner& simOwner);