EntryID(#865): switch ID generation to the newly defined generic ID functions

...first step to get rid of the proc::asset dependency
This commit is contained in:
Fischlurch 2015-06-30 02:31:36 +02:00
parent fc488f3b56
commit dccc41f156
4 changed files with 17 additions and 28 deletions

View file

@ -40,7 +40,7 @@ namespace test{ // see test-helper.cpp
namespace idi {
namespace { // generic entry points / integration helpers...
namespace format { // generic entry points / integration helpers...
using lib::test::demangleCxx;

View file

@ -57,7 +57,7 @@ namespace idi {
using lib::HashVal;
using std::string;
namespace { // integration helpers...
namespace format { // integration helpers...
string demangled_innermost_component (const char* rawName);
string demangled_sanitised_name (const char* rawName);
@ -75,7 +75,7 @@ namespace idi {
inline string
typeSymbol()
{
return demangled_innermost_component (typeid(TY).name());
return format::demangled_innermost_component (typeid(TY).name());
}
/** Complete unique type identifier
@ -87,7 +87,7 @@ namespace idi {
inline string
typeFullID()
{
return demangled_sanitised_name (typeid(TY).name());
return format::demangled_sanitised_name (typeid(TY).name());
}
template<typename TY>
@ -117,7 +117,7 @@ namespace idi {
generateSymbolicID()
{
static TypedCounter instanceCounter;
return instance_formatter (namePrefix<TY>(), instanceCounter.inc<TY>());
return format::instance_formatter (namePrefix<TY>(), instanceCounter.inc<TY>());
}
/**

View file

@ -61,6 +61,8 @@ namespace asset {
using std::string;
using std::ostream;
using lib::idi::generateSymbolicID;
using lib::idi::getTypeHash;
/**
@ -72,9 +74,12 @@ namespace asset {
*/
namespace idi {
using lib::hash::LuidH;
using lib::HashVal;
}
using lib::hash::LuidH;
using lib::HashVal;
namespace {
/** build up a hash value, packaged as LUID.
* @param sym symbolic ID-string to be hashed
@ -131,9 +136,9 @@ namespace asset {
* encoded into a hash seed. Thus even the same symbolicID
* generates differing hash-IDs for different type parameters
*/
BareEntryID (string const& symbolID, idi::HashVal seed =0)
BareEntryID (string const& symbolID, HashVal seed =0)
: symbol_(util::sanitise(symbolID))
, hash_(idi::buildHash (symbol_, seed))
, hash_(buildHash (symbol_, seed))
{ }
public:
@ -201,7 +206,7 @@ namespace asset {
/** case-1: auto generated symbolic ID */
EntryID()
: BareEntryID (idi::generateSymbolID<TY>(), getTypeHash()) /////////////TICKET #565 : how to organise access; this is not thread safe
: BareEntryID (generateSymbolicID<TY>(), getTypeHash<TY>())
{ }
/** case-2: explicitly specify a symbolic ID to use.
@ -210,7 +215,7 @@ namespace asset {
*/
explicit
EntryID (string const& symbolID)
: BareEntryID (symbolID, getTypeHash())
: BareEntryID (symbolID, getTypeHash<TY>())
{ }
@ -228,12 +233,6 @@ namespace asset {
return Asset::Ident (this->getSym(), cat);
}
static idi::HashVal
getTypeHash()
{
return hash_value (Category (STRUCT, idi::StructTraits<TY>::catFolder()));
}
/** @return true if the upcast would yield exactly the same
* tuple (symbol,type) as was used on original definition
@ -243,7 +242,7 @@ namespace asset {
static bool
canRecast (BareEntryID const& bID)
{
return bID.getHash() == idi::buildHash (bID.getSym(), getTypeHash());
return bID.getHash() == buildHash (bID.getSym(), getTypeHash<TY>());
}
static EntryID

View file

@ -148,16 +148,6 @@ namespace asset{
template<class STRU>
inline string
generateSymbolID()
{
static uint i=0;
static format namePattern ("%s.%03d");
////////////////////////////////////////////////////////////////////////////////TICKET #166 : needs to be pushed down into a *.cpp
return str(namePattern % StructTraits<STRU>::namePrefix() % (++i) ); //////////TICKET #565 : how to organise access; this ought to be thread safe (-> EntryID )
}
}}} // namespace asset::idi