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 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 #include <cstring>
34 
36 {
37 public:
38 
39 inline unsigned long long getID() {return Req.ID;}
40 
41 inline void getID(unsigned char *sid, int &lid,unsigned int &linst)
42  {memcpy(sid, Req.ids.Sid, sizeof(Req.ids.Sid));
43  lid = static_cast<int>(Req.ids.Lid);
44  linst = Req.ids.Linst;
45  }
46 
47 inline void setID(unsigned long long id) {Req.ID = id;}
48 
49 inline void setID(const unsigned char *sid,int lid,unsigned int linst)
50  {memcpy(Req.ids.Sid, sid, sizeof(Req.ids.Sid));
51  Req.ids.Lid = static_cast<unsigned short>(lid);
52  Req.ids.Linst = linst;
53  }
54 
55 inline unsigned long long setID(const unsigned char *sid)
56  {memcpy(Req.ids.Sid, sid, sizeof(Req.ids.Sid));
57  return Req.ID;
58  }
59 
60 inline unsigned char *Stream() {return Req.ids.Sid;}
61 
62  XrdXrootdReqID(unsigned long long id) {setID(id);}
63  XrdXrootdReqID(const unsigned char *sid, int lid, unsigned int linst)
64  {setID(sid ? (unsigned char *)"\0\0" : sid, lid, linst);}
66 
67 private:
68 
69 union {unsigned long long ID;
70  struct {unsigned int Linst;
71  unsigned short Lid;
72  unsigned char Sid[2];
73  } ids;
74  } Req;
75 };
76 #endif
#define ID
void setID(unsigned long long id)
XrdXrootdReqID(unsigned long long id)
unsigned char * Stream()
void getID(unsigned char *sid, int &lid, unsigned int &linst)
XrdXrootdReqID(const unsigned char *sid, int lid, unsigned int linst)
void setID(const unsigned char *sid, int lid, unsigned int linst)
unsigned long long getID()
unsigned long long setID(const unsigned char *sid)