EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Keyword.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Keyword.h
1 /* -------------------------------------------------------------------------- */
2 /* Keyword.h */
3 /* */
4 /* Definitions related to Keyword.cc code. */
5 /* */
6 /* A.Kisselev, PNPI, St.Petersburg, Russia. */
7 /* e-mail: kisselev@hermes.desy.de */
8 /* -------------------------------------------------------------------------- */
9 
10 //
11 // Prefer to change logic as less as possible in this code -> use linked
12 // list of keywords and a friend function to declare keywords;
13 //
14 
15 #ifndef _KEYWORD_H
16 #define _KEYWORD_H
17 
18 // Command line arguments starting from this prefix are 'keywords';
19 #define _KEYWORD_PREFIX_ "--"
20 
21 typedef int (*keywordfun)(int argc, char **argv);
22 
24 
25 class Keyword {
26  // Yes, just a friend function;
27  friend Keyword *declare_keyword(Keyword **root, char *_name, int _arg_num_min, int _arg_num_max,
28  keywordfun _fun,
29  MultipleInvocationMode _invocation_mode /*= _MULTIPLE_INVOCATION_DISABLED_*/);
30  public:
31  // Constructor;
32  Keyword(char *_name, int _arg_num_min, int _arg_num_max, keywordfun _fun,
33  MultipleInvocationMode _invocation_mode);
34 
35  // The actual parser;
36  int parseCommandLine(int argc, char **argv);
37 
38  private:
39  // Name of the command line key (like '--geometry');
40  char *name;
41  // Expected min/max # of arguments (keyword itself excluded);
43 
44  // Function to be called for this keyword;
46 
47  // Used to verify that the same key is not used twice in the same
48  // command line ...;
49  int activated;
50  // ... unless multiple invocation of this key is allowed;
52 
54 } ;
55 
56 #endif