IMP logo
IMP Reference Guide  2.7.0
The Integrative Modeling Platform
Flag.h
Go to the documentation of this file.
1 /**
2  * \file IMP/Flag.h
3  * \brief Various general useful macros for IMP.
4  *
5  * Copyright 2007-2017 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPKERNEL_FLAG_H
10 #define IMPKERNEL_FLAG_H
11 
12 #include <IMP/kernel_config.h>
13 #include "internal/Flag.h"
14 #include <boost/program_options.hpp>
15 #include <string>
16 
17 #ifndef IMP_DOXYGEN
18 
19 IMPKERNEL_BEGIN_INTERNAL_NAMESPACE
20 extern IMPKERNELEXPORT boost::program_options::options_description flags;
21 extern IMPKERNELEXPORT boost::program_options::options_description advanced_flags;
22 IMPKERNEL_END_INTERNAL_NAMESPACE
23 #endif
24 
25 IMPKERNEL_BEGIN_NAMESPACE
26 
27 /** Use this to add a flag to the program. It is convertible to the
28 passed type and so can be used as the value itself.
29 
30 The ENABLED template argument is to allow the preprocessor to turn it
31 on or off (eg pass IMP_HAS_XXX).
32 
33 The Flag can be used like an instance of type T.
34 */
35 template <class T, bool ENABLED = true>
36 class Flag : public internal::FlagImpl<T, ENABLED> {
37  public:
38  Flag(std::string name, std::string description, T default_value = T())
39  : internal::FlagImpl<T, ENABLED>(internal::flags, name, description,
40  default_value) {}
41  Flag<T, ENABLED>& operator=(const T& o) {
42  internal::FlagImpl<T, ENABLED>::operator=(o);
43  return *this;
44  }
45 };
46 
47 //! Use this to add an advanced flag to the program.
48 /** Such flags are not shown unless requested (using `--help_advanced`).
49 
50  \see Flag for more info.
51 */
52 template <class T, bool ENABLED = true>
53 class AdvancedFlag : public internal::FlagImpl<T, ENABLED> {
54 
55  public:
56  AdvancedFlag(std::string name, std::string description, T default_value = T())
57  : internal::FlagImpl<T, ENABLED>(internal::advanced_flags, name,
58  description, default_value) {}
59  AdvancedFlag<T, ENABLED>& operator=(const T& o) {
60  internal::FlagImpl<T, ENABLED>::operator=(o);
61  return *this;
62  }
63 };
64 
65 IMPKERNEL_END_NAMESPACE
66 
67 #endif /* IMPKERNEL_FLAG_H */
Definition: Flag.h:36
Use this to add an advanced flag to the program.
Definition: Flag.h:53