[TagLib 2.0] Tag property interface.

Vitali Lovich vlovich at gmail.com
Wed Jul 16 05:35:09 CEST 2008


Here's my suggestion: Why not make it a class?

enum PropertyType
{
    Title, Genre, ....
}

Property -> TitleProperty, GenreProperty, ArtistProperty, 
TrackNumberProperty, etc.

Property is templated.

/*
 * Adds the desired value.  This is non-pure virtual and returns false 
in the base class.
 *
 * Subclasses return true if they've added the value to the list (or 
false if they don't
 * support a list of types and there's already a value set).
 * Partial specialization only supports the types that are allowed (this 
way, a child class
 * can also support multiple different value types, if that becomes an 
issue in the future).
 */
bool Property<T>::add(T value)

/*
 * Remove a specific value from the property.  Returns whether or not 
the value was found
 * Pure-virtual
 */
template <class T>
bool Property::remove(T value);

/*
 * Unsets all values associated with this property
 * Pure virtual
 */
template <class T>
void Property<T>::removeAll();

/*
 * Pure virtual - Returns as a list, all the values associated with this 
property
 */
template <class T>
list<T> Property<T>::getValues()

/*
 * Pure virtual - returns if multiple values can be associated.
 * This has nothing to do whether or not the type is supported.
 */
template <class T>
list<T> Property<T>::supportsMultipleValues()

/*
 * Non-pure virtual.  Returns whether or not the value type is supported 
by the property.
 * Partial-specilization in child-classes to limit the types supported.  
Base class returns false.
 */
template <class T>
bool Property<T>::supports();

/*
 * bool supports(PropertyType)
 * 
 * returns whether the Tag object has support for that property-value mapping
 */
bool supports(PropertyType)


/*
 * list<PropertyType> available()
 *
 * return a list of all existing values on the Tag
 */
list<PropertyType> available()

/*
 * set(Property, String)
 *
 * set the desired property to the provided value.
 * returns bool indicating success
 */
bool set(Property<T> p);

The one thing I haven't figured out is how the set property would actually work.  I imagine that perhaps there might be a private callback in Property (Tag would have to be friended in this case, or perhaps it's not a private callback - available to everyone) with some kind of buffer or data stream where it is expected to serialize itself.

Thoughts?

>
> Of course, this interface has two immediately obvious deficiencies. It does not have support for multiple values. Second, it only provides support for String values on the base Tag. Are these problems that should be fixed, and if so, how would you suggest changing the interface?
>
> -pvh
> _______________________________________________
> taglib-devel mailing list
> taglib-devel at kde.org
> https://mail.kde.org/mailman/listinfo/taglib-devel
>   



More information about the taglib-devel mailing list