40#ifndef LIB_IDI_ENTRY_ID_H
41#define LIB_IDI_ENTRY_ID_H
49#include <boost/functional/hash.hpp>
110 size_t l = sym.length();
111 if (l > 1) boost::hash_combine(seed,
KNUTH_MAGIC * sym[l-1]);
112 if (l > 2) boost::hash_combine(seed,
KNUTH_MAGIC * sym[l-2]);
113 if (l > 3) boost::hash_combine(seed,
KNUTH_MAGIC * sym[l-3]);
114 if (l > 4) boost::hash_combine(seed,
KNUTH_MAGIC * sym[l-4]);
116 boost::hash_combine(seed, sym);
119 return reinterpret_cast<LuidH&
> (tmpLUID);
180 operator string()
const;
190 template<
typename TAR>
257 return bID.
getHash() == buildHash (bID.
getSym(), getTypeHash<TY>());
264 throw error::Logic (
"unable to recast EntryID: desired type "
265 "doesn't match original definition"
266 , error::LUMIERA_ERROR_WRONG_TYPE);
267 return static_cast<EntryID const&
> (bID);
271 operator string()
const;
319 template<
typename TAR>
328 BareEntryID::operator string()
const
Token or Atom with distinct identity.
Hash implementation based on a lumiera unique object id (LUID) When invoking the default ctor,...
type erased baseclass for building a combined hash and symbolic ID.
LuidH const & getHash() const
EntryID< TAR > const & recast() const
string const & getSym() const
BareEntryID(string const &symbolID, HashVal seed)
Not to be created stand-alone.
BareEntryID(string const &symbolID)
store the symbol but use a random hash part
Lumiera error handling (C++ interface).
Generic functions to build identification schemes.
A template for generating hash based ID tags carrying compile-time type info.
unsigned char lumiera_uid[16]
storage for a Lumiera unique ID, based on a 128bit random number
void lumiera_uid_set_ptr(lumiera_uid *luid, void *ptr)
Store a generic pointer in a luid.
const size_t KNUTH_MAGIC
lousy old tinkerer's trick: hash values with poor distribution can be improved by spreading the input...
LuidH buildHash(string const &sym, HashVal seed=0)
build up a hash value, packaged as LUID.
bool operator==(BareEntryID const &i1, BareEntryID const &i2)
string generateSymbolicID()
build a per-type identifier, with type prefix and running counter.
string typeSymbol()
Short readable type identifier, not necessarily unique or complete.
Implementation namespace for support and library code.
size_t HashVal
a STL compatible hash value
LumieraError< LERR_(LOGIC)> Logic
basic_ostream< char, char_traits< char > > ostream
using BareEntryID derived objects as keys within std::unordered_map
size_t operator()(BareEntryID const &obj) const
typed symbolic and hash ID for asset-like position accounting.
friend auto operator<=>(EntryID const &i1, EntryID const &i2)
EntryID()
case-1: auto generated symbolic ID
static EntryID const & recast(BareEntryID const &bID)
static bool canRecast(BareEntryID const &bID)
EntryID(string const &symbolID)
case-2: explicitly specify a symbolic ID to use.
EntryID(Symbol const &internalSymbol)
case-2b: rely on an internal, already sanitised symbol.
Entry-ID with a symbolic tag but just a plain random hash part.
RandID(Symbol const &internalSymbol)
RandID(string const &symbolID)
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...