Lumiera  0.pre.03
»edit your freedom«
EntryID< TY > Struct Template Reference

#include "lib/idi/entry-id.hpp"

Description

template<class TY>
struct lib::idi::EntryID< TY >

typed symbolic and hash ID for asset-like position accounting.

Allows for creating an entry with symbolic id and distinct type, combined with an derived hash value, without the overhead in storage and instance management imposed by using a full-fledged Asset.

Similar to an Asset, an identification tuple is available (generated on the fly), as is an unique LUID and total ordering. The type information is attached as template parameter, but included into the hash calculation. All instantiations of the EntryID template share a common baseclass, usable for type erased common registration.

Todo:
currently storing the symbolic-ID as string. It should be a lib::Symbol, but this isn't possible unless we use a symbol table. //////TICKET #158
Warning
there is a weakness in boost::hash applied to strings. EntryID by default generates symbolic IDs from a type prefix plus a running number, which causes collisions already with less than 100000 entries.
Todo:
As a temporary workaround, we hash the symbolic ID twice, but we should look into using a better hash function ////////////TICKET #865
See also
mobject::session::Fork

Definition at line 126 of file entry-id.hpp.

Public Member Functions

 EntryID ()
 case-1: auto generated symbolic ID
 
 EntryID (string const &symbolID)
 case-2: explicitly specify a symbolic ID to use. More...
 
 EntryID (const char *symbolID)
 
 EntryID (Symbol const &internalSymbol)
 case-2b: rely on an internal, already sanitised symbol. More...
 
 operator string () const
 
- Public Member Functions inherited from BareEntryID
LuidH const & getHash () const
 
string const & getSym () const
 
bool isValid () const
 
 operator string () const
 
template<typename TAR >
EntryID< TAR > const & recast () const
 try to upcast this BareEntryID to a fully typed EntryID. More...
 

Static Public Member Functions

static bool canRecast (BareEntryID const &bID)
 
static EntryID const & recast (BareEntryID const &bID)
 

Friends

bool operator< (EntryID const &i1, EntryID const &i2)
 

Additional Inherited Members

- Protected Member Functions inherited from BareEntryID
 BareEntryID (string const &symbolID, HashVal seed)
 Not to be created stand-alone. More...
 
 BareEntryID (string const &symbolID)
 store the symbol but use a random hash part
 

Constructor & Destructor Documentation

◆ EntryID() [1/2]

EntryID ( string const &  symbolID)
inlineexplicit

case-2: explicitly specify a symbolic ID to use.

The type information TY will be included automatically into the generated hash-ID. This hash is reproducible.

Definition at line 234 of file entry-id.hpp.

◆ EntryID() [2/2]

EntryID ( Symbol const &  internalSymbol)
inlineexplicit

case-2b: rely on an internal, already sanitised symbol.

The symbol string will be passed through as-is, while the type information from TY will be hashed in.

Definition at line 247 of file entry-id.hpp.

Member Function Documentation

◆ canRecast()

static bool canRecast ( BareEntryID< TY > const &  bID)
inlinestatic
Returns
true if the upcast would yield exactly the same tuple (symbol,type) as was used on original definition of an ID, based on the given BareEntryID. Implemented by re-calculating the hash.

Definition at line 258 of file entry-id.hpp.

+ Inheritance diagram for EntryID< TY >:
+ Collaboration diagram for EntryID< TY >:

The documentation for this struct was generated from the following file: