summaryrefslogtreecommitdiff
path: root/library/softFilter.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:05:53 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:05:53 +0200
commit618dfb51d93898632830f1b87443d3f748780871 (patch)
treebac520a2e261154f8d35b0cb8aa345f5ab373811 /library/softFilter.h
parent3.4 (diff)
downloadFreeFileSync-618dfb51d93898632830f1b87443d3f748780871.tar.gz
FreeFileSync-618dfb51d93898632830f1b87443d3f748780871.tar.bz2
FreeFileSync-618dfb51d93898632830f1b87443d3f748780871.zip
3.5
Diffstat (limited to 'library/softFilter.h')
-rw-r--r--library/softFilter.h79
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
bgstack15