~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/registry_dictionary/modules.cc

Reverted 1103

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2009 Sun Microsystems, Inc.
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; either version 2 of the License, or
9
 
 *  (at your option) any later version.
10
 
 *
11
 
 *  This program is distributed in the hope that it will be useful,
12
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 *  GNU General Public License for more details.
15
 
 *
16
 
 *  You should have received a copy of the GNU General Public License
17
 
 *  along with this program; if not, write to the Free Software
18
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
 
 */
20
 
 
21
 
#include "config.h"
22
 
 
23
 
#include "plugin/registry_dictionary/dictionary.h"
24
 
#include "drizzled/module/library.h"
25
 
 
26
 
using namespace std;
27
 
using namespace drizzled;
28
 
 
29
 
/* 
30
 
 * Suffix _STRING was added because sys/param.h on OSX defines a BSD symbol
31
 
 * to the version of BSD being run. FAIL
32
 
 */
33
 
static const string GPL_STRING("GPL");
34
 
static const string LGPL_STRING("LGPL");
35
 
static const string BSD_STRING("BSD");
36
 
static const string PROPRIETARY_STRING("PROPRIETARY");
37
 
 
38
 
ModulesTool::ModulesTool() :
39
 
  plugin::TableFunction("DATA_DICTIONARY", "MODULES")
40
 
{
41
 
  add_field("MODULE_NAME");
42
 
  add_field("MODULE_VERSION", 20);
43
 
  add_field("MODULE_AUTHOR");
44
 
  add_field("IS_BUILTIN", plugin::TableFunction::BOOLEAN, 0, false);
45
 
  add_field("MODULE_LIBRARY", 254);
46
 
  add_field("MODULE_DESCRIPTION", 254);
47
 
  add_field("MODULE_LICENSE", 80);
48
 
}
49
 
 
50
 
ModulesTool::Generator::Generator(Field **arg) :
51
 
  plugin::TableFunction::Generator(arg)
52
 
{
53
 
  module::Registry &registry= module::Registry::singleton();
54
 
  modules= registry.getList();
55
 
  it= modules.begin();
56
 
}
57
 
 
58
 
bool ModulesTool::Generator::populate()
59
 
{
60
 
  if (it == modules.end())
61
 
    return false;
62
 
 
63
 
  {
64
 
    module::Module *module= *it;
65
 
    const module::Manifest &manifest= module->getManifest();
66
 
 
67
 
    /* MODULE_NAME */
68
 
    push(module->getName());
69
 
 
70
 
    /* MODULE_VERSION */
71
 
    push(manifest.version ? manifest.version : 0);
72
 
 
73
 
    /* MODULE_AUTHOR */
74
 
    manifest.author ? push(manifest.author) : push();
75
 
 
76
 
    /* IS_BUILTIN */
77
 
    push((module->plugin_dl == NULL));
78
 
 
79
 
    /* MODULE_LIBRARY */
80
 
    push((module->plugin_dl == NULL) ? "builtin" : module->plugin_dl->getName());
81
 
 
82
 
    /* MODULE_DESCRIPTION */
83
 
    manifest.descr ? push(manifest.descr) : push();
84
 
 
85
 
    /* MODULE_LICENSE */
86
 
    switch (manifest.license) {
87
 
    case PLUGIN_LICENSE_GPL:
88
 
      push(GPL_STRING);
89
 
      break;
90
 
    case PLUGIN_LICENSE_BSD:
91
 
      push(BSD_STRING);
92
 
      break;
93
 
    case PLUGIN_LICENSE_LGPL:
94
 
      push(LGPL_STRING);
95
 
      break;
96
 
    default:
97
 
      push(PROPRIETARY_STRING);
98
 
      break;
99
 
    }
100
 
  }
101
 
 
102
 
  it++;
103
 
 
104
 
  return true;
105
 
}