8#include <display/InfoWidget.h>
9#include <display/HtmlClassInspector.h>
10#include <display/VisualRepMap.h>
11#include <display/ObjectInfo.h>
13#include <framework/datastore/DataStore.h>
14#include <framework/datastore/StoreArray.h>
15#include <framework/datastore/StoreObjPtr.h>
16#include <framework/datastore/RelationVector.h>
17#include <framework/logging/Logger.h>
18#include <framework/utilities/ColorPalette.h>
27 if (d ==
"persistent")
31 B2FATAL(
"Invalid URI scheme '" << d <<
"' specified!");
35 TGHtml(p, 400, 600, -1)
37 this->Connect(
"MouseDown(const char*)",
"Belle2::InfoWidget",
this,
"show(const char*)");
45InfoWidget::~InfoWidget()
67 URI parsedURI(lastURI);
68 if (!parsedURI.
object and !lastURI.EndsWith(
"/")) {
95 B2DEBUG(100,
"Navigating to: " << uri);
97 if (std::string(uri) ==
"back:") {
119 info =
"<html><body>" + info +
"</body></html>";
123 ParseText(
const_cast<char*
>(info.Data()));
131 const char* schemes[] = {
"event",
"persistent"};
133 const char* durabilyNames[] = {
"c_Event",
"c_Persistent"};
135 for (
int i = 0; i < 2; i++) {
136 const TString scheme = schemes[i];
138 if (!arrayNames.empty()) {
139 info +=
"<h2>Arrays";
142 info += durabilyNames[i];
147 for (std::string name : arrayNames) {
151 info += TString::Format(
"<a href='%s:%s/'>%s (%d)</a><br>", scheme.Data(), name.c_str(), name.c_str(), nEntries);
153 info += TString::Format(
"%s (%d)<br>", name.c_str(), nEntries);
157 if (!objNames.empty()) {
158 info +=
"<h2>Objects";
161 info += durabilyNames[i];
166 for (std::string name : objNames) {
169 info += TString::Format(
"<a href='%s:%s/'>%s</a><br>", scheme.Data(), name.c_str(), name.c_str());
171 info += TString::Format(
"%s<br>", name.c_str());
187 for (
int i = 0; i < array.
getEntries(); i++) {
191 info += TString::Format(
"<a href='%s:%s/%d'>%s[%d]%s</a><br>",
221 info +=
"<table border=0 width=100% bgcolor=" + col +
"><tr>";
224 info +=
"<a href='main:'>DataStore</a> / ";
227 info += TString::Format(
"<b>[%d]</b>", uri.
arrayIndex);
235 info +=
"<td align=right>Back</td>";
237 info +=
"<td align=right><a href='back:'>Back</a></td>";
240 info +=
"</tr></table>";
253 info += TString::Format(
"<h2>%s (%d)</h2>", uri.
entryName.Data(), numEntries);
261 info +=
"<a href='" + uri.
scheme +
":" + TString::Format(
"%s/%d", uri.
entryName.Data(), uri.
arrayIndex - 1) +
"'>Previous</a>";
266 info +=
"<a href='" + uri.
scheme +
":" + TString::Format(
"%s/%d", uri.
entryName.Data(), uri.
arrayIndex + 1) +
"'>Next</a>";
275 if (pos.first.empty()) {
276 B2DEBUG(100,
"No DataStore entry found for " << obj->GetName() <<
", using raw pointer.");
277 return TString::Format(
"raw:%lu", (
long)obj);
279 return TString::Format(
"event:%s/%d", pos.first.c_str(), pos.second);
285 info +=
"<h4>Related Objects</h4>";
292 TObject::Class(),
"ALL",
""));
293 const TString pref =
"this <b>-></b> ";
294 for (
size_t i = 0; i < relatedObjects.
size(); i++) {
295 const TObject* relObj = relatedObjects.
object(i);
296 double weight = relatedObjects.
weight(i);
302 info += TString::Format(
" (weight: %.3g)", weight);
311 TObject::Class(),
"ALL",
""));
313 const TString pref =
"this <b><-</b> ";
314 for (
size_t i = 0; i < relatedObjects.
size(); i++) {
315 const TObject* relObj = relatedObjects.
object(i);
316 double weight = relatedObjects.
weight(i);
322 info += TString::Format(
" (weight: %.3g)", weight);
333 info +=
"<h4>Object Details</h4>";
340InfoWidget::URI::URI(
const TString& uri)
343 Ssiz_t protStart = uri.First(
":");
344 Ssiz_t protEnd = protStart + 1;
345 if (protStart >= uri.Length())
346 B2FATAL(
"URI has invalid format: " << uri);
347 scheme = uri(0, protStart);
348 TString path = uri(protEnd, uri.Length() - 1);
350 if (scheme ==
"raw") {
352 object =
reinterpret_cast<TObject*
>(path.Atoll());
353 }
else if (path.Length() > 0 and path !=
"/") {
357 Ssiz_t delim = path.Last(
'/');
358 Ssiz_t idxFieldLength = path.Length() - delim - 1;
359 if (delim >= path.Length())
360 B2FATAL(
"URI has invalid format: " << path);
362 entryName = path(0, delim);
363 if (idxFieldLength > 0) {
365 arrayIndex = TString(path(delim + 1, idxFieldLength)).Atoi();
368 object = arr[arrayIndex];
371 const auto& it = entries.find(entryName.Data());
372 if (it == entries.end()) {
373 B2ERROR(
"Given entry '" << entryName <<
"' not found in DataStore, invalid URI?");
374 }
else if (!it->second.isArray) {
376 object = it->second.object;
std::vector< std::string > getListOfArrays(const TClass *arrayClass, EDurability durability) const
Returns a list of names of arrays which are of type (or inherit from) arrayClass.
@ c_FromSide
Return relations/objects pointed from (to a given object).
@ c_ToSide
Return relations/objects pointed to (from a given object).
StoreEntryMap & getStoreEntryMap(EDurability durability)
Get a reference to the object/array map.
std::vector< std::string > getListOfObjects(const TClass *objClass, EDurability durability) const
Returns a list of names of StoreObjPtr-objects whose class is (or inherits from) objClass.
EDurability
Durability types.
@ c_Persistent
Object is available during entire execution time.
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
static DataStore & Instance()
Instance of singleton Store.
static TString getMemberData(const TObject *obj)
Return table with member data contents.
static TString getClassInfo(const TClass *obj)
Get class name + description from comment after ClassDef().
Class for type safe access to objects that are referred to in relations.
T * object(int index) const
Get object with index.
size_t size() const
Get number of relations.
float weight(int index) const
Get weight with index.
Accessor to arrays stored in the data store.
int getEntries() const
Get the number of objects in the array.
Type-safe access to single objects in the data store.
void clearSelection() const
Clear existing selection in Eve Browser.
static VisualRepMap * getInstance()
get instance pointer.
void select(const TObject *object) const
Select the representation of the given object.
bool isVisualized(const TObject *obj)
Does obj have a visualization?
TString getName(const TObject *obj)
human-readable name (e.g.
TString getIdentifier(const TObject *obj)
Where is this object in the datastore?
std::pair< std::string, int > getDataStorePosition(const TObject *obj)
return entry name & index for arrays, with index = -1 for objects.
TString getInfo(const TObject *obj)
Get object info HTML (e.g.
const char * getHex(const std::string &tangoName, int tangoId=1)
Get six-digit hex code (#abcdef) for given name in tango colour palette.
Abstract base class for different kinds of events.
Wraps a stored array/object, stored under unique (name, durability) key.