diff options
Diffstat (limited to 'library/softFilter.h')
-rw-r--r-- | library/softFilter.h | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/library/softFilter.h b/library/softFilter.h new file mode 100644 index 00000000..e4735e38 --- /dev/null +++ b/library/softFilter.h @@ -0,0 +1,79 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) 2008-2010 ZenJu (zhnmju123 AT gmx.de) * +// ************************************************************************** +// +#ifndef SOFTFILTER_H_INCLUDED +#define SOFTFILTER_H_INCLUDED + +#include "../fileHierarchy.h" +#include <wx/timer.h> +/* +Semantics of SoftFilter: +1. It potentially can match only one side => it MUST NOT be applied while traversing a single folder to avoid mismatches +2. => it is applied after traversing and just marks rows, (NO deletions after comparison are allowed) +3. => not relevant for <Automatic>-mode! ;) + +-> SoftFilter is equivalent to a user temporarily (de-)selecting rows +*/ + +namespace FreeFileSync +{ + +class SoftFilter +{ +public: + SoftFilter(size_t timeWindow) : + timeWindow_(timeWindow), + currentTime(wxGetUTCTime()) {} + + bool passFilter(const FileMapping& fileMap) const; + bool passFilter(const DirMapping& dirMap) const; + +private: + const size_t timeWindow_; //point in time from "now" (in seconds) for oldest modification date to be allowed + const long currentTime; //number of seconds since GMT 00:00:00 Jan 1st 1970. +}; + + + + + + + + + + + + + + + + + + + + + + + +//---------------Inline Implementation--------------------------------------------------- +inline +bool SoftFilter::passFilter(const FileMapping& fileMap) const +{ + return (!fileMap.isEmpty<LEFT_SIDE>() && + currentTime <= fileMap.getLastWriteTime<LEFT_SIDE>() + timeWindow_) || + (!fileMap.isEmpty<RIGHT_SIDE>() && + currentTime <= fileMap.getLastWriteTime<RIGHT_SIDE>() + timeWindow_); +} + + +inline +bool SoftFilter::passFilter(const DirMapping& dirMap) const +{ + return false; +} +} + +#endif // SOFTFILTER_H_INCLUDED |