This macro demonstrates custom access and custom drawing for TMsgList class Main motivation for this example - demonstrate how traffic between server and client can be minimized and how one could build custom UI in the browser.
TMsgList in this tutorial keep last N messages, numbering each with unique identifier There is TMsgList::Select() method which selects messages from the list If one specifies identifier, only messages newer than this identifier are selected In the selection list (TList object of TObjString) first item always identifier for the latest message in the list
In JavaScript code (httptextlog.js) one uses Select() method to receive latest messages, which not yet been seen in the browser and display them as text At maximum, 1000 elements are preserved in the browser.
After macro started, one could open in browser address
One could either click item again or enable monitoring to always receive latest messages Or one could open only this output and nothing else:
In last case it could be used in iframe, also it requires less code to load on the page
#include <cstdio>
#include <cstring>
protected:
public:
fLimit(limit)
{
}
{
while (fMsgs.
GetSize() >= fLimit) {
delete last;
}
fCounter++;
}
{
if (max == 0) max = fMsgs.
GetLast()+1;
while ((obj = iter()) && (--
curr >=
id) && (--max >= 0))
return &fSelect;
}
};
{
TH1D *
hpx =
new TH1D(
"hpx",
"This is the px distribution",100,-4,4);
hpx->SetDirectory(
nullptr);
hpxpy->SetDirectory(
nullptr);
auto pos = fdir.find("httptextlog.C");
if (pos > 0) {
fdir.resize(pos);
} else {
printf(
"Cannot detect directory with macro - not possible to load JavaScript file\n");
return;
}
}
serv->Register(
"/", log);
serv->Restrict(
"/log",
"allow_method=Select,GetTitle");
serv->RegisterCommand(
"/Stop",
"bRun=kFALSE;",
"rootsys/icons/ed_delete.png");
serv->RegisterCommand(
"/ExitRoot",
"gSystem->Exit(1);",
"rootsys/icons/ed_delete.png");
if (loop % 1000 == 0) {
loop = loop/1000;
int shift = loop % 40;
}
}
}
}
#define ClassDefOverride(name, id)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TSystem * gSystem
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
UInt_t Get() const
Return raw date/time as encoded by TDatime.
1-D histogram with a double per channel (see TH1 documentation)
2-D histogram with a float per channel (see TH1 documentation)
Online http server for arbitrary ROOT application.
void Clear(Option_t *option="") override
Remove all objects from the list.
void Add(TObject *obj) override
TObject * Last() const override
Return the last object in the list. Returns 0 when list is empty.
void RemoveLast() override
Remove the last object of the list.
void AddFirst(TObject *obj) override
Add object at the beginning of the list.
The TNamed class is the base class for all named ROOT classes.
Collectable string class.
Mother of all ROOT objects.
Random number generator class based on M.
virtual Int_t GetLast() const
Returns index of last object in collection.
static TString LLtoa(Long64_t value, Int_t base)
Converts a Long64_t to a TString with respect to the base specified (2-36).
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
- Author
- Sergey Linev
Definition in file httptextlog.C.