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 "VisibleGraph.h"
\r
22 // construction / destruction
\r
24 CVisibleGraph::CVisibleGraph()
\r
29 CVisibleGraph::~CVisibleGraph()
\r
36 void CVisibleGraph::Clear()
\r
38 for (size_t i = roots.size(); i > 0; --i)
\r
39 nodeFactory.Destroy (roots[i-1]);
\r
41 assert (GetNodeCount() == 0);
\r
45 CVisibleGraphNode* CVisibleGraph::Add ( const CFullGraphNode* base
\r
46 , CVisibleGraphNode* source
\r
47 , bool preserveNode)
\r
49 // (only) the first node must have no parent / prev node
\r
51 assert ((source == NULL) || !roots.empty());
\r
53 CVisibleGraphNode* result
\r
54 = nodeFactory.Create (base, source, preserveNode);
\r
57 roots.push_back (result);
\r
62 void CVisibleGraph::ReplaceRoot ( CVisibleGraphNode* oldRoot
\r
63 , CVisibleGraphNode* newRoot)
\r
65 assert (newRoot->GetPrevious() == NULL);
\r
66 assert (newRoot->GetCopySource() == NULL);
\r
68 for (size_t i = 0, count = roots.size(); i < count; ++i)
\r
69 if (roots[i] == oldRoot)
\r
75 // we should never get here
\r
80 void CVisibleGraph::RemoveRoot (CVisibleGraphNode* root)
\r
82 for (size_t i = 0, count = roots.size(); i < count; ++i)
\r
83 if (roots[i] == root)
\r
85 roots[i] = roots[count-1];
\r
91 // we should never get here
\r
96 void CVisibleGraph::AddRoot (CVisibleGraphNode* root)
\r
98 assert (root->GetPrevious() == NULL);
\r
99 assert (root->GetCopySource() == NULL);
\r
101 roots.push_back (root);
\r