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 base classes
\r
23 #include "RevisionGraphOptions.h"
\r
24 #include "RevisionGraphOptionsImpl.h"
\r
27 * Extends the base interface with a method that has full
\r
28 * modifying access to a given visible graph.
\r
31 class IModificationOption : public IOrderedTraversalOption
\r
35 /// If true, the option shall be applied with all other
\r
36 /// clyclic options more than once until the graph is stable.
\r
38 virtual bool IsCyclic() const = 0;
\r
40 /// Apply / execute the filter.
\r
42 virtual void Apply (CVisibleGraph* graph, CVisibleGraphNode* node) = 0;
\r
44 /// will be called after each tree traversal.
\r
45 /// Use this to modify the tree is a way that interfers
\r
46 /// with the standard traveral, for instance.
\r
48 virtual void PostFilter (CVisibleGraph* graph) = 0;
\r
52 * Standard implementation of IModificationOption.
\r
55 template<class Base, int Prio, UINT ID, bool CopyiesFirst, bool RootFirst, bool Cyclic>
\r
56 class CModificationOptionImpl
\r
57 : public COrderedTraversalOptionImpl<Base, Prio, ID, CopyiesFirst, RootFirst>
\r
61 /// for simplied construction by the _derived_ class
\r
63 typedef typename CModificationOptionImpl< Base
\r
68 , Cyclic> inherited;
\r
72 /// construction / destruction
\r
74 CModificationOptionImpl (CRevisionGraphOptionList& list)
\r
75 : COrderedTraversalOptionImpl<Base, Prio, ID, CopyiesFirst, RootFirst>(list)
\r
79 /// implement IModificationOption
\r
81 virtual bool IsCyclic() const {return Cyclic;}
\r
82 virtual void PostFilter (CVisibleGraph*) {};
\r
86 * Filtered sub-set of \ref CAllRevisionGraphOptions.
\r
87 * It applies all options in the order defined by their \ref priority.
\r
88 * The option instances may transform the graph any way they consider fit.
\r
90 * Contains only \ref IModificationOption instances.
\r
93 class CModificationOptions : public CRevisionGraphOptionList
\r
97 std::vector<IModificationOption*> options;
\r
99 /// apply a filter using differnt traversal orders
\r
101 void TraverseFromRootCopiesFirst ( IModificationOption* option
\r
102 , CVisibleGraph* graph
\r
103 , CVisibleGraphNode* node);
\r
104 void TraverseToRootCopiesFirst ( IModificationOption* option
\r
105 , CVisibleGraph* graph
\r
106 , CVisibleGraphNode* node);
\r
107 void TraverseFromRootCopiesLast ( IModificationOption* option
\r
108 , CVisibleGraph* graph
\r
109 , CVisibleGraphNode* node);
\r
110 void TraverseToRootCopiesLast ( IModificationOption* option
\r
111 , CVisibleGraph* graph
\r
112 , CVisibleGraphNode* node);
\r
113 void InternalApply (CVisibleGraph* graph, bool cyclicFilters);
\r
117 /// construction / destruction
\r
119 CModificationOptions (const std::vector<IModificationOption*>& options);
\r
120 virtual ~CModificationOptions() {}
\r
122 /// apply all filters
\r
124 void Apply (CVisibleGraph* graph);
\r