summaryrefslogtreecommitdiff
path: root/library/softFilter.h
blob: 275aa9bd4bea5eaf7a5880447a2525fd8a3e27e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// **************************************************************************
// * 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 may 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()) {}

//    typedef boost::shared_ptr<const SoftFilter> FilterRef; //always bound by design!

    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.
};


//SoftFilter::FilterRef combineFilters(const SoftFilter& first,
//                                     const SoftFilter& second);
//
//
//
//

















//---------------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