/* ******************************************************************************* * INCLUDE ******************************************************************************* */ #include "SerialCode.h" #include namespace Video { namespace Core { /* ******************************************************************************* * CLASS DEFINE ******************************************************************************* */ bool SerialCode::empty() const { return _value.isNull(); } void SerialCode::reset() { return _value.clear(); } const SerialCode& SerialCode::operator++() { if (empty()) _value = 0; ++_value; return *this; } const SerialCode& SerialCode::operator++(int) { if (empty()) _value = 0; _value++; return *this; } bool SerialCode::operator!=(const SerialCode& other) { return _value != other._value; } const SerialCode& SerialCode::operator=(const SerialCode& other) { _value = other._value; return *this; } const SerialCode& SerialCode::operator=(const uint32_t value) { _value = value; return *this; } /* ******************************************************************************* * CLASS DEFINE ******************************************************************************* */ SerialCodeManager::SerialCodeManager() { Poco::Random r; r.seed(); _code = r.next(); } void SerialCodeManager::increment() { _code++; } /* ******************************************************************************* * CLASS DEFINE ******************************************************************************* */ bool SerialCodeWatcher::isChanged(const SerialCode& code, bool firstAsChanged) { if (_code.empty()) { _code = code; return firstAsChanged; } if (_code != code) { _code = code; return true; } return false; } void SerialCodeWatcher::reset() { _code.reset(); } } }