1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2008 - TortoiseSVN
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
20 #include "VisibleGraphBuilder.h"
\r
21 #include "FullGraph.h"
\r
22 #include "VisibleGraph.h"
\r
23 #include "CopyFilterOptions.h"
\r
26 #define new DEBUG_NEW
\r
28 static char THIS_FILE[] = __FILE__;
\r
31 // construction / destruction (nothing to do here)
\r
33 CVisibleGraphBuilder::CVisibleGraphBuilder
\r
34 ( const CFullGraph& fullGraph
\r
35 , CVisibleGraph& visibleGraph
\r
36 , const CCopyFilterOptions& copyFilter)
\r
37 : fullGraph (fullGraph)
\r
38 , visibleGraph (visibleGraph)
\r
39 , copyFilter (copyFilter)
\r
43 CVisibleGraphBuilder::~CVisibleGraphBuilder(void)
\r
49 void CVisibleGraphBuilder::Run()
\r
51 visibleGraph.Clear();
\r
52 Copy (fullGraph.GetRoot(), NULL);
\r
55 // the actual copy loop
\r
57 void CVisibleGraphBuilder::CopyBranches ( const CFullGraphNode* source
\r
58 , CVisibleGraphNode* target)
\r
60 for ( const CFullGraphNode::CCopyTarget* copy = source->GetFirstCopyTarget()
\r
62 ; copy = copy->next())
\r
64 Copy (copy->value(), target);
\r
68 void CVisibleGraphBuilder::Copy ( const CFullGraphNode* source
\r
69 , CVisibleGraphNode* target)
\r
73 ICopyFilterOption::EResult filterAction = copyFilter.ShallRemove (source);
\r
74 while ( (filterAction != ICopyFilterOption::KEEP_NODE)
\r
75 && (filterAction != ICopyFilterOption::PRESERVE_NODE))
\r
77 // stop copy here, if the whole sub-tree shall be removed
\r
79 if (filterAction == ICopyFilterOption::REMOVE_SUBTREE)
\r
84 assert (filterAction == ICopyFilterOption::REMOVE_NODE);
\r
85 CopyBranches (source, NULL);
\r
87 source = source->GetNext();
\r
96 filterAction = copyFilter.ShallRemove (source);
\r
99 // copy the node itself
\r
101 bool preserveNode = filterAction != ICopyFilterOption::PRESERVE_NODE;
\r
102 target = visibleGraph.Add (source, target, preserveNode);
\r
106 CopyBranches (source, target);
\r
110 source = source->GetNext();
\r
112 while (source != NULL);
\r