4 * @brief Declarations of CDiffContext and diff structures
6 // ID line follows -- this is updated by SVN
7 // $Id: DiffContext.h 6910 2009-07-12 09:06:54Z kimmov $
9 #if !defined(AFX_DIFFCONTEXT_H__D3CC86BE_F11E_11D2_826C_00A024706EDC__INCLUDED_)
10 #define AFX_DIFFCONTEXT_H__D3CC86BE_F11E_11D2_826C_00A024706EDC__INCLUDED_
13 #include <boost/scoped_ptr.hpp>
14 #include "PathContext.h"
15 #include "DiffFileInfo.h"
16 #include "DiffItemList.h"
29 /** Interface to a provider of plugin info */
33 virtual void FetchPluginInfos(LPCTSTR filteredFilenames,
34 PackingInfo ** infoUnpacker,
35 PrediffingInfo ** infoPrediffer) = 0;
39 * The folder compare context.
40 * This class holds data of the current folder compare. There are paths
41 * to compare, filters used, compare options etc. And compare results list
42 * is also contained in this class. Many compare classes and functions have
43 * a pointer to instance of this class.
45 * @note If you add new member variables, remember to copy values in
46 * CDiffContext::CDiffContext(..,CDiffContext) constructor!
48 class CDiffContext : public DiffItemList
51 /** @brief Special values for difference counts. */
54 DIFFS_UNKNOWN = -1, /**< Difference count unknown (generally). */
55 DIFFS_UNKNOWN_QUICKCOMPARE = -9, /**< Unknown because of quick-compare method. */
58 CDiffContext(const PathContext & paths, int compareMethod);
61 void UpdateVersion(DIFFITEM & di, BOOL bLeft) const;
64 * Get the main compare method used in this compare.
65 * @return Compare method used.
67 int GetCompareMethod(void) const { return m_nCompMethod; }
71 * @name Path accessor functions.
73 * These functions return left/right path associated to DiffContext.
74 * There is no setter fuctions and path can be set only via constructor.
75 * Normalized paths are preferred to use - short paths are expanded
76 * and trailing slashes removed (except from root path).
79 * Get left-side compare path.
80 * @return full path in left-side.
82 String GetLeftPath() const { return m_paths.GetLeft(FALSE); }
83 String GetMiddlePath() const { return m_paths.GetMiddle(FALSE); }
85 * Get right-side compare path.
86 * @return full path in right-side.
88 String GetRightPath() const { return m_paths.GetRight(FALSE); }
89 String GetPath(int nIndex) const { return m_paths.GetPath(nIndex, FALSE); }
91 * Get left-side compare path in normalized form.
92 * @return full path in left-side.
94 String GetNormalizedLeft() const { return m_paths.GetLeft(); }
95 String GetNormalizedMiddle() const { return m_paths.GetMiddle(); }
97 * Get right-side compare path in normalized form.
98 * @return full path in left-side.
100 String GetNormalizedRight() const { return m_paths.GetRight(); }
101 String GetNormalizedPath(int nIndex) const { return m_paths.GetPath(nIndex, TRUE); }
102 PathContext GetNormalizedPaths() const
105 for (int nIndex = 0; nIndex < m_paths.GetSize(); nIndex++)
106 paths.SetPath(nIndex, m_paths.GetPath(nIndex, TRUE).c_str());
111 // change an existing difference
112 BOOL UpdateInfoFromDiskHalf(DIFFITEM & di, int nIndex);
113 void UpdateStatusFromDisk(UINT_PTR diffpos, BOOL bLeft, BOOL bRight);
114 void UpdateStatusFromDisk(POSITION diffpos, BOOL bLeft, BOOL bMiddle, BOOL bRight);
116 BOOL CreateCompareOptions(int compareMethod, const DIFFOPTIONS & options);
117 CompareOptions * GetCompareOptions(int compareMethod);
119 // retrieve or manufacture plugin info for specified file comparison
120 void FetchPluginInfos(LPCTSTR filteredFilenames,
121 PackingInfo ** infoUnpacker, PrediffingInfo ** infoPrediffer);
125 * @name Compare aborting interface.
126 * These functions handle compare aborting using IAbortable interface.
128 bool ShouldAbort() const;
131 * Set pointer to IAbortable interface.
132 * This function sets pointer to interface used to abort the compare when
134 * @param [in] piAbortable Pointer to interface.
136 void SetAbortable(IAbortable * piAbortable) { m_piAbortable = piAbortable; }
139 * Returns a pointer to current IAbortable interface.
140 * This function returns a pointer to interface used to abort the compare.
141 * @return Pointer to current IAbortable interface.
143 const IAbortable * GetAbortable() const { return m_piAbortable; }
146 int GetCompareDirs() const { return m_paths.GetSize(); }
148 IDiffFilter * m_piFilterGlobal; /**< Interface for file filtering. */
149 IPluginInfos * m_piPluginInfos;
150 int m_iGuessEncodingType;
153 * The current and effective compare method.
154 * During the compare we may change compare method per file. This may
155 * happen for various reasons. But the change is always temporarily and
156 * we must return to the main method indicated by m_nCompMethod.
158 int m_nCurrentCompMethod;
160 BOOL m_bIgnoreSmallTimeDiff; /**< Ignore small timedifferences when comparing by date */
161 CompareStats *m_pCompareStats; /**< Pointer to compare statistics */
164 * Optimize compare by stopping after first difference.
165 * In some compare methods (currently quick compare) we can stop the
166 * compare right after finding the first difference. This speeds up the
167 * compare, but also causes compare statistics to be inaccurate.
169 bool m_bStopAfterFirstDiff;
172 * Threshold size for switching to quick compare.
173 * When diffutils compare is selected, files bigger (in bytes) than this
174 * value are compared using Quick compare. This is because diffutils simply
175 * cannot compare large files. And large files are usually binary files.
177 int m_nQuickCompareLimit;
180 * Walk into unique folders and add contents.
181 * This enables/disables walking into unique folders. If we don't walk into
182 * unique folders, they are shown as such in folder compare results. If we
183 * walk into unique folders, we'll show all files in the unique folder and
184 * in possible subfolders.
186 * This value is true by default.
190 bool m_bRecursive; /**< Do we include subfolders to compare? */
191 bool m_bPluginsEnabled; /**< Are plugins enabled? */
192 boost::scoped_ptr<FilterList> m_pFilterList; /**< Filter list for line filters */
193 BOOL m_bScanUnpairedDir; /** Scan into unpaired directories **/
194 CDiffWrapper *m_pDiffWrapper;
198 * The main compare method used.
199 * This is the main compare method set when compare is started. There
200 * can be temporary switches to other method (e.g. for large file) but
201 * this main method must be set back for next file.
205 boost::scoped_ptr<DIFFOPTIONS> m_pOptions; /**< Generalized compare options. */
206 boost::scoped_ptr<CompareOptions> m_pCompareOptions; /**< Per compare method compare options. */
207 PathContext m_paths; /**< (root) paths for this context */
208 IAbortable *m_piAbortable; /**< Interface for aborting the compare. */
211 #endif // !defined(AFX_DIFFCONTEXT_H__D3CC86BE_F11E_11D2_826C_00A024706EDC__INCLUDED_)