Drizzled Public API Documentation

context.cc
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 #include <config.h>
21 #include <boost/algorithm/string.hpp>
22 #include <drizzled/module/context.h>
24 #include <drizzled/module/module.h>
25 #include <drizzled/drizzled.h>
26 #include <drizzled/sys_var.h>
27 
28 namespace drizzled {
29 namespace module {
30 
31 module::option_map Context::getOptions()
32 {
33  return module::option_map(module->getName(), getVariablesMap());
34 }
35 
36 void Context::registerVariable(sys_var *var)
37 {
38  var->setName(prepend_name(module->getName(), var->getName()));
39  module->addMySysVar(var);
40  add_sys_var_to_list(var);
41 }
42 
43 std::string Context::prepend_name(std::string module_name,
44  const std::string &var_name)
45 {
46  module_name.push_back('_');
47  module_name.append(var_name);
48  std::replace(module_name.begin(), module_name.end(), '-', '_');
49  return boost::to_lower_copy(module_name);
50 }
51 
52 } /* namespace module */
53 } /* namespace drizzled */