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 namespace module {
00044 
00045 class Vertex
00046 {
00047   std::string name_;
00048   Module *module_;
00049 public:
00050   Vertex() :
00051     name_(""),
00052     module_(NULL)
00053   { }
00054   explicit Vertex(const std::string& name) :
00055     name_(name),
00056     module_(NULL)
00057   { }
00058   Vertex(const std::string& name, Module *module) :
00059     name_(name),
00060     module_(module)
00061   { }
00062   Vertex(const Vertex& old) :
00063     name_(old.name_),
00064     module_(old.module_)
00065   { }
00066   Vertex& operator=(const Vertex& old)
00067   {
00068     name_= old.name_;
00069     module_= old.module_;
00070     return *this;
00071   }
00072   const std::string &getName() const
00073   {
00074     return name_;
00075   }
00076   void setModule(Module *module)
00077   {
00078     module_= module;
00079   }
00080   Module* getModule()
00081   {
00082     return module_;
00083   }
00084 };
00085 
00086 typedef std::pair<std::string, std::string> ModuleEdge;
00087 typedef boost::adjacency_list<boost::vecS,
00088         boost::vecS,
00089         boost::bidirectionalS, 
00090         boost::property<boost::vertex_color_t,
00091         boost::default_color_type,
00092         boost::property<vertex_properties_t, Vertex> >
00093           > VertexGraph;
00094 typedef boost::graph_traits<VertexGraph>::vertex_descriptor VertexDesc;
00095 typedef std::vector<VertexDesc> VertexList;
00096 
00097 typedef boost::graph_traits<VertexGraph>::vertex_iterator vertex_iter;
00098 
00099 } /* namespace module */
00100 } /* namespace vertex */
00101