~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table_function_container.cc

  • Committer: Monty Taylor
  • Date: 2011-03-15 16:10:15 UTC
  • mfrom: (2235.3.1 staging)
  • Revision ID: mordred@inaugust.com-20110315161015-qceggirmf3cct7cw
Merge in libdrizzle install changes, doc changes and some header
refactoring.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include "config.h"
22
 
#include "drizzled/plugin/table_function.h"
23
 
#include "drizzled/table_function_container.h"
24
 
 
25
 
#include <iostream>
 
21
#include <config.h>
 
22
#include <boost/foreach.hpp>
 
23
#include <drizzled/plugin/table_function.h>
 
24
#include <drizzled/table_function_container.h>
 
25
#include <drizzled/util/find_ptr.h>
26
26
 
27
27
using namespace std;
28
28
 
29
 
namespace drizzled
30
 
{
 
29
namespace drizzled {
31
30
 
32
31
plugin::TableFunction *TableFunctionContainer::getFunction(const std::string &path)
33
32
{
34
 
  ToolMap::iterator iter= table_map.find(path);
35
 
 
36
 
  if (iter == table_map.end())
37
 
  {
38
 
    return NULL;
39
 
  }
40
 
  return (*iter).second;
 
33
  ToolMap::mapped_type* ptr= find_ptr(table_map, path);
 
34
  return ptr ? *ptr : NULL;
41
35
}
42
36
 
43
 
void TableFunctionContainer::getNames(const string &predicate,
44
 
                                      std::set<std::string> &set_of_names)
 
37
void TableFunctionContainer::getNames(const string &predicate, std::set<std::string> &set_of_names)
45
38
{
46
 
  for (ToolMap::iterator it= table_map.begin();
47
 
       it != table_map.end();
48
 
       it++)
 
39
  BOOST_FOREACH(ToolMap::reference i, table_map)
49
40
  {
50
 
    plugin::TableFunction *tool= (*it).second;
51
 
 
52
 
    if (tool->visable())
53
 
    {
54
 
      if (predicate.length())
55
 
      {
56
 
        if (boost::iequals(predicate, tool->getSchemaHome()))
57
 
        {
58
 
          set_of_names.insert(tool->getTableLabel());
59
 
        }
60
 
      }
61
 
      else
62
 
      {
63
 
        set_of_names.insert(tool->getTableLabel());
64
 
      }
65
 
    }
 
41
    if (i.second->visible() && (predicate.empty() || boost::iequals(predicate, i.second->getSchemaHome())))
 
42
      set_of_names.insert(i.second->getTableLabel());
66
43
  }
67
44
}
68
45
 
69
46
void TableFunctionContainer::addFunction(plugin::TableFunction *tool)
70
47
{
71
 
  std::pair<ToolMap::iterator, bool> ret=
72
 
    table_map.insert(std::make_pair(tool->getPath(), tool));
73
 
  assert(ret.second == true);
 
48
  std::pair<ToolMap::iterator, bool> ret= table_map.insert(std::make_pair(tool->getPath(), tool));
 
49
  assert(ret.second);
74
50
}
75
51
 
76
52
} /* namespace drizzled */