Drizzled Public API Documentation

vertex.h
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 
20 #pragma once
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 {
36  template<> struct property_kind<drizzled::vertex_properties_t>
37  {
38  typedef vertex_property_tag type;
39  };
40 }
41 
42 namespace drizzled {
43 namespace module {
44 
45 class Vertex
46 {
47  std::string name_;
48  Module *module_;
49 public:
50  Vertex() :
51  name_(""),
52  module_(NULL)
53  { }
54  explicit Vertex(const std::string& name) :
55  name_(name),
56  module_(NULL)
57  { }
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  }
76  void setModule(Module *module)
77  {
78  module_= module;
79  }
80  Module* getModule()
81  {
82  return module_;
83  }
84 };
85 
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> >
93  > VertexGraph;
94 typedef boost::graph_traits<VertexGraph>::vertex_descriptor VertexDesc;
95 typedef std::vector<VertexDesc> VertexList;
96 
97 typedef boost::graph_traits<VertexGraph>::vertex_iterator vertex_iter;
98 
99 } /* namespace module */
100 } /* namespace vertex */
101