implement initial EventLog entry
This commit is contained in:
parent
b2542b86f7
commit
d38b28da5b
4 changed files with 37 additions and 17 deletions
|
|
@ -64,12 +64,19 @@ namespace idi {
|
|||
|
||||
|
||||
string
|
||||
instance_formatter (string const& prefix, long instanceNr)
|
||||
instance_format (string const& prefix, size_t instanceNr)
|
||||
{
|
||||
return _Fmt("%s.%03d")
|
||||
% prefix % instanceNr;
|
||||
}
|
||||
|
||||
string
|
||||
instance_hex_format (string const& prefix, size_t instanceNr)
|
||||
{
|
||||
return _Fmt("%s.%04X")
|
||||
% prefix % instanceNr;
|
||||
}
|
||||
|
||||
} //(End)integration helpers...
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,8 @@ namespace idi {
|
|||
string demangled_innermost_component (const char* rawName);
|
||||
string demangled_sanitised_name (const char* rawName);
|
||||
|
||||
string instance_formatter (string const& prefix, long instanceNr);
|
||||
string instance_format (string const& prefix, size_t instanceNr);
|
||||
string instance_hex_format (string const& prefix, size_t instanceNr);
|
||||
|
||||
} //(End)integration helpers...
|
||||
|
||||
|
|
@ -107,6 +108,18 @@ namespace idi {
|
|||
return typeSymbol<TY>();
|
||||
}
|
||||
|
||||
/** designation of an distinct object instance
|
||||
* @par obj pointer to the memory location of the object
|
||||
* @return a notation "typename.hash", where the hash is given
|
||||
* as 4 hex digits derived from the memory location
|
||||
*/
|
||||
template<typename TY>
|
||||
inline string
|
||||
instanceTypeID(const TY *const obj)
|
||||
{
|
||||
return format::instance_hex_format (namePrefix<TY>(), (size_t(obj) / alignof(TY)) % (1<<16));
|
||||
}
|
||||
|
||||
|
||||
/** build a per-type identifier, with type prefix and running counter.
|
||||
* @return a type based prefix, followed by an instance number
|
||||
|
|
@ -122,7 +135,7 @@ namespace idi {
|
|||
generateSymbolicID()
|
||||
{
|
||||
static TypedCounter instanceCounter;
|
||||
return format::instance_formatter (namePrefix<TY>(), instanceCounter.inc<TY>());
|
||||
return format::instance_format (namePrefix<TY>(), instanceCounter.inc<TY>());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -160,18 +160,24 @@ namespace test{
|
|||
string logID_;
|
||||
Log log_;
|
||||
|
||||
void
|
||||
log (std::initializer_list<string> const&& ili)
|
||||
{
|
||||
log_.emplace_back(ili);
|
||||
}
|
||||
|
||||
public:
|
||||
explicit
|
||||
EventLog (string logID)
|
||||
: logID_(logID)
|
||||
{
|
||||
UNIMPLEMENTED("initial log entry");
|
||||
log({"type=EventLogHeader", "ID="+logID_});
|
||||
}
|
||||
|
||||
template<class X>
|
||||
explicit
|
||||
EventLog (const X *const)
|
||||
: EventLog(idi::typeSymbol<X>())
|
||||
EventLog (const X *const obj)
|
||||
: EventLog(idi::instanceTypeID (obj))
|
||||
{ }
|
||||
|
||||
|
||||
|
|
@ -192,25 +198,18 @@ namespace test{
|
|||
EventLog&
|
||||
event (string text)
|
||||
{
|
||||
log({"type=event", text});
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class X>
|
||||
static string
|
||||
instanceHash(const X *const)
|
||||
{
|
||||
UNIMPLEMENTED ("generate an object instance hash");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ==== Iteration ==== */
|
||||
|
||||
bool
|
||||
empty() const
|
||||
{
|
||||
UNIMPLEMENTED ("collection behaviour");
|
||||
return 1 >= log_.size();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -87,8 +87,9 @@ namespace test{
|
|||
log.verify("α").before("β");
|
||||
VERIFY_ERROR (ASSERTION, log.verify("β").before("α"));
|
||||
|
||||
CHECK (join(log) == "LOG::TestEventLog_test"+EventLog::instanceHash(this)
|
||||
+ ", Rec(event| |{α}), Rec(event| |{β})");
|
||||
CHECK (join(log) == "Rec(EventLogHeader| ID = TestEventLog_test."+idi::instanceTypeID(this)+" |), "
|
||||
+ "Rec(event| |{α}), "
|
||||
+ "Rec(event| |{β})");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue