~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/module/registry.cc

  • Committer: Monty Taylor
  • Date: 2011-01-18 05:29:46 UTC
  • mto: (2114.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 2115.
  • Revision ID: mordred@inaugust.com-20110118052946-j7a7v3qsump62duw
Use the catalog registry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
107
107
 
108
108
  module_registry_[add_str]= handle;
109
109
 
 
110
  VertexDesc handle_vertex;
110
111
  Vertex vertex_info(add_str, handle);
111
112
 
112
 
  VertexDesc handle_vertex= boost::add_vertex(depend_graph_);
 
113
  /* It's possible we could have added a vertex without a module attached
 
114
     as part of adding dependency edges */
 
115
  bool found_vertex= false;
 
116
  vertex_iter vertexes= boost::vertices(depend_graph_).first;
 
117
  while (vertexes != vertices(depend_graph_).second)
 
118
  {
 
119
    if (properties(*vertexes).getName() == add_str)
 
120
    {
 
121
      found_vertex= true;
 
122
      break;
 
123
    }
 
124
    ++vertexes;
 
125
  }
 
126
  if (found_vertex)
 
127
  {
 
128
    handle_vertex= *vertexes;
 
129
  }
 
130
  else
 
131
  {
 
132
    handle_vertex= boost::add_vertex(depend_graph_);
 
133
  }
113
134
  properties(handle_vertex)= vertex_info;
 
135
 
 
136
 
 
137
  Module::Depends::const_iterator handle_deps= handle->getDepends().begin();
 
138
  while (handle_deps != handle->getDepends().end())
 
139
  {
 
140
    std::string dep_str((*handle_deps));
 
141
    transform(dep_str.begin(), dep_str.end(),
 
142
              dep_str.begin(), ::tolower);
 
143
 
 
144
    bool found_dep= false;
 
145
    vertex_iter it= boost::vertices(depend_graph_).first;
 
146
    while (it != vertices(depend_graph_).second)
 
147
    {
 
148
      if (properties(*it).getName() == dep_str)
 
149
      {
 
150
        found_dep= true;
 
151
        add_edge(handle_vertex, *it, depend_graph_);
 
152
        break;
 
153
      }
 
154
      ++it;
 
155
    }
 
156
    if (not found_dep)
 
157
    {
 
158
      Vertex dep_vertex_info(dep_str);
 
159
      VertexDesc dep_vertex= boost::add_vertex(depend_graph_);
 
160
      properties(dep_vertex)= dep_vertex_info;
 
161
    }
 
162
 
 
163
    ++handle_deps;
 
164
  }
 
165
 
114
166
}
115
167
 
116
168
void module::Registry::remove(module::Module *handle)
133
185
  assert(arg.size() == plugin_registry.size());
134
186
}
135
187
 
136
 
vector<module::Module *> module::Registry::getList(bool active)
 
188
module::Registry::ModuleList module::Registry::getList()
137
189
{
138
 
  module::Module *plugin= NULL;
139
 
 
140
190
  std::vector<module::Module *> plugins;
141
 
  plugins.reserve(module_registry_.size());
142
 
 
143
 
  ModuleMap::iterator map_iter;
144
 
  for (map_iter= module_registry_.begin();
145
 
       map_iter != module_registry_.end();
146
 
       map_iter++)
 
191
 
 
192
  std::cout << "In module::Registry::getList" << std::endl;
 
193
  
 
194
  VertexList vertex_list;
 
195
 
 
196
  boost::topological_sort(depend_graph_, std::back_inserter(vertex_list));
 
197
 
 
198
  std::cout << "plugin load ordering: ";
 
199
  for (VertexList::iterator i = vertex_list.begin();
 
200
       i != vertex_list.end(); ++i)
147
201
  {
148
 
    plugin= (*map_iter).second;
149
 
    if (active)
150
 
      plugins.push_back(plugin);
151
 
    else if (plugin->isInited)
152
 
      plugins.push_back(plugin);
 
202
    std::cout << properties(*i).getName() << " ";
 
203
    if (properties(*i).getModule() != NULL)
 
204
    {
 
205
      plugins.push_back(properties(*i).getModule());
 
206
    }  
153
207
  }
 
208
  std::cout << std::endl;
154
209
 
155
210
  return plugins;
156
211
}