Ubuntu TV Media Scanner
A centralized index for removable media content.
|
A writable instance of the media index. More...
#include <mediascanner/writablemediaindex.h>
Public Member Functions | |
WritableMediaIndex (MediaRootManagerPtr root_manager) | |
~WritableMediaIndex () | |
void | set_commit_policy (CommitPolicyPtr policy) |
Changes the commit_policy() of this media index. More... | |
CommitPolicyPtr | commit_policy () const |
The commit policy of this media index. More... | |
void | set_write_lock_timeout (int64_t timeout) |
Changes the time to wait for a write lock in milliseconds. More... | |
int64_t | write_lock_timeout () const |
The time to wait for a write lock in milliseconds. More... | |
bool | Open (const FileSystemPath &path) |
Opens the media index at path . More... | |
void | Close () |
Closes the media index. More... | |
bool | Insert (const std::wstring &url, const MediaInfo &metadata) |
Inserts new properties for the media referenced by url . More... | |
bool | Delete (const std::wstring &url) |
Removes a media information from the index. More... | |
void | CommitPendingChanges () |
Commits all pending changes so that other readers will see the changes, and so that the updates will survive a system crash or power loss. More... | |
![]() | |
MediaIndex (MediaRootManagerPtr root_manager) | |
virtual | ~MediaIndex () |
std::string | error_message () |
The error message of the last failed operation. More... | |
FileSystemPath | path () const |
The file system path of the index, or an empty string to use. More... | |
bool | is_open () const |
Predicate indicating weither the index was opened successfully. More... | |
bool | is_current () const |
Indicator if the index still reads current data, or if Refresh() should be called. More... | |
void | set_refresh_policy (RefreshPolicyPtr policy) |
Changes the current RefreshPolicy of the media index. More... | |
RefreshPolicyPtr | refresh_policy () const |
The current RefreshPolicy of the media index. More... | |
MediaRootManagerPtr | root_manager () const |
The MediaRootManager of the media index. More... | |
virtual bool | Reopen () |
Refreshs the media index if it doesn't reflect recent changes anymore. More... | |
void | AddMediaRoot (const MediaRoot &root) |
void | RemoveMediaRoot (const MediaRoot &root) |
bool | Exists (const std::wstring &url) |
Checks if the media index contains information about the media referenced by url . More... | |
MediaInfo | Lookup (const std::wstring &url) |
Retrieves all information stored about the referenced media. More... | |
MediaInfo | Lookup (const std::wstring &url, const Property::Set &fields) |
Retrieves the information stored in the index for the media referenced by url , as requested in field_names . More... | |
template<typename PropertyType , typename ValueType > | |
ValueType | Lookup (const std::wstring &url, const GenericProperty< PropertyType, ValueType > &key) |
Looks up a single detail about the referenced media. More... | |
void | VisitAll (const ItemVistor &visit_item, int32_t limit=kUnlimited, int32_t offset=0) |
Visits all items stored in the media index. More... | |
bool | Query (const ItemVistor &visit_item, const Filter &filter, int32_t limit=kUnlimited, int32_t offset=0) |
Visits all items matching the filter . More... | |
template<typename P , typename V > | |
V | Lookup (const std::wstring &url, const GenericProperty< P, V > &key) |
Protected Member Functions | |
bool | ReadParams () |
bool | FlushParams (Wrapper< GKeyFile > params) |
Lucene::IndexReaderPtr | OpenIndex () |
Lucene::IndexReaderPtr | OpenChildIndex (const MediaRoot &root) |
Lucene::IndexWriterPtr | find_index_writer (const std::wstring &url) |
![]() | |
Lucene::AnalyzerPtr | analyzer () const |
void | report_error (const boost::locale::format &error_message) |
Lucene::DocumentPtr | FindDocument (const std::wstring &url) const |
MediaInfo | ExtractProperties (Lucene::DocumentPtr document) |
MediaInfo | ExtractProperties (Lucene::DocumentPtr document, const Property::Set &fields) |
bool | Lookup (const std::wstring &url, const Property &key, Property::Value *value) |
bool | FlushParams () |
std::string | get_param (const std::string &group, const ParamId &key) const |
void | set_param (const std::string &group, const ParamId &key, const std::string &value) |
FileSystemPath | params_path () const |
Friends | |
class | CommitPolicy |
Additional Inherited Members | |
![]() | |
typedef std::function< void(const MediaInfo &metadata, int32_t remaining_items)> | ItemVistor |
Signature of the visitor function passed to methods like Query(), or VisitAll(). More... | |
![]() | |
static FileSystemPath | default_path () |
The default that is used when path() is empty. More... | |
![]() | |
static const int32_t | kUnlimited |
Pass this constant as limit argument to methods such as Query(), or VisitAll() to request all available results for those methods. More... | |
static const char | kMediaIndexFormat [] |
static const char | kMetaIndexFormat [] |
![]() | |
static Lucene::TermPtr | MakeLookupTerm (const std::wstring &url) |
static Property::Set | GetFields (Lucene::DocumentPtr document) |
![]() | |
static const ParamId | kParamFormat |
static const ParamId | kParamSegments |
static const ParamId | kParamVolumeUUID |
static const ParamId | kParamRelativePath |
A writable instance of the media index.
Use set_commit_policy() to control when changes are written back to the disk.
|
explicit |
mediascanner::WritableMediaIndex::~WritableMediaIndex | ( | ) |
|
virtual |
Closes the media index.
After calling this method no other queries are permitted.
Reimplemented from mediascanner::MediaIndex.
CommitPolicyPtr mediascanner::WritableMediaIndex::commit_policy | ( | ) | const |
The commit policy of this media index.
void mediascanner::WritableMediaIndex::CommitPendingChanges | ( | ) |
Commits all pending changes so that other readers will see the changes, and so that the updates will survive a system crash or power loss.
This call can be very expensive, therefore we should only call it if when really necessary. It's usually more efficient to just rely on the configured commit_policy().
bool mediascanner::WritableMediaIndex::Delete | ( | const std::wstring & | url) |
Removes a media information from the index.
url | The URL of the media to remove. |
|
protected |
Reimplemented from mediascanner::MediaIndex.
bool mediascanner::WritableMediaIndex::Insert | ( | const std::wstring & | url, |
const MediaInfo & | metadata | ||
) |
Inserts new properties for the media referenced by url
.
url | The URL of the media to modify. |
metadata | The new property values to attach. |
|
virtual |
Opens the media index at path
.
This method must be called before performing any read operations.
path | The file system path of the index, or an empty string to use the default_path(). |
true
on success. Reimplemented from mediascanner::MediaIndex.
|
protectedvirtual |
Reimplemented from mediascanner::MediaIndex.
|
protectedvirtual |
Reimplemented from mediascanner::MediaIndex.
|
protectedvirtual |
Reimplemented from mediascanner::MediaIndex.
void mediascanner::WritableMediaIndex::set_commit_policy | ( | CommitPolicyPtr | policy) |
Changes the commit_policy() of this media index.
void mediascanner::WritableMediaIndex::set_write_lock_timeout | ( | int64_t | timeout) |
Changes the time to wait for a write lock in milliseconds.
int64_t mediascanner::WritableMediaIndex::write_lock_timeout | ( | ) | const |
The time to wait for a write lock in milliseconds.
|
friend |