1    	// $Id: StObject.h,v 1.20 2015/08/28 19:54:18 perev Exp $
2    	// $Log: StObject.h,v $
3    	// Revision 1.20  2015/08/28 19:54:18  perev
4    	// Add specific copy constructor to StObject.
5    	// This ctr set zero to bit 1<<22. This boit means that object belongs
6    	// to structured container. But copy obviously not.
7    	//
8    	// Revision 1.19  2012/06/11 15:08:41  fisyak
9    	// std namespace, warn off for x64
10   	//
11   	// Revision 1.18  2012/02/21 18:48:37  perev
12   	// I/O mode flag added
13   	//
14   	// Revision 1.15  2007/04/26 04:16:41  perev
15   	// Remove senseless comment
16   	//
17   	// Revision 1.14  2007/03/15 16:27:32  fine
18   	//  Allow user to select the arbitrary StEvent object to be drawn with StEventDisplay
19   	//
20   	// Revision 1.13  2002/11/26 02:23:38  perev
21   	// new ROOT adoptation
22   	//
23   	// Revision 1.12  2001/05/30 17:46:42  perev
24   	// StEvent branching
25   	//
26   	// Revision 1.11  2000/12/09 02:11:02  perev
27   	// clone() called Clone()
28   	//
29   	//
30   	
31   	#ifndef STAR_StObject
32   	#define STAR_StObject
33   	 
34   	 
35   	//////////////////////////////////////////////////////////////////////////
36   	//                                                                      //
37   	// StObject class is a base class to implement StEvent                  //
38   	//                                                                      //
39   	//////////////////////////////////////////////////////////////////////////
40   	#include "TDataSet.h"
41   	
42   	class StXRefManager;
43   	class StXRefMain;
44   	class StRefArray;
45   	class StStrArray;
46   	
47   	enum EStObjectDrawBit { kMark2Draw = BIT(24)}; // mark object to be rendered by "EventDisplay"
48   	
49   	//_____________________________________________________________________________
50   	class StObject : public TObject {
51   	
52   	public:
53   	          StObject(){;}
54   	          StObject(const StObject &sto);
55   	          StObject &operator=(const StObject &sto);
56   	  virtual ~StObject();
57   	  virtual void Browse(TBrowser *b);
58   	  
59   	  virtual Bool_t IsFolder() 	const;
60   	  virtual TObject *clone() 	const {return ((TObject*)this)->Clone();}
61   	  Int_t   isZombie() 		const {return IsZombie();}
62   	  virtual void makeZombie(int flg=1)
63   	    {if (flg) {MakeZombie();} else {((UInt_t*)this)[1] &=~(kZombie);}} 
64   	  UInt_t  Ztreamer(TBuffer &R__b);
65   	  ClassDef(StObject,3) // Base class for StEvent
66   	
67   	static UInt_t 	         fgTally;
68   	
69   	};
70   	
71   	//_____________________________________________________________________________
72   	//////////////////////////////////////////////////////////////////////////
73   	//                                                                      //
74   	//  StUUDGen                                                             //
75   	//  The uuidgen creates a new universally unique identifier (UUID)      //
76   	//  using the libuuid(3) library.					//
77   	//                                                                      //
78   	//////////////////////////////////////////////////////////////////////////
79   	class StUUId
80   	{
81   	protected:
82   	   UInt_t fID[4];
83   	public:
84   	    	StUUId();
85   	virtual ~StUUId(){};
86   	void 	Generate();
87   	StUUId  &operator=(const StUUId &from);
88   	StUUId  &operator=(const char  *from);
89   	Int_t  IsNull() const {return (fID[3]==0);}
90   	
91   	//void  Streamer(TBuffer &b);
92   	int Compare(const StUUId &u2) const;
93   	ClassDef(StUUId,1)
94   	};   
95   	
96   	
97   	#include "TDataSet.h"
98   	
99   	//_____________________________________________________________________________
100  	class StXRef :public TDataSet 
101  	{
102  	public:
103  	StXRef(const char *brName="", StXRefMain *evt=0, UInt_t tally=0);
104  	virtual 		       ~StXRef();
105  	
106  	virtual		StXRefMain     *MakeMain() = 0 ;
107  	 virtual		      void      Synchro(int /* toMain */) = 0 ;
108  	virtual		StXRefMain     *GetMain();
109  	virtual		       int      IsMain() const		{return 0;}
110  	virtual		      void      SetMain(StXRefMain *m) 	{fMain  = m;}
111  	virtual		      void      Add(TDataSet *ds);
112  		const 	StUUId 	       &GetUUId() const       	{return   fUUId;}
113  			void         	SetUUId(const StUUId &id){fUUId    = id;}
114  			void         	GenUUId()		{fUUId.Generate();}
115  			void         	SetTally(UInt_t tally) 	{fTally = tally;}
116  			UInt_t         	GetTally()             	{return   fTally;}
117  	private:
118  	
119  	StUUId         fUUId;		//!
120  	UInt_t         fTally; 		//!
121  	StXRefMain     *fMain;          //!
122  	ClassDef(StXRef,1)
123  	};   
124  	
125  	
126  	
127  	//_____________________________________________________________________________
128  	class StXRefMain :public StXRef {
129  	public:
130  	    	 StXRefMain(const char *name="") : StXRef(name){};
131  	virtual ~StXRefMain();
132  	virtual  	void  		Split()=0;
133  	virtual	       	StXRefMain     *MakeMain() {return this;}
134  	virtual		      void      Synchro(int toMain){};
135  	ClassDef(StXRefMain,1)
136  	};
137  	
138  	//_____________________________________________________________________________
139  	class TPageMap  {
140  	
141  	enum EPageMap {kPAGE=2048,kBITS=11,kBITZ=22,kMASK=0x7ff,kLAST=0xfffff800};
142  	public:
143  	 TPageMap();
144  	~TPageMap();
145  	
146  	ULong_t *GET(UInt_t udx) ;
147  	ULong_t *Get(UInt_t udx) ;
148  	void     GetMiMax(UInt_t &udxMin,UInt_t &udxMax) {udxMin=fMinUdx;udxMax=fMaxUdx;}
149  	
150  	static  void     Test();
151  	private:
152  	ULong_t *NewPage();
153  	
154  	ULong_t *fTopPage;
155  	ULong_t *fLstPage;
156  	UInt_t   fLstUdx;
157  	ULong_t *fList;
158  	UInt_t   fMinUdx;
159  	UInt_t   fMaxUdx;
160  	
161  	
162  	};
163  	#ifndef __CINT__
164  	#include <list>
165  	#include <vector>
166  	#ifndef ST_NO_NAMESPACES
167  	using namespace std;
168  	#endif
169  	class StProxyUrr;
170  	
171  	typedef list<StProxyUrr*>  	        StCollList;
172  	typedef StCollList::iterator 		StCollListIter;
173  	typedef list<StXRefManager*> 		StXRefManagerList;
174  	typedef StXRefManagerList::iterator 	StXRefManagerListIter;
175  	typedef vector<UInt_t> 			UIntVector;
176  	typedef UIntVector::iterator 		UIntVectorIter;
177  	//_____________________________________________________________________________
178  	
179  	
180  	//_____________________________________________________________________________
181  	class StProxyUrr : public UIntVector {
182  	public:
183  	  	StProxyUrr(TObject  *coll){fArr = coll;		   fType=0;}
184  	  	StProxyUrr(TObject  **adr){fAdr = adr; 		   fType=1;}
185  	  	StProxyUrr(StObject **adr){fAdr = (TObject **)adr; fType=1;}
186  	       ~StProxyUrr(){fArr = 0;}
187  	int       GetType() {return fType;}
188  	TObject   *GetArr()  {return fArr;}
189  	TObject  **GetAdr()  {return fAdr;}
190  	
191  	private:
192  	int  fType;
193  	union {
194  	  TObject  *fArr;
195  	  TObject **fAdr;};
196  	};
197  	
198  	
199  	class StXRefManager : public TObject
200  	{
201  	public:
202  	    	StXRefManager(const StUUId &id);
203  	       ~StXRefManager();
204  	        
205  	        void    Cd();
206  	        void    AddColl (      StProxyUrr *rarr);
207  	        void    AddColl (const StStrArray *sarr);
208  	        void    Update ();
209  	        void    Clear (Option_t*);
210  	static  void    Cd        (StXRef     *xref);
211  	static  void    Open      (StXRef     *xref);
212  	static  void    Close     (StXRef     *xref);
213  	static  TDataSet *GetMain();
214  	
215  	private:
216  	        Int_t  fUpd;
217  	        UInt_t fTally;
218  	        StUUId fUUId;		//!
219  	        StCollList  fColList;
220  	        TPageMap  fObjTab;
221  	        StXRefMain *fMain;
222  	public:
223  	static StXRefManagerList fgManagerList;
224  	static StXRefManager 	*fgManager;
225  	static int 	         fgRWmode; //0=read,1=write,-1=undefined
226  	
227  	};
228  	
229  	#endif // -__CINT__
230  	#endif
231  	
232  	
233  	
234  	
235  	
236  	
237  	
238  	
239  	
240  	
241  	
242  	
243  	
244  	
245  	
246  	
247  	
248  	
249