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
21 #include "FullGraphNode.h"
\r
23 // CVisibleGraphNode::CFactory methods
\r
25 CFullGraphNode::CFactory::CFactory()
\r
26 : nodePool (sizeof (CFullGraphNode), 1024)
\r
27 , copyTargetFactory()
\r
31 CFullGraphNode* CFullGraphNode::CFactory::Create
\r
32 ( const CDictionaryBasedTempPath& path
\r
33 , revision_t revision
\r
34 , CNodeClassification classification
\r
35 , CFullGraphNode* source)
\r
37 CFullGraphNode * result = static_cast<CFullGraphNode *>(nodePool.malloc());
\r
38 new (result) CFullGraphNode (path, revision, classification, source, copyTargetFactory);
\r
42 void CFullGraphNode::CFactory::Replace ( CFullGraphNode* toReplace
\r
43 , CFullGraphNode::CCopyTarget*& toMove
\r
44 , CNodeClassification newClassification)
\r
46 // remove the old node
\r
48 CFullGraphNode* previousNode = toReplace->GetPrevious();
\r
49 Destroy (toReplace);
\r
51 // extract the new node
\r
53 CFullGraphNode* toInsert = copyTargetFactory.remove (toMove);
\r
55 // (re-)insert the new node
\r
57 toInsert->classification = newClassification;
\r
58 toInsert->InsertAt (previousNode, copyTargetFactory);
\r
61 void CFullGraphNode::CFactory::Destroy (CFullGraphNode* node)
\r
63 node->DestroySubNodes (*this, copyTargetFactory);
\r
65 node->~CFullGraphNode();
\r
66 nodePool.free (node);
\r
69 // CVisibleGraphNode construction / destruction
\r
71 CFullGraphNode::CFullGraphNode
\r
72 ( const CDictionaryBasedTempPath& path
\r
73 , revision_t revision
\r
74 , CNodeClassification classification
\r
75 , CFullGraphNode* source
\r
76 , CCopyTarget::factory& copyTargetFactory)
\r
78 , realPathID (path.GetBasePath().GetIndex())
\r
79 , firstCopyTarget(NULL)
\r
83 , revision (revision)
\r
84 , classification (classification)
\r
86 InsertAt (source, copyTargetFactory);
\r
89 CFullGraphNode::~CFullGraphNode()
\r
91 assert (next == NULL);
\r
92 assert (firstCopyTarget == NULL);
\r
95 void CFullGraphNode::InsertAt ( CFullGraphNode* source
\r
96 , CCopyTarget::factory& copyTargetFactory)
\r
99 if (classification.Is (CNodeClassification::IS_COPY_TARGET))
\r
101 copySource = source;
\r
103 copyTargetFactory.insert (this, source->firstCopyTarget);
\r
108 source->next = this;
\r
113 void CFullGraphNode::DestroySubNodes
\r
114 ( CFactory& factory
\r
115 , CCopyTarget::factory& copyTargetFactory)
\r
117 while (next != NULL)
\r
119 CFullGraphNode* toDestroy = next;
\r
120 next = toDestroy->next;
\r
121 toDestroy->next = NULL;
\r
123 factory.Destroy (toDestroy);
\r
126 while (firstCopyTarget)
\r
128 factory.Destroy (copyTargetFactory.remove (firstCopyTarget));
\r