Nymph  v1.5.2
Flow-Based Data Processing Framework
KTCommandLineOption.hh
Go to the documentation of this file.
1 /*
2  * KTCommandLineOption.hh
3  *
4  * Created on: Aug 1, 2012
5  * Author: nsoblath
6  */
7 
8 #ifndef KTCOMMANDLINEOPTION_H_
9 #define KTCOMMANDLINEOPTION_H_
10 
11 #include "KTCommandLineHandler.hh"
12 
13 #include <string>
14 
15 namespace Nymph
16 {
17  //class KTCommandLineHandler;
18 
19  template< typename XInputType >
21  {
22  public:
24  KTCommandLineOption(const std::string& group, const std::string& helpMsg, const std::string& longOpt, char shortOpt='#');
25  virtual ~KTCommandLineOption();
26 
27  protected:
29 
30  };
31 
32  template< typename XInputType >
34  fCLHandler(KTCommandLineHandler::get_instance())
35  {
36  }
37 
38  template< typename XInputType >
39  KTCommandLineOption< XInputType >::KTCommandLineOption(const std::string& group, const std::string& helpMsg, const std::string& longOpt, char shortOpt) :
40  fCLHandler(KTCommandLineHandler::get_instance())
41  {
42  if (shortOpt == '#')
43  {
44  fCLHandler->AddOption< XInputType >(group, helpMsg, longOpt);
45  }
46  else
47  {
48  fCLHandler->AddOption< XInputType >(group, helpMsg, longOpt, shortOpt);
49  }
50  }
51 
52  template< typename XInputType >
54  {
55  }
56 
57 
58  template< >
59  class KTCommandLineOption< bool >
60  {
61  public:
63  fCLHandler(KTCommandLineHandler::get_instance())
64  {
65  }
66  KTCommandLineOption(const std::string& group, const std::string& helpMsg, const std::string& longOpt, char shortOpt='#') :
67  fCLHandler(KTCommandLineHandler::get_instance())
68  {
69  if (shortOpt == '#')
70  {
71  fCLHandler->AddOption(group, helpMsg, longOpt);
72  }
73  else
74  {
75  fCLHandler->AddOption(group, helpMsg, longOpt, shortOpt);
76  }
77  }
79  {
80  }
81 
82  protected:
84 
85  };
86 
87 } /* namespace Nymph */
88 
89 #endif /* KTCOMMANDLINEOPTION_H_ */
bool AddOption(const std::string &aTitle, const std::string &aHelpMsg, const std::string &aLongOpt, char aShortOpt, bool aWarnOnDuplicate=true)
Simple option adding function, with short option (flag only; no values allowed)
Parses and stores command-line options.
Contains KTCommandLineHandler.
KTCommandLineHandler * fCLHandler
KTCommandLineOption(const std::string &group, const std::string &helpMsg, const std::string &longOpt, char shortOpt='#')