Ubuntu TV Media Scanner
A centralized index for removable media content.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | List of all members
mediascanner::Property Class Reference

Definition of a property value. More...

#include <mediascanner/property.h>

+ Inheritance diagram for mediascanner::Property:

Classes

class  Category
 
class  MetadataKey
 
class  Private
 
class  Value
 Container class for all supported property values. More...
 

Public Types

enum  Boundary { Inclusive, Exclusive }
 Boundaries of a range query. More...
 
enum  MergeStrategy { MergeAppend, MergeReplace, MergePreserve }
 How to resolve merge conflicts for this property. More...
 
typedef boost::variant
< boost::blank, bool, int32_t,
uint64_t, double, Fraction,
DateTime, String
ValueBase
 
typedef std::pair< Property,
Property::Value
BoundValue
 A property value bound to an actual property. More...
 
typedef std::map< Property, ValueValueMap
 Maps properties to their actual values. More...
 
typedef std::set< PropertySet
 A set of distinct properties. More...
 
typedef std::function< bool(const
Property &property)> 
PropertyVisitor
 Functions of this kind are passed to the VisitAll() method. More...
 
typedef std::function< bool(GstDiscovererInfo
*info, GstDiscovererStreamInfo
*stream, ValueMap *item)> 
StreamInfoFunction
 Functions of this kind are merge the discoverer's stream information. More...
 

Public Member Functions

 Property ()
 Constructs an unidentified property. More...
 
 Property (const Property &other)
 Constructs a copy of the other property. More...
 
 ~Property ()
 
String field_name () const
 Name of the Lucene++ field. More...
 
const MetadataKeymetadata_key () const
 Id of the Grilo metadata key. More...
 
Category category () const
 Category of the property. More...
 
std::set< std::string > origins () const
 Origins of this property. More...
 
bool is_null () const
 Checks if the property is undefined (null). More...
 
bool supports_full_text_search () const
 Checks if the property permits full text searches. More...
 
MergeStrategy merge_strategy () const
 How to resolve merge conflicts for this property. More...
 
bool MergeStreamInfo (GstDiscovererInfo *media, GstDiscovererStreamInfo *stream, ValueMap *properties) const
 Extracts property values from discoverer stream information. More...
 
LuceneFields MakeFields (const Value &value) const
 Turns a property value into Lucene++ fields. More...
 
Value TransformFields (const LuceneFields &fields) const
 Extracts property values of the Lucene++ fields. More...
 
Value TransformSingleField (Lucene::FieldablePtr field) const
 
Lucene::QueryPtr MakeTermQuery (const Value &value) const
 Constructs a Lucene term query for this property and value. More...
 
Lucene::QueryPtr MakeRangeQuery (const Value &lower_value, Boundary lower_boundary, const Value &upper_value, Boundary upper_boundary) const
 Constructs a Lucene term query for this property and value. More...
 
Lucene::QueryPtr MakeRangeQuery (const Value &lower_value, const Value &upper_value)
 Constructs a Lucene term query for this property and value. More...
 
template<typename T >
bool TransformTagValue (const GValue *input, Value *output) const
 Converts a tag value into a canonical property value. More...
 
bool TransformGriloValue (const GValue *input, Value *output) const
 Converts a tag value into a canonical property value. More...
 
bool TransformDBusVariant (GVariant *input, Value *output) const
 
GValueMakeGriloValue (const Value &value) const
 Turns a property value into a Grilo value. More...
 
bool operator== (const Property &other) const
 Checks if two properties are the same. More...
 
bool operator!= (const Property &other) const
 Checks if two properties are the different. More...
 
 operator const void * () const
 Safe boolean cast. The more natural operator bool() is problematic because it leads to unwanted implicit casts. More...
 
bool operator< (const Property &other) const
 Define sort order for usage in std::map. More...
 

Static Public Member Functions

static Property FromFieldName (const String &name)
 Finds a property by its Lucene++ field name. More...
 
static Property FromMetadataKey (GrlKeyID key)
 Finds a property by its Grilo metadata key. More...
 
static void VisitAll (const PropertyVisitor &visit)
 Visits all property declarations known to the media scanner. More...
 

Protected Types

typedef std::shared_ptr< PrivatePrivatePtr
 Shared pointer to internal property fields. More...
 

Protected Member Functions

 Property (PrivatePtr impl)
 Constructs a new property instance. More...
 
StreamInfoFunction bind_any (const StreamInfoFunction &first, const StreamInfoFunction &second) const
 
template<typename ValueType >
bool MergeAttribute (GstDiscovererInfo *media, GstDiscovererStreamInfo *stream, ValueType(*get_attribute)(const GstDiscovererInfo *), ValueMap *item) const
 
