Ubuntu TV Media Scanner
A centralized index for removable media content.
|
A read-only instance of the media index. More...
#include <mediascanner/mediaindex.h>
Public Types | |
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... | |
Public Member Functions | |
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 | Open (const FileSystemPath &path) |
Opens the media index at path . More... | |
virtual void | Close () |
Closes 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) |
Static Public Member Functions | |
static FileSystemPath | default_path () |
The default that is used when path() is empty. More... | |
Static Public Attributes | |
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 [] |
Protected Member Functions | |
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) |
virtual bool | ReadParams () |
virtual bool | FlushParams (Wrapper< GKeyFile > params) |
bool | FlushParams () |
virtual Lucene::IndexReaderPtr | OpenIndex () |
virtual Lucene::IndexReaderPtr | OpenChildIndex (const MediaRoot &root) |
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 |
Static Protected Member Functions | |
static Lucene::TermPtr | MakeLookupTerm (const std::wstring &url) |
static Property::Set | GetFields (Lucene::DocumentPtr document) |
Static Protected Attributes | |
static const ParamId | kParamFormat |
static const ParamId | kParamSegments |
static const ParamId | kParamVolumeUUID |
static const ParamId | kParamRelativePath |
A read-only instance of the media index.
Use set_refresh_policy() to control when changes are read from the disk.
typedef std::function<void(const MediaInfo &metadata, int32_t remaining_items)> mediascanner::MediaIndex::ItemVistor |
Signature of the visitor function passed to methods like Query(), or VisitAll().
metadata | The metadata of the current item. |
remaining_items | The number of remaining items. |
|
explicit |
|
virtual |
void mediascanner::MediaIndex::AddMediaRoot | ( | const MediaRoot & | root) |
|
protected |
|
virtual |
Closes the media index.
After calling this method no other queries are permitted.
Reimplemented in mediascanner::WritableMediaIndex.
|
static |
std::string mediascanner::MediaIndex::error_message | ( | ) |
The error message of the last failed operation.
bool mediascanner::MediaIndex::Exists | ( | const std::wstring & | url) |
Checks if the media index contains information about the media referenced by url
.
url | The URL of the media to check |
true
if the index contains information about url
|
protected |
|
protected |
|
protected |
Reimplemented in mediascanner::WritableMediaIndex.
|
protected |
|
protected |
|
staticprotected |
bool mediascanner::MediaIndex::is_current | ( | ) | const |
Indicator if the index still reads current data, or if Refresh() should be called.
bool mediascanner::MediaIndex::is_open | ( | ) | const |
Predicate indicating weither the index was opened successfully.
MediaInfo mediascanner::MediaIndex::Lookup | ( | const std::wstring & | url) |
Retrieves all information stored about the referenced media.
url | The URL of the media to lookup. |
MediaInfo mediascanner::MediaIndex::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
.
url | The URL of the media to lookup. |
field_names | The fields to lookup. |
ValueType mediascanner::MediaIndex::Lookup | ( | const std::wstring & | url, |
const GenericProperty< PropertyType, ValueType > & | key | ||
) |
Looks up a single detail about the referenced media.
url | The URL of the media to lookup. |
key | The field to lookup. |
|
protected |
|
inline |
|
staticprotected |
|
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 in mediascanner::WritableMediaIndex.
|
protectedvirtual |
Reimplemented in mediascanner::WritableMediaIndex.
|
protectedvirtual |
Reimplemented in mediascanner::WritableMediaIndex.
|
protected |
FileSystemPath mediascanner::MediaIndex::path | ( | ) | const |
bool mediascanner::MediaIndex::Query | ( | const ItemVistor & | visit_item, |
const Filter & | filter, | ||
int32_t | limit = kUnlimited , |
||
int32_t | offset = 0 |
||
) |
Visits all items matching the filter
.
visit_item | The function to call for each item. |
filter | The filter to apply to all items. |
limit | The maximum number of items to return, or kUnlimited |
offset | Number of items to skip. |
@p | true on success, check error_message() on error. |
|
protectedvirtual |
Reimplemented in mediascanner::WritableMediaIndex.
RefreshPolicyPtr mediascanner::MediaIndex::refresh_policy | ( | ) | const |
The current RefreshPolicy of the media index.
void mediascanner::MediaIndex::RemoveMediaRoot | ( | const MediaRoot & | root) |
|
virtual |
Refreshs the media index if it doesn't reflect recent changes anymore.
Such a method is needed because, to optimize performance, Lucene++ doesn't automatically reload its index readers upon changes.
|
protected |
MediaRootManagerPtr mediascanner::MediaIndex::root_manager | ( | ) | const |
The MediaRootManager of the media index.
|
protected |
void mediascanner::MediaIndex::set_refresh_policy | ( | RefreshPolicyPtr | policy) |
Changes the current RefreshPolicy of the media index.
void mediascanner::MediaIndex::VisitAll | ( | const ItemVistor & | visit_item, |
int32_t | limit = kUnlimited , |
||
int32_t | offset = 0 |
||
) |
Visits all items stored in the media index.
visit_item | The function to call for each item. |
limit | The maximum number of items to return, or kUnlimited |
offset | Number of items to skip. |
|
static |
|
static |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
static |
Pass this constant as limit
argument to methods such as Query(), or VisitAll() to request all available results for those methods.