xrootd
XrdXrootdReqID.hh
Go to the documentation of this file.
1 #ifndef __XRDXROOTDREQID_HH_
2 #define __XRDXROOTDREQID_HH_
3 /******************************************************************************/
4 /* */
5 /* X r d X r o o t d R e q I D . h h */
6 /* */
7 /* (c) 2006 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /******************************************************************************/
12 
13 #include <string.h>
14 
15 // $Id$
16 
18 {
19 public:
20 
21 inline unsigned long long getID() {return Req.ID;}
22 
23 inline void getID(unsigned char *sid, int &lid,unsigned int &linst)
24  {memcpy(sid, Req.ids.Sid, sizeof(Req.ids.Sid));
25  lid = static_cast<int>(Req.ids.Lid);
26  linst = Req.ids.Linst;
27  }
28 
29 inline void setID(unsigned long long id) {Req.ID = id;}
30 
31 inline void setID(const unsigned char *sid,int lid,unsigned int linst)
32  {memcpy(Req.ids.Sid, sid, sizeof(Req.ids.Sid));
33  Req.ids.Lid = static_cast<unsigned short>(lid);
34  Req.ids.Linst = linst;
35  }
36 
37 inline unsigned long long setID(const unsigned char *sid)
38  {memcpy(Req.ids.Sid, sid, sizeof(Req.ids.Sid));
39  return Req.ID;
40  }
41 
42 inline unsigned char *Stream() {return Req.ids.Sid;}
43 
44  XrdXrootdReqID(unsigned long long id) {setID(id);}
45  XrdXrootdReqID(const unsigned char *sid, int lid, unsigned int linst)
46  {setID(sid ? (unsigned char *)"\0\0" : sid, lid, linst);}
48 
49 private:
50 
51 union {unsigned long long ID;
52  struct {unsigned int Linst;
53  unsigned short Lid;
54  unsigned char Sid[2];
55  } ids;
56  } Req;
57 };
58 #endif