Drizzled Public API Documentation

context.cc

00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2010 Monty Taylor
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 #include <config.h>
00021 #include <boost/algorithm/string.hpp>
00022 #include <drizzled/module/context.h>
00023 #include <drizzled/module/option_map.h>
00024 #include <drizzled/module/module.h>
00025 #include <drizzled/drizzled.h>
00026 #include <drizzled/sys_var.h>
00027 
00028 namespace drizzled {
00029 namespace module {
00030 
00031 module::option_map Context::getOptions()
00032 {
00033   return module::option_map(module->getName(), getVariablesMap());
00034 }
00035 
00036 void Context::registerVariable(sys_var *var)
00037 {
00038   var->setName(prepend_name(module->getName(), var->getName()));
00039   module->addMySysVar(var);
00040   add_sys_var_to_list(var);
00041 }
00042 
00043 std::string Context::prepend_name(std::string module_name,
00044                                   const std::string &var_name)
00045 {
00046   module_name.push_back('_');
00047   module_name.append(var_name);
00048   std::replace(module_name.begin(), module_name.end(), '-', '_');
00049   return boost::to_lower_copy(module_name);
00050 }
00051 
00052 } /* namespace module */
00053 } /* namespace drizzled */