OSDN Git Service

merge original branch.
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / RevisionGraph / ModificationOptions.h
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2008 - TortoiseSVN\r
4 \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
9 \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
14 \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
18 //\r
19 #pragma once\r
20 \r
21 // include base classes\r
22 \r
23 #include "RevisionGraphOptions.h"\r
24 #include "RevisionGraphOptionsImpl.h"\r
25 \r
26 /**\r
27 * Extends the base interface with a method that has full\r
28 * modifying access to a given visible graph.\r
29 */\r
30 \r
31 class IModificationOption : public IOrderedTraversalOption\r
32 {\r
33 public:\r
34 \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
37 \r
38     virtual bool IsCyclic() const = 0;\r
39 \r
40     /// Apply / execute the filter.\r
41 \r
42     virtual void Apply (CVisibleGraph* graph, CVisibleGraphNode* node) = 0;\r
43 \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
47 \r
48     virtual void PostFilter (CVisibleGraph* graph) = 0;\r
49 };\r
50 \r
51 /**\r
52  * Standard implementation of IModificationOption.\r
53  */\r
54 \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
58 {\r
59 protected:\r
60 \r
61     /// for simplied construction by the _derived_ class\r
62 \r
63     typedef typename CModificationOptionImpl< Base\r
64                                             , Prio\r
65                                             , ID\r
66                                             , CopyiesFirst\r
67                                             , RootFirst\r
68                                             , Cyclic> inherited;\r
69 \r
70 public:\r
71 \r
72     /// construction / destruction\r
73 \r
74     CModificationOptionImpl (CRevisionGraphOptionList& list)\r
75         : COrderedTraversalOptionImpl<Base, Prio, ID, CopyiesFirst, RootFirst>(list)\r
76     {\r
77     }\r
78 \r
79     /// implement IModificationOption\r
80 \r
81     virtual bool IsCyclic() const {return Cyclic;}\r
82     virtual void PostFilter (CVisibleGraph*) {};\r
83 };\r
84 \r
85 /**\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
89 *\r
90 * Contains only \ref IModificationOption instances.\r
91 */\r
92 \r
93 class CModificationOptions : public CRevisionGraphOptionList\r
94 {\r
95 private:\r
96 \r
97     std::vector<IModificationOption*> options;\r
98 \r
99     /// apply a filter using differnt traversal orders\r
100 \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
114 \r
115 public:\r
116 \r
117     /// construction / destruction\r
118 \r
119     CModificationOptions (const std::vector<IModificationOption*>& options);\r
120     virtual ~CModificationOptions() {}\r
121 \r
122     /// apply all filters \r
123 \r
124     void Apply (CVisibleGraph* graph);\r
125 };\r
126 \r