~ubuntu-branches/ubuntu/trusty/mediascanner/trusty-proposed

« back to all changes in this revision

Viewing changes to src/mediascanner/refreshpolicy.h

  • Committer: Package Import Robot
  • Author(s): Łukasz 'sil2100' Zemczak
  • Date: 2013-08-13 18:47:34 UTC
  • Revision ID: package-import@ubuntu.com-20130813184734-u3lyvu2u1hgybryc
Tags: upstream-0.3.93
Import upstream version 0.3.93

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of the Ubuntu TV Media Scanner
 
3
 * Copyright (C) 2012-2013 Canonical Ltd.
 
4
 *
 
5
 * This program is free software: you can redistribute it and/or modify
 
6
 * it under the terms of the GNU Lesser General Public License version 3 as
 
7
 * published by the Free Software Foundation.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU Lesser General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Lesser General Public License
 
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
 *
 
17
 * Contact: Jim Hodapp <jim.hodapp@canonical.com>
 
18
 * Authored by: Mathias Hasselmann <mathias@openismus.com>
 
19
 */
 
20
#ifndef MEDIASCANNER_REFRESHPOLICY_H
 
21
#define MEDIASCANNER_REFRESHPOLICY_H
 
22
 
 
23
// Media Scanner Library
 
24
#include "mediascanner/declarations.h"
 
25
 
 
26
namespace mediascanner {
 
27
 
 
28
/**
 
29
 * @brief Shared pointer holding a RefreshPolicy.
 
30
 */
 
31
typedef boost::shared_ptr<RefreshPolicy> RefreshPolicyPtr;
 
32
 
 
33
/**
 
34
 * @brief A refresh policy decides when changes to the media index must be
 
35
 * re-read. A policy is needed because, to optimize performance,
 
36
 * Lucene++ doesn't automatically refresh its index readers upon changes.
 
37
 */
 
38
class RefreshPolicy {
 
39
public:
 
40
    virtual ~RefreshPolicy();
 
41
 
 
42
    /**
 
43
     * @brief The default policy - currently an instance of InstantRefreshPolicy.
 
44
     */
 
45
    static RefreshPolicyPtr default_policy();
 
46
 
 
47
    /**
 
48
     * @brief This method is called by the MediaIndex before it starts any
 
49
     * read operation. The policy can now check if the media index needs to
 
50
     * be reopened, can can do so if needed.
 
51
     * @param index
 
52
     */
 
53
    virtual bool OnBeginReading(MediaIndex *index) = 0;
 
54
 
 
55
    /**
 
56
     * @brief This method is called by the WritableMediaIndex before it
 
57
     * starts any write operation. The policy can now check if the media index
 
58
     * needs to be reopened, can can do so if needed.
 
59
     * @param index
 
60
     */
 
61
    virtual bool OnBeginWriting(WritableMediaIndex *index) = 0;
 
62
};
 
63
 
 
64
class InstantRefreshPolicy : public RefreshPolicy {
 
65
public:
 
66
    bool OnBeginReading(MediaIndex *index);
 
67
    bool OnBeginWriting(WritableMediaIndex *index);
 
68
};
 
69
 
 
70
} // namespace mediascanner
 
71
 
 
72
#endif // MEDIASCANNER_REFRESHPOLICY_H