~drizzle-trunk/drizzle/development

2095.3.4 by Monty Taylor
Split out module vertex and then actually used it.
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2011 Monty Taylor
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; version 2 of the License.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
20
#pragma once
2095.3.4 by Monty Taylor
Split out module vertex and then actually used it.
21
22
#include <string>
23
24
#define BOOST_NO_HASH 1
25
#include <boost/graph/graph_traits.hpp>
26
#include <boost/graph/adjacency_list.hpp>
27
#include <boost/graph/topological_sort.hpp>
28
29
namespace drizzled
30
{
31
  enum vertex_properties_t { vertex_properties };
32
}
33
34
namespace boost
35
{
2385.3.6 by Olaf van der Spek
cppcheck
36
  template<> struct property_kind<drizzled::vertex_properties_t>
2095.3.4 by Monty Taylor
Split out module vertex and then actually used it.
37
  {
38
    typedef vertex_property_tag type;
39
  };
40
}
41
2252.1.21 by Olaf van der Spek
Common fwd
42
namespace drizzled {
43
namespace module {
2095.3.4 by Monty Taylor
Split out module vertex and then actually used it.
44
45
class Vertex
46
{
47
  std::string name_;
48
  Module *module_;
49
public:
50
  Vertex() :
51
    name_(""),
52
    module_(NULL)
53
  { }
2095.3.5 by Monty Taylor
Use the catalog registry.
54
  explicit Vertex(const std::string& name) :
55
    name_(name),
56
    module_(NULL)
57
  { }
2095.3.4 by Monty Taylor
Split out module vertex and then actually used it.
58
  Vertex(const std::string& name, Module *module) :
59
    name_(name),
60
    module_(module)
61
  { }
62
  Vertex(const Vertex& old) :
63
    name_(old.name_),
64
    module_(old.module_)
65
  { }
66
  Vertex& operator=(const Vertex& old)
67
  {
68
    name_= old.name_;
69
    module_= old.module_;
70
    return *this;
71
  }
72
  const std::string &getName() const
73
  {
74
    return name_;
75
  }
2095.3.5 by Monty Taylor
Use the catalog registry.
76
  void setModule(Module *module)
77
  {
78
    module_= module;
79
  }
80
  Module* getModule()
2095.3.4 by Monty Taylor
Split out module vertex and then actually used it.
81
  {
82
    return module_;
83
  }
84
};
85
2095.3.6 by Monty Taylor
Actually properly process module dependencies. w00t.
86
typedef std::pair<std::string, std::string> ModuleEdge;
87
typedef boost::adjacency_list<boost::vecS,
88
        boost::vecS,
89
        boost::bidirectionalS, 
90
        boost::property<boost::vertex_color_t,
91
        boost::default_color_type,
92
        boost::property<vertex_properties_t, Vertex> >
2095.3.7 by Monty Taylor
Fixed the dependency graph so that it doesn't get included in sql_yacc.yy.
93
          > VertexGraph;
94
typedef boost::graph_traits<VertexGraph>::vertex_descriptor VertexDesc;
2095.3.6 by Monty Taylor
Actually properly process module dependencies. w00t.
95
typedef std::vector<VertexDesc> VertexList;
96
2095.3.7 by Monty Taylor
Fixed the dependency graph so that it doesn't get included in sql_yacc.yy.
97
typedef boost::graph_traits<VertexGraph>::vertex_iterator vertex_iter;
2095.3.6 by Monty Taylor
Actually properly process module dependencies. w00t.
98
2095.3.4 by Monty Taylor
Split out module vertex and then actually used it.
99
} /* namespace module */
100
} /* namespace vertex */
101