CustomOptionType.hpp
1 #ifndef OPALS_CUSTOM_OPTION_TYPE_HPP_INCLUDED
2 #define OPALS_CUSTOM_OPTION_TYPE_HPP_INCLUDED
3 
4 #include <opals/fwd.hpp>
5 
6 #if 0
7 #define OPALS_C_DOXY_COMMENT(Arg)\
8  /##** Arg *##/
9 #endif
10 
11 namespace opals
12 {
13  /**
14  \class CustomOptionType
15  \tparam Derived the custom parameter type implementation
16 
17  \brief Base class for all custom parameter types.
18 
19  Following the curiously recurring template pattern. Must be derived from.
20 
21  \author wk
22  \date 05.02.2011
23 
24  \internal
25  Derive your custom parameter type from opals::CustomOptionType with the custom parameter type as template argument,
26  if the data type's help shall be appended to an parameter's module-specific long help
27  - on the usage screen (--help optionName)
28  - in the Python doc-string.
29 
30  _syntax() will be appended to _help(), if
31  - the module binding is not python, or
32  - _exportsPythonType() returns false (see CustomOptionTypeGeneralDescription.hpp).
33 
34  You may also include the general help in your exception messages.
35  Must be derived from (protected destructor).
36  */
37 
38  template<class Derived>
40  {
41  public:
42  /// get general help on this type
43  static const char * _help()
44  {
45  return Derived::help();
46  }
47  /// get the syntax used for parsing this type
48  static const char * _syntax()
49  {
50  return Derived::syntax();
51  }
52  /// returns true if this type is exposed to Python as a custom type, false otherwise (if it is represented as Python-string)
53  static bool _exportsPythonType()
54  {
55  return Derived::exportsPythonType();
56  }
57  protected:
58  ///protected, must be derived from
60  };
61 }
62 
63 #endif