2
* This file is part of the Ubuntu TV Media Scanner
3
* Copyright (C) 2012-2013 Canonical Ltd.
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.
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.
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/>.
17
* Contact: Jim Hodapp <jim.hodapp@canonical.com>
18
* Authored by: Mathias Hasselmann <mathias@openismus.com>
20
#ifndef MEDIASCANNER_REFRESHPOLICY_H
21
#define MEDIASCANNER_REFRESHPOLICY_H
23
// Media Scanner Library
24
#include "mediascanner/declarations.h"
26
namespace mediascanner {
29
* @brief Shared pointer holding a RefreshPolicy.
31
typedef boost::shared_ptr<RefreshPolicy> RefreshPolicyPtr;
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.
40
virtual ~RefreshPolicy();
43
* @brief The default policy - currently an instance of InstantRefreshPolicy.
45
static RefreshPolicyPtr default_policy();
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.
53
virtual bool OnBeginReading(MediaIndex *index) = 0;
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.
61
virtual bool OnBeginWriting(WritableMediaIndex *index) = 0;
64
class InstantRefreshPolicy : public RefreshPolicy {
66
bool OnBeginReading(MediaIndex *index);
67
bool OnBeginWriting(WritableMediaIndex *index);
70
} // namespace mediascanner
72
#endif // MEDIASCANNER_REFRESHPOLICY_H