~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/module/option_map.h

  • Committer: Monty Taylor
  • Date: 2010-06-20 22:20:14 UTC
  • mfrom: (1626.1.4 build)
  • Revision ID: mordred@inaugust.com-20100620222014-9ae0uzuyo5lrhrld
Merge of Patrick's schema_dictionary test changes, Stewart's HA Status
variable move and more module program_options work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2010 Monty Taylor
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; version 2 of the License.
 
9
 *
 
10
 *  This program is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with this program; if not, write to the Free Software
 
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
18
 */
 
19
 
 
20
/**
 
21
 * @file
 
22
 * @brief An Proxy Wrapper around boost::program_options::variables_map
 
23
 */
 
24
 
 
25
#ifndef DRIZZLED_MODULE_OPTION_MAP_H
 
26
#define DRIZZLED_MODULE_OPTION_MAP_H
 
27
 
 
28
#include "drizzled/visibility.h"
 
29
 
 
30
#include <boost/program_options.hpp>
 
31
 
 
32
#include <string>
 
33
 
 
34
namespace drizzled
 
35
{
 
36
namespace module
 
37
{
 
38
 
 
39
/**
 
40
 * Options proxy wrapper. Provides pre-pending of module name to each option
 
41
 * which is added.
 
42
 */
 
43
class DRIZZLED_API option_map
 
44
{
 
45
  const std::string &module_name;
 
46
  const boost::program_options::variables_map &vm;
 
47
 
 
48
public:
 
49
 
 
50
  option_map(const std::string &module_name_in,
 
51
             const boost::program_options::variables_map &vm_in);
 
52
  option_map(const option_map &old);
 
53
 
 
54
  const boost::program_options::variable_value& operator[](const std::string &name_in) const
 
55
  {
 
56
    std::string new_name(module_name);
 
57
    new_name.push_back('.');
 
58
    new_name.append(name_in);
 
59
    return vm[new_name];
 
60
  }
 
61
 
 
62
  size_t count(const std::string &name_in) const
 
63
  {
 
64
    std::string new_name(module_name);
 
65
    new_name.push_back('.');
 
66
    new_name.append(name_in);
 
67
    return vm.count(new_name);
 
68
  }
 
69
 
 
70
private:
 
71
  
 
72
  /**
 
73
   * Don't allow default construction.
 
74
   */
 
75
  option_map();
 
76
 
 
77
  /**
 
78
   * Don't allow assignment of objects.
 
79
   */
 
80
  option_map& operator=(const option_map &);
 
81
};
 
82
 
 
83
} /* namespace module */
 
84
} /* namespace drizzled */
 
85
 
 
86
 
 
87
#endif /* DRIZZLED_MODULE_OPTION_MAP_H */