template<typename ValueType , typename InfoType >
bool MergeAttribute (GstDiscovererInfo *media, GstDiscovererStreamInfo *stream, ValueType(*get_attribute)(const InfoType *), ValueMap *item) const
 
template<typename ValueType >
bool MergeTag (GstDiscovererInfo *media, GstDiscovererStreamInfo *stream, const char *tag_name, ValueMap *item) const
 
template<typename ValueType >
StreamInfoFunction bind_attr (ValueType(*)(const GstDiscovererInfo *))
 
template<typename ValueType , typename InfoType >
StreamInfoFunction bind_attr (ValueType(*)(const InfoType *))
 
template<typename ValueType >
StreamInfoFunction bind_tag (const char *tag_name) const
 

Static Protected Member Functions

static MetadataKey define_boolean (const char *name, const char *nick, const char *blurb, bool default_value)
 
static MetadataKey define_datetime (const char *name, const char *nick, const char *blurb)
 
static MetadataKey define_string (const char *name, const char *nick, const char *blurb, const char *default_value=0)
 
static bool merge_nothing (const GstDiscovererInfo *, const GstDiscovererStreamInfo *, ValueMap *)
 
static bool MergeAny (GstDiscovererInfo *media, GstDiscovererStreamInfo *stream, const StreamInfoFunction &merge_first, const StreamInfoFunction &merge_second, ValueMap *item)
 

Detailed Description

Definition of a property value.

This class provides all the information to descibe data mappings between all the involved subsystems such as Lucene++, Grilo and GStreamer. It also provides facilities to convert property values among those systems.

Properties cannot be instantiated directly. Instead refer the constants declared in the mediascanner::schema namespace.

Member Typedef Documentation

A property value bound to an actual property.

Shared pointer to internal property fields.

typedef std::function<bool(const Property &property)> mediascanner::Property::PropertyVisitor

Functions of this kind are passed to the VisitAll() method.

A set of distinct properties.

Functions of this kind are merge the discoverer's stream information.

typedef boost::variant<boost::blank, bool, int32_t, uint64_t, double, Fraction, DateTime, String> mediascanner::Property::ValueBase

Maps properties to their actual values.

Member Enumeration Documentation

Boundaries of a range query.

Enumerator
Inclusive 
Exclusive 

How to resolve merge conflicts for this property.

Enumerator
MergeAppend 
MergeReplace 
MergePreserve 

Constructor & Destructor Documentation

mediascanner::Property::Property ( )
inline

Constructs an unidentified property.

Such properties are needed to support uninitialized variables and to support various container operations.

mediascanner::Property::Property ( const Property other)
inline

Constructs a copy of the other property.

Parameters
[in]other- the copied property
mediascanner::Property::~Property ( )
mediascanner::Property::Property ( PrivatePtr  impl)
explicitprotected

Constructs a new property instance.

This constructor is used create specializations of the Property class.

Parameters
[in]impl- the private fields of the new property

Member Function Documentation

StreamInfoFunction mediascanner::Property::bind_any ( const StreamInfoFunction first,
const StreamInfoFunction second 
) const
protected
template<typename ValueType >
StreamInfoFunction mediascanner::Property::bind_attr ( ValueType(*)(const GstDiscovererInfo *)  )
protected
template<typename ValueType , typename InfoType >
StreamInfoFunction mediascanner::Property::bind_attr ( ValueType(*)(const InfoType *)  )
protected
template<typename ValueType >
StreamInfoFunction mediascanner::Property::bind_tag ( const char *  tag_name) const
protected
Category mediascanner::Property::category ( ) const

Category of the property.

static MetadataKey mediascanner::Property::define_boolean ( const char *  name,
const char *  nick,
const char *  blurb,
bool  default_value 
)
staticprotected
static MetadataKey mediascanner::Property::define_datetime ( const char *  name,
const char *  nick,
const char *  blurb 
)
staticprotected
static MetadataKey mediascanner::Property::define_string ( const char *  name,
const char *  nick,
const char *  blurb,
const char *  default_value = 0 
)
staticprotected
String mediascanner::Property::field_name ( ) const

Name of the Lucene++ field.

static Property mediascanner::Property::FromFieldName ( const String name)
static

Finds a property by its Lucene++ field name.

Parameters
[in]name- the field name by which to search
static Property mediascanner::Property::FromMetadataKey ( GrlKeyID  key)
static

Finds a property by its Grilo metadata key.

Parameters
[in]key- the metadata key ID to search for.
bool mediascanner::Property::is_null ( ) const
inline

Checks if the property is undefined (null).

