1 
2 /* Web Polygraph       http://www.web-polygraph.org/
3  * Copyright 2003-2011 The Measurement Factory
4  * Licensed under the Apache License, Version 2.0 */
5 
6 #include "pgl/pgl.h"
7 
8 #include "xstd/String.h"
9 #include "pgl/PglRec.h"
10 #include "pgl/PglArraySym.h"
11 #include "pgl/BenchSym.h"
12 #include "pgl/BenchSideSym.h"
13 #include "pgl/SrvLb4AsSym.h"
14 
15 
16 
17 const String SrvLb4AsSym::TheType = "SrvLb4As";
18 
19 static String strSrvLb4 = "SrvLb-4";
20 static String strAddrArr = "addr[]";
21 
22 
SrvLb4AsSym()23 SrvLb4AsSym::SrvLb4AsSym(): VerFourAsSym(TheType, new PglRec) {
24 	kind(strSrvLb4);
25 }
26 
SrvLb4AsSym(const String & aType,PglRec * aRec)27 SrvLb4AsSym::SrvLb4AsSym(const String &aType, PglRec *aRec): VerFourAsSym(aType, aRec) {
28 }
29 
isA(const String & type) const30 bool SrvLb4AsSym::isA(const String &type) const {
31 	return VerFourAsSym::isA(type) || type == TheType;
32 }
33 
dupe(const String & type) const34 SynSym *SrvLb4AsSym::dupe(const String &type) const {
35 	if (isA(type))
36 		return new SrvLb4AsSym(this->type(), theRec->clone());
37 	return VerFourAsSym::dupe(type);
38 }
39 
robots(ArraySym * & addrs) const40 String SrvLb4AsSym::robots(ArraySym *&addrs) const {
41 	return addresses(theBench->clientSide(), addrs);
42 }
43 
servers(ArraySym * & addrs) const44 String SrvLb4AsSym::servers(ArraySym *&addrs) const {
45 	if (const ArraySym *space = theBench->serverSide()->addrSpace()) {
46 		cerr << space->loc() << "warning: SrvLb4As addressing scheme"
47 			<< " uses server_side.hosts only; your setting of"
48 			<< " server_side.addr_space will be ignored" << endl;
49 	}
50 
51 	if (ArraySym *hosts = theBench->serverSide()->hostsSym()) {
52 		if (hosts->count()) {
53 			addrs = &((ArraySym&)hosts->clone()->cast(strAddrArr));
54 			return String();
55 		}
56 	}
57 
58 	return "no server_side.hosts specified";
59 }
60 
proxies(ArraySym * & addrs) const61 String SrvLb4AsSym::proxies(ArraySym *&addrs) const {
62 	return VerFourAsSym::proxies(addrs);
63 }
64