ClearVertexDelta.cpp

Go to the documentation of this file.
00001 
00005 /* Copyright © 2009 James Legg.
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, either version 3 of the License, or
00009     (at your option) any later version.
00010 */
00011 
00012 #include "ClearVertexDelta.h"
00013 #include "InsertEdgeDelta.h"
00014 #include "../Track.h"
00015 
00016 namespace Document
00017 {
00018 
00019 ClearVertexDelta::ClearVertexDelta(std::size_t vertex_name)
00020     :   vertex_name(vertex_name)
00021 {
00022 }
00023 
00024 void ClearVertexDelta::apply(Track::Track & track)
00025 {
00026     Track::Path & path = track.get_path();
00027     Track::Path::Graph & graph = path.graph;
00028     Track::Path::Graph::vertex_descriptor vertex_descriptor = path.get_node_descriptor(vertex_name);
00029     
00030     // remove out edges.
00031     typedef Track::Path::Graph::out_edge_iterator out_edge_iterator;
00032     std::pair<out_edge_iterator, out_edge_iterator> out_edges;
00033     while (boost::out_degree(vertex_descriptor, graph))
00034     {
00035         out_edges = boost::out_edges(vertex_descriptor, graph);
00036         std::size_t edge_name = graph[*(out_edges.first)].get_name();
00037         boost::shared_ptr<DocumentDelta> delta(new RemoveEdgeDelta(edge_name));
00038         add_to_stack(delta, track);
00039     }
00040     
00041     // remove in edges
00042     typedef Track::Path::Graph::in_edge_iterator in_edge_iterator;
00043     std::pair<in_edge_iterator, in_edge_iterator> in_edges;
00044     while (boost::in_degree(vertex_descriptor, graph))
00045     {
00046         in_edges = boost::in_edges(vertex_descriptor, graph);
00047         std::size_t edge_name = graph[*(in_edges.first)].get_name();
00048         boost::shared_ptr<DocumentDelta> delta(new RemoveEdgeDelta(edge_name));
00049         add_to_stack(delta, track);
00050     }
00051 }
00052 
00053 } // namespace document

Get Racer at SourceForge.net. Fast, secure and Free Open Source software downloads

Generated at Mon Sep 6 00:41:11 2010 by Doxygen version 1.4.7 for Racer version svn335.