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:
parent
fc488f3b56
commit
dccc41f156
4 changed files with 17 additions and 28 deletions
|
|
@ -40,7 +40,7 @@ namespace test{ // see test-helper.cpp
|
||||||
namespace idi {
|
namespace idi {
|
||||||
|
|
||||||
|
|
||||||
namespace { // generic entry points / integration helpers...
|
namespace format { // generic entry points / integration helpers...
|
||||||
|
|
||||||
using lib::test::demangleCxx;
|
using lib::test::demangleCxx;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ namespace idi {
|
||||||
using lib::HashVal;
|
using lib::HashVal;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
namespace { // integration helpers...
|
namespace format { // integration helpers...
|
||||||
string demangled_innermost_component (const char* rawName);
|
string demangled_innermost_component (const char* rawName);
|
||||||
string demangled_sanitised_name (const char* rawName);
|
string demangled_sanitised_name (const char* rawName);
|
||||||
|
|
||||||
|
|
@ -75,7 +75,7 @@ namespace idi {
|
||||||
inline string
|
inline string
|
||||||
typeSymbol()
|
typeSymbol()
|
||||||
{
|
{
|
||||||
return demangled_innermost_component (typeid(TY).name());
|
return format::demangled_innermost_component (typeid(TY).name());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Complete unique type identifier
|
/** Complete unique type identifier
|
||||||
|
|
@ -87,7 +87,7 @@ namespace idi {
|
||||||
inline string
|
inline string
|
||||||
typeFullID()
|
typeFullID()
|
||||||
{
|
{
|
||||||
return demangled_sanitised_name (typeid(TY).name());
|
return format::demangled_sanitised_name (typeid(TY).name());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TY>
|
template<typename TY>
|
||||||
|
|
@ -117,7 +117,7 @@ namespace idi {
|
||||||
generateSymbolicID()
|
generateSymbolicID()
|
||||||
{
|
{
|
||||||
static TypedCounter instanceCounter;
|
static TypedCounter instanceCounter;
|
||||||
return instance_formatter (namePrefix<TY>(), instanceCounter.inc<TY>());
|
return format::instance_formatter (namePrefix<TY>(), instanceCounter.inc<TY>());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,8 @@ namespace asset {
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::ostream;
|
using std::ostream;
|
||||||
|
|
||||||
|
using lib::idi::generateSymbolicID;
|
||||||
|
using lib::idi::getTypeHash;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -72,9 +74,12 @@ namespace asset {
|
||||||
*/
|
*/
|
||||||
namespace idi {
|
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.
|
/** build up a hash value, packaged as LUID.
|
||||||
* @param sym symbolic ID-string to be hashed
|
* @param sym symbolic ID-string to be hashed
|
||||||
|
|
@ -131,9 +136,9 @@ namespace asset {
|
||||||
* encoded into a hash seed. Thus even the same symbolicID
|
* encoded into a hash seed. Thus even the same symbolicID
|
||||||
* generates differing hash-IDs for different type parameters
|
* 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))
|
: symbol_(util::sanitise(symbolID))
|
||||||
, hash_(idi::buildHash (symbol_, seed))
|
, hash_(buildHash (symbol_, seed))
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -201,7 +206,7 @@ namespace asset {
|
||||||
|
|
||||||
/** case-1: auto generated symbolic ID */
|
/** case-1: auto generated symbolic ID */
|
||||||
EntryID()
|
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.
|
/** case-2: explicitly specify a symbolic ID to use.
|
||||||
|
|
@ -210,7 +215,7 @@ namespace asset {
|
||||||
*/
|
*/
|
||||||
explicit
|
explicit
|
||||||
EntryID (string const& symbolID)
|
EntryID (string const& symbolID)
|
||||||
: BareEntryID (symbolID, getTypeHash())
|
: BareEntryID (symbolID, getTypeHash<TY>())
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -228,12 +233,6 @@ namespace asset {
|
||||||
return Asset::Ident (this->getSym(), cat);
|
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
|
/** @return true if the upcast would yield exactly the same
|
||||||
* tuple (symbol,type) as was used on original definition
|
* tuple (symbol,type) as was used on original definition
|
||||||
|
|
@ -243,7 +242,7 @@ namespace asset {
|
||||||
static bool
|
static bool
|
||||||
canRecast (BareEntryID const& bID)
|
canRecast (BareEntryID const& bID)
|
||||||
{
|
{
|
||||||
return bID.getHash() == idi::buildHash (bID.getSym(), getTypeHash());
|
return bID.getHash() == buildHash (bID.getSym(), getTypeHash<TY>());
|
||||||
}
|
}
|
||||||
|
|
||||||
static EntryID
|
static EntryID
|
||||||
|
|
|
||||||
|
|
@ -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
|
}}} // namespace asset::idi
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue