drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
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#ifndef BOOST_NO_HASH
25#define BOOST_NO_HASH 1
26#endif
27#include <boost/graph/graph_traits.hpp>
28#include <boost/graph/adjacency_list.hpp>
29#include <boost/graph/topological_sort.hpp>
30
31namespace drizzled
32{
33 enum vertex_properties_t { vertex_properties };
34}
35
36namespace boost
37{
38 template<> struct property_kind<drizzled::vertex_properties_t>
39 {
40 typedef vertex_property_tag type;
41 };
42}
43
44namespace drizzled {
45namespace module {
46
47class Vertex
48{
49 std::string name_;
50 Module *module_;
51public:
52 Vertex() :
53 name_(""),
54 module_(NULL)
55 { }
56 explicit Vertex(const std::string& name) :
57 name_(name),
58 module_(NULL)
59 { }
60 Vertex(const std::string& name, Module *module) :
61 name_(name),
62 module_(module)
63 { }
64 Vertex(const Vertex& old) :
65 name_(old.name_),
66 module_(old.module_)
67 { }
68 Vertex& operator=(const Vertex& old)
69 {
70 name_= old.name_;
71 module_= old.module_;
72 return *this;
73 }
74 const std::string &getName() const
75 {
76 return name_;
77 }
78 void setModule(Module *module)
79 {
80 module_= module;
81 }
82 Module* getModule()
83 {
84 return module_;
85 }
86};
87
88typedef std::pair<std::string, std::string> ModuleEdge;
89typedef boost::adjacency_list<boost::vecS,
90 boost::vecS,
91 boost::bidirectionalS,
92 boost::property<boost::vertex_color_t,
93 boost::default_color_type,
94 boost::property<vertex_properties_t, Vertex> >
95 > VertexGraph;
96typedef boost::graph_traits<VertexGraph>::vertex_descriptor VertexDesc;
97typedef std::vector<VertexDesc> VertexList;
98
99typedef boost::graph_traits<VertexGraph>::vertex_iterator vertex_iter;
100
101} /* namespace module */
102} /* namespace vertex */
103
TODO: Rename this file - func.h is stupid.