xrootd
XrdCmsRole.hh
Go to the documentation of this file.
1 #ifndef __XRDCMSROLE_HH__
2 #define __XRDCMSROLE_HH__
3 /******************************************************************************/
4 /* */
5 /* X r d C m s R o l e . h h */
6 /* */
7 /* (c) 2011 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 
13 #include <string.h>
14 
15 // This class centralizes the naming of various roles servers can have.
16 
18 {
19 public:
20 
21 enum RoleID {MetaManager = 0,
25  };
26 
27 static RoleID Convert(const char *Tok1, const char *Tok2)
28  {if (!Tok2)
29  {if (!strcmp( Tok1, "server")) return Server;
30  if (!strcmp( Tok1, "supervisor")) return Supervisor;
31  if (!strcmp( Tok1, "peer")) return Peer;
32  return (strcmp(Tok1, "manager") ? noRole:Manager);
33  }
34  if (!strcmp( Tok1, "proxy"))
35  {if (!strcmp( Tok2, "server")) return ProxyServer;
36  if (!strcmp( Tok2, "supervisor")) return ProxySuper;
37  return (strcmp(Tok2, "manager") ? noRole:ProxyManager);
38  }
39  if (!strcmp( Tok1, "meta"))
40  return (strcmp(Tok2, "manager") ? noRole:MetaManager);
41  if (!strcmp( Tok1, "peer"))
42  return (strcmp(Tok2, "manager") ? noRole:Peer);
43  return noRole;
44  }
45 
46 static const char *Name(RoleID rid)
47  {static const char *rName[] = {"metamanager", // MetaMan
48  "manager", // Manager
49  "supervisor", // Super
50  "server", // Server
51  "proxy-manager", // ProxyMan
52  "proxy-super", // ProxySuper
53  "proxy-server", // ProxyServ
54  "peer-manager", // PeerMan
55  "peer" // Peer
56  };
57  if (rid >= MetaManager && rid < noRole) return rName[rid];
58  return "??";
59  }
60 
61 static const char *Type(RoleID rid) // Maximum of 3 characters plus null byte!
62  {static const char *tName[] = {"MM", // MetaMan
63  "M", // Manager
64  "R", // Super
65  "S", // Server
66  "PM", // ProxyMan
67  "PR", // ProxySuper
68  "PS", // ProxyServ
69  "EM", // PeerMan
70  "E" // Peer
71  };
72  if (rid >= MetaManager && rid < noRole) return tName[rid];
73  return "??";
74  }
75 
78 };
79 #endif