#pragma once #include "../FnvHash.hpp" #include "../types.hpp" #include #include #include namespace sibs { const usize PUBSUB_KEY_LENGTH = 20; class PubsubKey { public: PubsubKey(); // Create pubsub key from existing data, data will be cutoff at PUBSUB_KEY_LENGTH. If @size is less than PUBSUB_KEY_LENGTH then data is appended with 0 PubsubKey(const void *data, const usize size); bool operator == (const PubsubKey &other) const; bool operator != (const PubsubKey &other) const; std::string toString() const; std::array data; }; struct PubsubKeyHasher { size_t operator()(const PubsubKey &pubsubKey) const { return fnvHash((const unsigned char*)pubsubKey.data.data(), PUBSUB_KEY_LENGTH); } }; template using PubsubKeyMap = std::unordered_map; }