LuceneFields mediascanner::Property::MakeFields ( const Value value) const

Turns a property value into Lucene++ fields.

Parameters
[in]value- the property values to convert
GValue* mediascanner::Property::MakeGriloValue ( const Value value) const

Turns a property value into a Grilo value.

Parameters
[in]value- the property values to convert
Lucene::QueryPtr mediascanner::Property::MakeRangeQuery ( const Value lower_value,
Boundary  lower_boundary,
const Value upper_value,
Boundary  upper_boundary 
) const

Constructs a Lucene term query for this property and value.

Parameters
[in]lower_value- the lower value to search for
[in]lower_boundary- boundery to use for lower_value
[in]upper_value- the upper value to search for
[in]upper_boundary- boundery to use for upper_value
Lucene::QueryPtr mediascanner::Property::MakeRangeQuery ( const Value lower_value,
const Value upper_value 
)
inline

Constructs a Lucene term query for this property and value.

The constructed query searchs for lower_value <= x < upper_value.

Parameters
[in]lower_value- the lower value to search for
[in]upper_value- the upper value to search for
Lucene::QueryPtr mediascanner::Property::MakeTermQuery ( const Value value) const

Constructs a Lucene term query for this property and value.

Parameters
[in]value- the value to search for
static bool mediascanner::Property::merge_nothing ( const GstDiscovererInfo ,
const GstDiscovererStreamInfo ,
ValueMap  
)
inlinestaticprotected
MergeStrategy mediascanner::Property::merge_strategy ( ) const

How to resolve merge conflicts for this property.

static bool mediascanner::Property::MergeAny ( GstDiscovererInfo media,
GstDiscovererStreamInfo stream,
const StreamInfoFunction merge_first,
const StreamInfoFunction merge_second,
ValueMap item 
)
staticprotected
template<typename ValueType >
bool mediascanner::Property::MergeAttribute ( GstDiscovererInfo media,
GstDiscovererStreamInfo stream,
ValueType(*)(const GstDiscovererInfo *)  get_attribute,
ValueMap item 
) const
protected
template<typename ValueType , typename InfoType >
bool mediascanner::Property::MergeAttribute ( GstDiscovererInfo media,
GstDiscovererStreamInfo stream,
ValueType(*)(const InfoType *)  get_attribute,
ValueMap item 
) const
protected
bool mediascanner::Property::MergeStreamInfo ( GstDiscovererInfo media,
GstDiscovererStreamInfo stream,
ValueMap properties 
) const

Extracts property values from discoverer stream information.

Parameters
[in]info- the discoverer info to investigate
[in]stream- the stream info to investigate
[in,out]properties- the item to update
Returns
true if the property value got updated
template<typename ValueType >
bool mediascanner::Property::MergeTag ( GstDiscovererInfo media,
GstDiscovererStreamInfo stream,
const char *  tag_name,
ValueMap item 
) const
protected
const MetadataKey& mediascanner::Property::metadata_key ( ) const

Id of the Grilo metadata key.

mediascanner::Property::operator const void * ( ) const
inline

Safe boolean cast. The more natural operator bool() is problematic because it leads to unwanted implicit casts.

bool mediascanner::Property::operator!= ( const Property other) const
inline

Checks if two properties are the different.

bool mediascanner::Property::operator< ( const Property other) const
inline

Define sort order for usage in std::map.

bool mediascanner::Property::operator== ( const Property other) const
inline

Checks if two properties are the same.

std::set<std::string> mediascanner::Property::origins ( ) const

Origins of this property.

bool mediascanner::Property::supports_full_text_search ( ) const

Checks if the property permits full text searches.

bool mediascanner::Property::TransformDBusVariant ( GVariant input,
Value output 
) const
Value mediascanner::Property::TransformFields ( const LuceneFields &  fields) const

Extracts property values of the Lucene++ fields.

Parameters
[in]fields- the Lucene++ fields to convert
bool mediascanner::Property::TransformGriloValue ( const GValue input,
Value output 
) const

Converts a tag value into a canonical property value.

Parameters
[in]input- the tag value to transform
in/out]output - location for the transformed value
Returns
true on succcess
Value mediascanner::Property::TransformSingleField ( Lucene::FieldablePtr  field) const
template<typename T >
bool mediascanner::Property::TransformTagValue ( const GValue input,
Value output 
) const

Converts a tag value into a canonical property value.

Parameters
[in]input- the tag value to transform
in/out]output - location for the transformed value
Returns
true on succcess
static void mediascanner::Property::VisitAll ( const PropertyVisitor visit)
static

Visits all property declarations known to the media scanner.

Parameters
[in]visit- a function that is called for each property