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 #ifndef POLYGRAPH__BASE_POLYOPTS_H
7 #define POLYGRAPH__BASE_POLYOPTS_H
8 
9 #include "base/opts.h"
10 
11 class FileScanner;
12 
13 // a collection of command line options that are very specific to Poly
14 // see include/opts.h for more generic options
15 
16 
17 // which system call to use for scanning for ready files
18 class FileScanOpt: public Opt {
19 	public:
20 		FileScanOpt(OptGrp *aGrp, const char *aName, const char *aDescr, FileScanner *def);
21 
22 		virtual void report(ostream &) const;
23 
val()24 		FileScanner *val() { return theVal; }
25 		operator void*() const { return theVal ? (void*)-1 : 0; }
26 
27 	protected:
28 		virtual bool parse(const String &name, const String &val);
29 
30 		FileScanner *theVal;
31 };
32 
33 
34 // various message dump flags
35 typedef enum { dumpNone = 0, dumpAny = ~0U,
36 	dumpReq = 1, dumpRep = 2, dumpErr = 3, dumpSum, dumpEmbedStats,
37 	dumpTypeCnt, // must be last
38 	dumpHdr = 1, dumpBody = 2 } DumpFlags;
39 
40 class DumpFlagsOpt: public ListOpt {
41 	public:
42 		DumpFlagsOpt(OptGrp *aGrp, const char *aName, const char *aDescr);
43 
44 		virtual void report(ostream &) const;
45 
operator()46 		bool operator ()(DumpFlags type, DumpFlags part = dumpAny) const { return (theFlags[type] & part) != 0; }
47 
48 		void setAll(); // dump everything
49 
50 		void setFlag(DumpFlags type, DumpFlags part);
51 
52 	protected:
53 		virtual bool addItem(const String &item);
54 		const char *dumpPartStr(DumpFlags type) const;
55 
56 	protected:
57 		unsigned int theFlags[dumpTypeCnt];
58 };
59 
60 
61 // generic interface, but poly-specific implementation
62 class HostTypeOpt: public Opt {
63 	public:
64 		HostTypeOpt(OptGrp *aGrp, const char *aName, const char *aDescr);
65 
66 		virtual void report(ostream &) const;
67 
68 	protected:
69 		virtual bool parse(const String &name, const String &val);
70 };
71 
72 // generic interface, but poly-specific implementation
73 class VersionOpt: public Opt {
74 	public:
75 		VersionOpt(OptGrp *aGrp, const char *aName, const char *aDescr);
76 
77 		virtual void report(ostream &) const;
78 
79 	protected:
80 		virtual bool parse(const String &name, const String &val);
81 };
82 
83 #endif
84