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