Lumiera  0.pre.03
»edityourfreedom«
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 128 of file entry-id.hpp.

Public Member Functions

 EntryID ()
 case-1: auto generated symbolic ID More...
 
 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=0)
 Not to be created stand-alone. More...
 

Constructor & Destructor Documentation

◆ EntryID() [1/4]

EntryID ( )
inline

case-1: auto generated symbolic ID

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

◆ EntryID() [2/4]

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 229 of file entry-id.hpp.

◆ EntryID() [3/4]

EntryID ( const char *  symbolID)
inlineexplicit

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

◆ EntryID() [4/4]

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 242 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 253 of file entry-id.hpp.

◆ recast()

static EntryID const& recast ( BareEntryID< TY > const &  bID)
inlinestatic

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

Referenced by EntryID_test::checkErasure().

+ Here is the caller graph for this function:

◆ operator string()

operator string ( ) const
inline

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

Friends And Related Function Documentation

◆ operator<

bool operator< ( EntryID< TY > const &  i1,
EntryID< TY > const &  i2 
)
friend

Definition at line 271 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: