整理代码
This commit is contained in:
commit
c7b4e178ec
364 changed files with 59691 additions and 0 deletions
107
video/core/SerialCode.cpp
Normal file
107
video/core/SerialCode.cpp
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* INCLUDE
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "SerialCode.h"
|
||||
#include <Poco/Random.h>
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue