Client program which allows the snooping of objects from a spyserv process.
class Spy {
private:
public:
Spy();
~Spy();
void Connect();
void DoButton();
};
void Spy::DoButton()
{
return;
switch (btn->WidgetId()) {
case 1:
fSock->Send("get hpx");
break;
case 2:
fSock->Send("get hpxpy");
break;
case 3:
fSock->Send("get hprof");
break;
}
Error("Spy::DoButton", "error receiving message");
return;
}
if (mess->GetClass()->InheritsFrom(
TH1::Class())) {
fHist = (TH1*) mess->ReadObject(mess->GetClass());
if (mess->GetClass()->InheritsFrom(TH2::Class()))
fHist->Draw("cont");
else
fHist->Draw();
fCanvas->GetCanvas()->Modified();
fCanvas->GetCanvas()->Update();
}
delete mess;
}
void Spy::Connect()
{
fSock =
new TSocket(
"localhost", 9090);
}
Spy::Spy()
{
fMain = new TGMainFrame(0, 100, 100);
fCanvas = new TRootEmbeddedCanvas("Canvas", fMain, 600, 400);
fMain->AddFrame(fCanvas, fLcan);
fHorz = new TGHorizontalFrame(fMain, 100, 100);
fMain->AddFrame(fHorz, fLhorz);
fHpx = new TGTextButton(fHorz, "Get hpx", 1);
fHpx->
Connect(
"Clicked()",
"Spy",
this,
"DoButton()");
fHpxpy = new TGTextButton(fHorz, "Get hpxpy", 2);
fHpxpy->
Connect(
"Clicked()",
"Spy",
this,
"DoButton()");
fHprof = new TGTextButton(fHorz, "Get hprof", 3);
fHprof->
Connect(
"Clicked()",
"Spy",
this,
"DoButton()");
fHorz2 = new TGHorizontalFrame(fMain, 100, 100);
fMain->AddFrame(fHorz2, fLhorz);
fConnect = new TGTextButton(fHorz2, "Connect");
fConnect->
Connect(
"Clicked()",
"Spy",
this,
"Connect()");
fQuit = new TGTextButton(fHorz2, "Quit");
fMain->SetWindowName("Spy on SpyServ");
fMain->MapSubwindows();
fMain->Resize(fMain->GetDefaultSize());
fMain->MapWindow();
fHist = 0;
}
Spy::~Spy()
{
delete fHist;
delete fSock;
delete fLbut;
delete fLhorz;
delete fLcan;
delete fHpx;
delete fHpxpy;
delete fHprof;
delete fConnect;
delete fQuit;
delete fHorz;
delete fHorz2;
delete fCanvas;
delete fMain;
}
void spy()
{
new Spy;
}
#define RQ_OBJECT(sender_class)
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
A composite frame that layout their children in horizontal way.
This class describes layout hints used by the layout classes.
Defines top level windows that interact with the system Window Manager.
TH1 is the base class of all histogram classes in ROOT.
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
This class creates a TGCanvas in which a TCanvas is created.
This class implements client sockets.
virtual Int_t Recv(TMessage *&mess)
Receive a TMessage object.
virtual Bool_t IsValid() const