xrootd
|
00001 #ifndef __XRDXROOTDREQID_HH_ 00002 #define __XRDXROOTDREQID_HH_ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d X r o o t d R e q I D . h h */ 00006 /* */ 00007 /* (c) 2006 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* All Rights Reserved */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC02-76-SFO0515 with the Department of Energy */ 00011 /******************************************************************************/ 00012 00013 #include <string.h> 00014 00015 // $Id$ 00016 00017 class XrdXrootdReqID 00018 { 00019 public: 00020 00021 inline unsigned long long getID() {return Req.ID;} 00022 00023 inline void getID(unsigned char *sid, int &lid,unsigned int &linst) 00024 {memcpy(sid, Req.ids.Sid, sizeof(Req.ids.Sid)); 00025 lid = static_cast<int>(Req.ids.Lid); 00026 linst = Req.ids.Linst; 00027 } 00028 00029 inline void setID(unsigned long long id) {Req.ID = id;} 00030 00031 inline void setID(const unsigned char *sid,int lid,unsigned int linst) 00032 {memcpy(Req.ids.Sid, sid, sizeof(Req.ids.Sid)); 00033 Req.ids.Lid = static_cast<unsigned short>(lid); 00034 Req.ids.Linst = linst; 00035 } 00036 00037 inline unsigned long long setID(const unsigned char *sid) 00038 {memcpy(Req.ids.Sid, sid, sizeof(Req.ids.Sid)); 00039 return Req.ID; 00040 } 00041 00042 inline unsigned char *Stream() {return Req.ids.Sid;} 00043 00044 XrdXrootdReqID(unsigned long long id) {setID(id);} 00045 XrdXrootdReqID(const unsigned char *sid, int lid, unsigned int linst) 00046 {setID(sid ? (unsigned char *)"\0\0" : sid, lid, linst);} 00047 XrdXrootdReqID() {} 00048 00049 private: 00050 00051 union {unsigned long long ID; 00052 struct {unsigned int Linst; 00053 unsigned short Lid; 00054 unsigned char Sid[2]; 00055 } ids; 00056 } Req; 00057 }; 00058 #endif