Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
genfunc.hpp
Go to the documentation of this file.
1/*
2 GENFUNC.hpp - generic identification functions
3
4 Copyright (C)
5 2015, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12*/
13
14
36#ifndef LIB_IDI_GENFUNC_H
37#define LIB_IDI_GENFUNC_H
38
39#include "lib/hash-value.h"
40#include "lib/symbol.hpp"
41#include "lib/typed-counter.hpp"
42//#include "lib/hash-standard.hpp"
43
44#include <typeinfo>
45#include <string>
46
47
48namespace lib {
49namespace meta{
50 std::string demangleCxx (lib::Literal rawName);
54}// implemented in format-obj.cpp
55
56namespace idi {
57
58 using lib::HashVal;
59 using std::string;
60
61 namespace format { // integration helpers...
62
63 string instance_format (string const& prefix, size_t instanceNr);
64 string instance_hex_format (string const& prefix, size_t instanceNr);
65
66 } //(End)integration helpers...
67
68
69
76 template<typename TY>
77 inline string
79 {
80 return lib::meta::primaryTypeComponent (typeid(TY).name());
81 }
82
88 template<typename TY>
89 inline string
91 {
92 return lib::meta::sanitisedFullTypeName (typeid(TY).name());
93 }
94
95 template<typename TY>
96 inline string
98 {
99 return typeSymbol<TY>();
100 }
101
102 template<typename TY>
103 inline string
105 {
106 return typeSymbol<TY>();
107 }
108
114 template<typename TY>
115 inline string
116 instanceTypeID(const TY *const obj)
117 {
118 return format::instance_hex_format (namePrefix<TY>(), (size_t(obj) / alignof(TY)) % (1<<16));
119 }
120
121
123
124
134 template<class TY>
135 inline string
137 {
138 return format::instance_format (namePrefix<TY>(), sharedInstanceCounter().inc<TY>());
139 }
140
148 template<class TY>
149 inline string
150 generateExtendedID(string prefix ="")
151 {
152 return format::instance_format (prefix + typeFullID<TY>(), sharedInstanceCounter().inc<TY>());
153 }
154
158 template<typename TY>
159 inline HashVal
161 {
162 return typeid(TY).hash_code();
163 }
164
165
166
167}} // namespace lib::idi
168#endif /*LIB_IDI_GENFUNC_H*/
Inline string literal.
Definition symbol.hpp:78
Utility providing a set of counters, each tied to a specific type.
Hash value types and utilities.
string instance_format(string const &prefix, size_t instanceNr)
Definition genfunc.cpp:40
string instance_hex_format(string const &prefix, size_t instanceNr)
Definition genfunc.cpp:47
string instanceTypeID(const TY *const obj)
designation of an distinct object instance
Definition genfunc.hpp:116
string namePrefix()
Definition genfunc.hpp:104
TypedCounter & sharedInstanceCounter()
Definition genfunc.cpp:57
HashVal getTypeHash()
Definition genfunc.hpp:160
string typeFullID()
Complete unique type identifier.
Definition genfunc.hpp:90
string categoryFolder()
Definition genfunc.hpp:97
string generateSymbolicID()
build a per-type identifier, with type prefix and running counter.
Definition genfunc.hpp:136
string typeSymbol()
Short readable type identifier, not necessarily unique or complete.
Definition genfunc.hpp:78
string generateExtendedID(string prefix="")
build a long type based identifier, with running counter and custom prefix.
Definition genfunc.hpp:150
string sanitisedFullTypeName(lib::Literal rawName)
build a sanitised ID from full type name
string humanReadableTypeID(Literal rawType)
pretty-print an internal C++ type representation
string primaryTypeComponent(Literal rawType)
extract core name component from a raw type spec
enable_if_c< Cond::value, T >::type enable_if
SFINAE helper to control the visibility of specialisations and overloads.
Definition meta/util.hpp:87
string demangleCxx(Literal rawName)
Fallback type-ID:
Implementation namespace for support and library code.
size_t HashVal
a STL compatible hash value
Definition hash-value.h:52
Marker types to indicate a literal string and a Symbol.
Creating series of type-based contexts.