Drizzled Public API Documentation

vertex.h
00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2011 Monty Taylor
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 #pragma once
00021 
00022 #include <string>
00023 
00024 #define BOOST_NO_HASH 1
00025 #include <boost/graph/graph_traits.hpp>
00026 #include <boost/graph/adjacency_list.hpp>
00027 #include <boost/graph/topological_sort.hpp>
00028 
00029 namespace drizzled
00030 {
00031   enum vertex_properties_t { vertex_properties };
00032 }
00033 
00034 namespace boost
00035 {
00036   template <> struct property_kind<drizzled::vertex_properties_t>
00037   {
00038     typedef vertex_property_tag type;
00039   };
00040 }
00041 
00042 namespace drizzled
00043 {
00044 
00045 namespace module
00046 {
00047 class Module;
00048 
00049 class Vertex
00050 {
00051   std::string name_;
00052   Module *module_;
00053 public:
00054   Vertex() :
00055     name_(""),
00056     module_(NULL)
00057   { }
00058   explicit Vertex(const std::string& name) :
00059     name_(name),
00060     module_(NULL)
00061   { }
00062   Vertex(const std::string& name, Module *module) :
00063     name_(name),
00064     module_(module)
00065   { }
00066   Vertex(const Vertex& old) :
00067     name_(old.name_),
00068     module_(old.module_)
00069   { }
00070   Vertex& operator=(const Vertex& old)
00071   {
00072     name_= old.name_;
00073     module_= old.module_;
00074     return *this;
00075   }
00076   const std::string &getName() const
00077   {
00078     return name_;
00079   }
00080   void setModule(Module *module)
00081   {
00082     module_= module;
00083   }
00084   Module* getModule()
00085   {
00086     return module_;
00087   }
00088 };
00089 
00090 typedef std::pair<std::string, std::string> ModuleEdge;
00091 typedef boost::adjacency_list<boost::vecS,
00092         boost::vecS,
00093         boost::bidirectionalS, 
00094         boost::property<boost::vertex_color_t,
00095         boost::default_color_type,
00096         boost::property<vertex_properties_t, Vertex> >
00097           > VertexGraph;
00098 typedef boost::graph_traits<VertexGraph>::vertex_descriptor VertexDesc;
00099 typedef std::vector<VertexDesc> VertexList;
00100 
00101 typedef boost::graph_traits<VertexGraph>::vertex_iterator vertex_iter;
00102 
00103 } /* namespace module */
00104 } /* namespace vertex */
00105