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 /* This file is part of the XRootD software suite.                            */
00013 /*                                                                            */
00014 /* XRootD is free software: you can redistribute it and/or modify it under    */
00015 /* the terms of the GNU Lesser General Public License as published by the     */
00016 /* Free Software Foundation, either version 3 of the License, or (at your     */
00017 /* option) any later version.                                                 */
00018 /*                                                                            */
00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
00021 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
00022 /* License for more details.                                                  */
00023 /*                                                                            */
00024 /* You should have received a copy of the GNU Lesser General Public License   */
00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
00026 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
00027 /*                                                                            */
00028 /* The copyright holder's institutional names and contributor's names may not */
00029 /* be used to endorse or promote products derived from this software without  */
00030 /* specific prior written permission of the institution or contributor.       */
00031 /******************************************************************************/
00032 
00033 #include "XProtocol/YProtocol.hh"
00034 
00035 class XrdCmsRouting
00036 {
00037 public:
00038 
00039 enum {isInvalid = 0x00,
00040       isSync    = 0x02,
00041       Forward   = 0x04,
00042       noArgs    = 0x08,
00043       Delayable = 0x10,
00044       Repliable = 0x20,
00045       AsyncQ0   = 0x40,
00046       AsyncQ1   = 0x80
00047      };
00048 
00049 struct      theRouting {int reqCode; int reqOpts;};
00050 
00051 inline int  getRoute(int reqCode)
00052                       {return reqCode < XrdCms::kYR_MaxReq
00053                                       ? valVec[reqCode] : isInvalid;
00054                       }
00055 
00056             XrdCmsRouting(theRouting *initP)
00057                           {memset(valVec, 0, sizeof(valVec));
00058                            do {valVec[initP->reqCode] = initP->reqOpts;
00059                               } while((++initP)->reqCode);
00060                            }
00061             ~XrdCmsRouting() {}
00062 
00063 private:
00064 int          valVec[XrdCms::kYR_MaxReq];
00065 };
00066 
00067 /******************************************************************************/
00068 /*                    X r d C m s R o u t e r   C l a s s                     */
00069 /******************************************************************************/
00070 
00071 class XrdCmsNode;
00072 class XrdCmsRRData;
00073   
00074 class XrdCmsRouter
00075 {
00076 public:
00077 
00078 typedef const char *(XrdCmsNode::*NodeMethod_t)(XrdCmsRRData &);
00079 
00080 struct  theRoute {int reqCode; const char *reqName; NodeMethod_t reqMeth;};
00081 
00082 inline  NodeMethod_t getMethod(int Code)
00083                            {return Code < XrdCms::kYR_MaxReq
00084                                         ? methVec[Code] : (NodeMethod_t)0;
00085                            }
00086 
00087 inline  const char  *getName(int Code)
00088                             {return Code < XrdCms::kYR_MaxReq && nameVec[Code]
00089                                          ? nameVec[Code] : "?";
00090                             }
00091 
00092               XrdCmsRouter(theRoute *initP)
00093                           {memset(methVec, 0, sizeof(methVec));
00094                            do {nameVec[initP->reqCode] = initP->reqName;
00095                                methVec[initP->reqCode] = initP->reqMeth;
00096                               } while((++initP)->reqCode);
00097                            }
00098              ~XrdCmsRouter() {}
00099 
00100 private:
00101 
00102 const  char         *nameVec [XrdCms::kYR_MaxReq];
00103        NodeMethod_t  methVec [XrdCms::kYR_MaxReq];
00104 };
00105 
00106 namespace XrdCms
00107 {
00108 extern XrdCmsRouter  Router;
00109 extern XrdCmsRouting manVOps;
00110 extern XrdCmsRouting rdrVOps;
00111 extern XrdCmsRouting rspVOps;
00112 extern XrdCmsRouting srvVOps;
00113 extern XrdCmsRouting supVOps;
00114 }
00115 #endif