77 lines
1.8 KiB
C++
77 lines
1.8 KiB
C++
#ifndef F54A2617_3BA7_4779_88A5_AB040FD9B002
|
|
#define F54A2617_3BA7_4779_88A5_AB040FD9B002
|
|
/*
|
|
*******************************************************************************
|
|
* INCLUDE
|
|
*******************************************************************************
|
|
*/
|
|
#include "CodecID.h"
|
|
#include <Poco/Nullable.h>
|
|
#include <Poco/Any.h>
|
|
#include <map>
|
|
|
|
namespace Video
|
|
{
|
|
namespace Core
|
|
{
|
|
/*
|
|
*******************************************************************************
|
|
* CLASS DECLARE
|
|
*******************************************************************************
|
|
*/
|
|
class SerialCode
|
|
{
|
|
public:
|
|
bool empty() const;
|
|
void reset();
|
|
const SerialCode& operator++();
|
|
const SerialCode& operator++(int);
|
|
bool operator!=(const SerialCode& other);
|
|
const SerialCode& operator=(const SerialCode& other);
|
|
const SerialCode& operator=(const uint32_t other);
|
|
|
|
private:
|
|
Poco::Nullable<uint32_t> _value;
|
|
};
|
|
|
|
class SerialCodeManager
|
|
{
|
|
public:
|
|
SerialCodeManager();
|
|
|
|
template <class T> void put(const std::string& name, const T& value);
|
|
void increment();
|
|
|
|
const SerialCode& code() const;
|
|
|
|
private:
|
|
SerialCode _code;
|
|
std::map<std::string, Poco::Any> _values;
|
|
};
|
|
|
|
template <class T> inline void SerialCodeManager::put(const std::string& name, const T& value)
|
|
{
|
|
if (_values.find(name) == _values.end() || Poco::AnyCast<T>(_values[name]) != value)
|
|
{
|
|
_values[name] = value;
|
|
_code++;
|
|
}
|
|
}
|
|
|
|
inline const SerialCode& SerialCodeManager::code() const
|
|
{
|
|
return _code;
|
|
}
|
|
|
|
class SerialCodeWatcher
|
|
{
|
|
public:
|
|
bool isChanged(const SerialCode& code, bool firstAsChanged = false);
|
|
void reset();
|
|
|
|
private:
|
|
SerialCode _code;
|
|
};
|
|
}
|
|
}
|
|
#endif
|