~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table_function_container.cc

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

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 <boost/foreach.hpp>
23
 
#include <drizzled/plugin/table_function.h>
24
 
#include <drizzled/table_function_container.h>
25
 
#include <drizzled/util/find_ptr.h>
 
21
#include "config.h"
 
22
#include "drizzled/plugin/table_function.h"
 
23
#include "drizzled/table_function_container.h"
 
24
 
 
25
#include <iostream>
26
26
 
27
27
using namespace std;
28
28
 
29
 
namespace drizzled {
 
29
namespace drizzled
 
30
{
30
31
 
31
32
plugin::TableFunction *TableFunctionContainer::getFunction(const std::string &path)
32
33
{
33
 
  ToolMap::mapped_type* ptr= find_ptr(table_map, path);
34
 
  return ptr ? *ptr : NULL;
 
34
  ToolMap::iterator iter= table_map.find(path);
 
35
 
 
36
  if (iter == table_map.end())
 
37
  {
 
38
    return NULL;
 
39
  }
 
40
  return (*iter).second;
35
41
}
36
42
 
37
 
void TableFunctionContainer::getNames(const string &predicate, std::set<std::string> &set_of_names)
 
43
void TableFunctionContainer::getNames(const string &predicate,
 
44
                                      std::set<std::string> &set_of_names)
38
45
{
39
 
  BOOST_FOREACH(ToolMap::reference i, table_map)
 
46
  for (ToolMap::iterator it= table_map.begin();
 
47
       it != table_map.end();
 
48
       it++)
40
49
  {
41
 
    if (i.second->visible() && (predicate.empty() || boost::iequals(predicate, i.second->getSchemaHome())))
42
 
      set_of_names.insert(i.second->getTableLabel());
 
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
    }
43
66
  }
44
67
}
45
68
 
46
69
void TableFunctionContainer::addFunction(plugin::TableFunction *tool)
47
70
{
48
 
  std::pair<ToolMap::iterator, bool> ret= table_map.insert(std::make_pair(tool->getPath(), tool));
49
 
  assert(ret.second);
 
71
  std::pair<ToolMap::iterator, bool> ret=
 
72
    table_map.insert(std::make_pair(tool->getPath(), tool));
 
73
  assert(ret.second == true);
50
74
}
51
75
 
52
76
} /* namespace drizzled */