dca_interface  6.3.4
base_options.h
Go to the documentation of this file.
1 /* IBM Source Code */
2 /* (C) Copyright IBM Corp. 2009, 2012 */
3 /* Licensed Materials - Property of IBM */
4 /* US Government Users Restricted Rights - Use duplication or disclosure restricted by GSA Schedule Contract with IBM Corp. */
5 
6 #ifndef BASE_OPTIONS_H
7 #define BASE_OPTIONS_H
8 
15 namespace dca {
16 
18  class optionvalue_p;
19 
26  {
27  public:
33  OVT_String
34  };
35 
39  OptionValue( int );
41  OptionValue( double );
43  OptionValue( const std::string& );
45  virtual ~OptionValue();
46 
49 
51  operator int() const;
55  operator double() const;
59  operator std::string() const;
61  OptionValue& operator = ( const std::string& );
62 
64  PRIVATE_PTR optionvalue_p *_p;
65  };
66 
68  class options_p;
79  class Options
80  {
81  public:
82 
92  static Options create( const DcaInstance& aDcaInstance );
93 
95  Options();
96  Options( const Options& rhi );
97  Options& operator = ( const Options& rhi );
98  virtual ~Options();
100 
108  bool find( const std::string& key, OptionValue& value ) const;
114  void erase( const std::string& key );
126  void set( const std::string& key, const OptionValue& value );
127 
129  PRIVATE_PTR options_p *_p;
130  };
131 
137  extern Options DefaultOptions;
138 
139 }
140 
141 #endif
OptionValue(const std::string &)
Creates an option value with string type and sets the value.
void set(const std::string &key, const OptionValue &value)
Add or updates an option in the current Options.
Generic encapsulation of a value used in Options objects.
Definition: base_options.h:26
static Options create(const DcaInstance &aDcaInstance)
Creates an empty option object.
Options DefaultOptions
A constant for a default empty options object. This can be used for functions which require an Option...
OptionValueType type() const
Returns type of the option value.
OptionValue(int)
Creates an option value with integer type and sets the value.
@ OVT_Integer
Option type is numeric (signed)
Definition: base_options.h:31
OptionValueType
Defines the available types of an option value.
Definition: base_options.h:29
OptionValue(double)
Creates an option value with double type and sets the value.
Generic option class, used to set up optional options for several classes, modules etc.
Definition: base_options.h:80
@ OVT_Unknown
Unassigned option type.
Definition: base_options.h:30
OptionValue()
Creates an option value with unknown type.
OptionValue & operator=(int)
Is used to assign a new value and set the type to integer.
@ OVT_Double
Option type is floating point.
Definition: base_options.h:32
Encapsulates the init and deinit of the DCA API.
Definition: base_classes.h:315
@ OVT_String
Option type is string.
Definition: base_options.h:33
bool find(const std::string &key, OptionValue &value) const
Perform a lookup for a given key, and return its value and whether or not it was found.
#define PRIVATE_PTR
Type for private pointer implementations, for internal use only.
Definition: base_types.h:83
void erase(const std::string &key)
Erases an option from the current Options instance if present. This function does nothing if the opti...