xrootd

XrdCmsRouting.hh

Go to the documentation of this file.
00001 #ifndef __CMS_ROUTING_H__
00002 #define __CMS_ROUTING_H__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                      X r d C m s R o u t i n g . h h                       */
00006 /*                                                                            */
00007 /* (c) 2007 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 "XProtocol/YProtocol.hh"
00014 
00015 class XrdCmsRouting
00016 {
00017 public:
00018 
00019 enum {isInvalid = 0x00,
00020       isSync    = 0x02,
00021       Forward   = 0x04,
00022       noArgs    = 0x08,
00023       Delayable = 0x10,
00024       Repliable = 0x20,
00025       AsyncQ0   = 0x40,
00026       AsyncQ1   = 0x80
00027      };
00028 
00029 struct      theRouting {int reqCode; int reqOpts;};
00030 
00031 inline int  getRoute(int reqCode)
00032                       {return reqCode < XrdCms::kYR_MaxReq
00033                                       ? valVec[reqCode] : isInvalid;
00034                       }
00035 
00036             XrdCmsRouting(theRouting *initP)
00037                           {memset(valVec, 0, sizeof(valVec));
00038                            do {valVec[initP->reqCode] = initP->reqOpts;
00039                               } while((++initP)->reqCode);
00040                            }
00041             ~XrdCmsRouting() {}
00042 
00043 private:
00044 int          valVec[XrdCms::kYR_MaxReq];
00045 };
00046 
00047 /******************************************************************************/
00048 /*                    X r d C m s R o u t e r   C l a s s                     */
00049 /******************************************************************************/
00050 
00051 class XrdCmsNode;
00052 class XrdCmsRRData;
00053   
00054 class XrdCmsRouter
00055 {
00056 public:
00057 
00058 typedef const char *(XrdCmsNode::*NodeMethod_t)(XrdCmsRRData &);
00059 
00060 struct  theRoute {int reqCode; const char *reqName; NodeMethod_t reqMeth;};
00061 
00062 inline  NodeMethod_t getMethod(int Code)
00063                            {return Code < XrdCms::kYR_MaxReq
00064                                         ? methVec[Code] : (NodeMethod_t)0;
00065                            }
00066 
00067 inline  const char  *getName(int Code)
00068                             {return Code < XrdCms::kYR_MaxReq && nameVec[Code]
00069                                          ? nameVec[Code] : "?";
00070                             }
00071 
00072               XrdCmsRouter(theRoute *initP)
00073                           {memset(methVec, 0, sizeof(methVec));
00074                            do {nameVec[initP->reqCode] = initP->reqName;
00075                                methVec[initP->reqCode] = initP->reqMeth;
00076                               } while((++initP)->reqCode);
00077                            }
00078              ~XrdCmsRouter() {}
00079 
00080 private:
00081 
00082 const  char         *nameVec [XrdCms::kYR_MaxReq];
00083        NodeMethod_t  methVec [XrdCms::kYR_MaxReq];
00084 };
00085 
00086 namespace XrdCms
00087 {
00088 extern XrdCmsRouter  Router;
00089 extern XrdCmsRouting manVOps;
00090 extern XrdCmsRouting rdrVOps;
00091 extern XrdCmsRouting rspVOps;
00092 extern XrdCmsRouting srvVOps;
00093 extern XrdCmsRouting supVOps;
00094 }
00095 #endif