Line data Source code
1 : /* This file is property of and copyright by the ALICE HLT Project *
2 : * ALICE Experiment at CERN, All rights reserved. *
3 : * See cxx source for full Copyright notice */
4 :
5 : /** @file AliZMQhistViewer.cxx
6 : @author Mikolaj Krzewicki (mkrzewic@cern.ch)
7 : */
8 :
9 : #ifndef ALIZMQHISTVIEWER_H
10 : #define ALIZMQHISTVIEWER_H
11 :
12 : #include "AliZMQhelpers.h"
13 : #include <vector>
14 : #include <string>
15 : #include <memory>
16 : #include "TThread.h"
17 : #include <deque>
18 : #include "TQObject.h"
19 : #include "TObject.h"
20 :
21 : class TVirtualPad;
22 : class TString;
23 : class TObject;
24 : class TPad;
25 : class TCanvas;
26 : class TPRegexp;
27 : class TCollection;
28 : class AliAnalysisDataContainer;
29 :
30 : struct ZMQviewerObject {
31 : TObject* object;
32 : TObject* previous;
33 : int pad;
34 : bool redraw;
35 : bool isnew;
36 : std::string options;
37 :
38 : ZMQviewerObject() : object(NULL), previous(NULL), pad(-1), redraw(true), isnew(true), options() {}
39 0 : ZMQviewerObject(TObject* o) : object(o), previous(NULL),
40 0 : pad(-1), redraw(true), isnew(true), options() {}
41 0 : ZMQviewerObject(const ZMQviewerObject& o) : object(o.object), previous(o.previous),
42 0 : pad(o.pad),
43 0 : redraw(o.redraw),
44 0 : isnew(o.isnew),
45 0 : options(o.options) {}
46 :
47 : ZMQviewerObject& operator=(const ZMQviewerObject& o) {
48 0 : object = o.object;
49 0 : previous = o.previous;
50 0 : pad = o.pad;
51 0 : redraw = o.redraw;
52 0 : isnew = o.isnew;
53 0 : options = o.options;
54 0 : return *this;
55 : }
56 :
57 : bool SwapObject(ZMQviewerObject& from) {
58 0 : if (isnew) { return false; }
59 0 : if (from.object) {
60 0 : previous = object;
61 0 : std::swap(object, from.object);
62 0 : isnew = true;
63 0 : return true;
64 : }
65 0 : return false;
66 0 : }
67 :
68 0 : ~ZMQviewerObject() {}
69 : };
70 :
71 : struct AliZMQhistViewer : public AliOptionParser, public TQObject {
72 : public:
73 : //methods
74 : AliZMQhistViewer();
75 0 : virtual ~AliZMQhistViewer() {}
76 : int Run(void* arg);
77 : int ProcessOption(TString option, TString value);
78 0 : void SetCanvas(TCanvas* canvas) {fCanvas = canvas;}
79 : int GetObjects(AliAnalysisDataContainer* kont, std::vector<TObject*>* list, const char* prefix="");
80 : int GetObjects(TCollection* kont, std::vector<TObject*>* list, const char* prefix="");
81 :
82 : //signals
83 : void DataReady(); //*SIGNAL*
84 :
85 : //thread safe stuff
86 : int UpdateCanvas(TCanvas* canvas, TPRegexp* sel=NULL, TPRegexp* unsel=NULL);
87 : int GetData(void* socket);
88 : std::vector<ZMQviewerObject>* GetIncoming(std::vector<ZMQviewerObject>* in = NULL);
89 : std::string GetInfo(std::string* in = NULL);
90 : bool GetClearCanvas(bool* in = NULL);
91 : bool GetUpdateCanvas(bool* in = NULL);
92 : bool GetTerminated(bool* in = NULL);
93 : int GetPollInterval(int* in = NULL);
94 : std::string GetZMQconfig(std::string* in=NULL);
95 : TPRegexp* GetSelection(std::string* in=NULL);
96 : TPRegexp* GetUnSelection(std::string* in=NULL);
97 :
98 : private:
99 : AliZMQhistViewer(const AliZMQhistViewer&);
100 : AliZMQhistViewer& operator=(const AliZMQhistViewer&);
101 :
102 : //internal stuff
103 : static Int_t CountPads(TVirtualPad* pad);
104 :
105 : //configuration vars
106 : TCanvas* fCanvas;
107 : Bool_t fVerbose ;
108 : TString fZMQconfigIN ;
109 : int fZMQsocketModeIN;
110 : TString fZMQconfigCONFIG;
111 :
112 : TString fFilter ;
113 : int fPollInterval ;
114 : int fPollTimeout ;
115 : Bool_t fSort ;
116 :
117 : //internal state
118 : void* fZMQcontext ;
119 : void* fZMQin ;
120 : void* fZMQconfig;
121 : void* fZMQsleeper;
122 : void* fZMQsleeper2;
123 : std::deque<std::vector<ZMQviewerObject>*> fTrashQueue;
124 : std::vector<ZMQviewerObject>* fContent;
125 :
126 : TString fStatus ;
127 : Int_t fRunNumber ;
128 : TPRegexp* fSelectionRegexp ;
129 : TPRegexp* fUnSelectionRegexp ;
130 : TString fDrawOptions;
131 : Bool_t fScaleLogX ;
132 : Bool_t fScaleLogY ;
133 : Bool_t fScaleLogZ ;
134 : Bool_t fResetOnRequest ;
135 : Int_t fHistStats ;
136 :
137 : Bool_t fAllowResetAtSOR ;
138 :
139 : ULong64_t iterations;
140 :
141 : //inter thread exchange data
142 : std::vector<ZMQviewerObject>* fIncoming;
143 : std::string fInfo;
144 : bool fClearCanvas;
145 : bool fUpdateCanvas;
146 : bool fTerminated;
147 :
148 8 : ClassDef(AliZMQhistViewer, 0)
149 : };
150 :
151 : struct ZMQviewerObjectTitleComparator {
152 : bool operator()(const ZMQviewerObject& left, const std::string& right) {
153 : if (!(left.object)) {return true;}
154 : return right.compare(left.object->GetTitle())>0;
155 : }
156 :
157 : bool operator()(const ZMQviewerObject& left, const ZMQviewerObject& right) {
158 0 : if (!(left.object)) {return true;}
159 0 : if (!(right.object)) {return false;}
160 0 : return strcmp(right.object->GetTitle(),left.object->GetTitle())>0;
161 0 : }
162 : };
163 :
164 : #endif
|