Drizzled Public API Documentation

context.h

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 #pragma once
00021 
00037 #include <boost/noncopyable.hpp>
00038 #include <drizzled/module/registry.h>
00039 #include <drizzled/visibility.h>
00040 
00041 namespace drizzled {
00042 
00043 class sys_var;
00044 
00045 namespace module {
00046 
00047 class Module;
00048 class option_map;
00049 
00050 class DRIZZLED_API Context : boost::noncopyable
00051 {
00052 public:
00053 
00054   Context(module::Registry &registry_arg,
00055           module::Module *module_arg) :
00056      registry(registry_arg),
00057      module(module_arg)
00058   { }
00059 
00060   template<class T>
00061   void add(T *plugin)
00062   {
00063     plugin->setModule(module);
00064     registry.add(plugin);
00065   }
00066 
00067   template<class T>
00068   void remove(T *plugin)
00069   {
00070     registry.remove(plugin);
00071   }
00072 
00073   void registerVariable(sys_var *var);
00074 
00075   option_map getOptions();
00076 
00077   static std::string prepend_name(std::string module_name,
00078                                   const std::string &var_name);
00079 private:
00080   module::Registry &registry;
00081   module::Module *module;
00082 };
00083 
00084 
00085 } /* namespace module */
00086 } /* namespace drizzled */
00087