95 lines
2.5 KiB
C++
95 lines
2.5 KiB
C++
/*
|
|
provenance.h
|
|
|
|
Copyright (c) 2021 Kevin Matz (kevin.matz@gmail.com)
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
SOFTWARE.
|
|
*/
|
|
#pragma once
|
|
|
|
#include "data.h"
|
|
#include "uuid/uuid.h"
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
|
|
namespace SACN {
|
|
|
|
/**
|
|
* @brief The Provenance class
|
|
*/
|
|
class Provenance
|
|
{
|
|
public:
|
|
Provenance();
|
|
Provenance(std::shared_ptr<DATA::Pdu>);
|
|
|
|
const UUID::uuid CID() const;
|
|
const std::string description() const;
|
|
uint16_t universe() const;
|
|
uint8_t priority() const;
|
|
uint16_t syncAddress() const;
|
|
bool isTerminated() const;
|
|
bool isPreview() const;
|
|
bool isForced() const;
|
|
|
|
friend bool operator== (const Provenance& a, const Provenance& b);
|
|
|
|
void setCID(UUID::uuid cid);
|
|
void setDescription(std::string desc);
|
|
void setOptions(uint8_t o);
|
|
void setUniverse(uint16_t n);
|
|
void setSyncAddress(uint16_t a);
|
|
void setPriority(uint8_t p);
|
|
|
|
private:
|
|
UUID::uuid cid_;
|
|
std::string description_;
|
|
uint16_t universe_;
|
|
uint8_t priority_;
|
|
uint16_t sync_address_;
|
|
uint8_t options_;
|
|
};
|
|
} // SACN namespace
|
|
|
|
|
|
namespace std
|
|
{
|
|
template<>
|
|
/**
|
|
* @brief The hash struct specilizaton for SACN::Provenance
|
|
*/
|
|
struct hash<SACN::Provenance>
|
|
{
|
|
/**
|
|
* @brief operator ()
|
|
* @param src
|
|
* @return
|
|
*/
|
|
size_t operator()(SACN::Provenance const& src) const noexcept
|
|
{
|
|
size_t h1 = hash<string>{}(src.description());
|
|
size_t h2 = hash<UUID::uuid>{}(src.CID());
|
|
size_t h3 = hash<int>{}(src.priority());
|
|
size_t h = h1 ^ h2 ^ h3; // or use boost::hash_combine
|
|
return h;
|
|
}
|
|
};
|
|
} // std namespace
|