libmusicbrainz3  3.0.2
MusicBrainz::Entity Class Reference

A first-level MusicBrainz class. More...

Inheritance diagram for MusicBrainz::Entity:

Public Member Functions

virtual ~Entity ()
 Destructor. More...
 
virtual std::string getId () const
 Returns a MusicBrainz ID. More...
 
virtual void setId (const std::string &value)
 Sets a MusicBrainz ID. More...
 
RelationList getRelations (const std::string &targetType=std::string(), const std::string &relationType=std::string()) const
 Returns a list of relations. More...
 
void addRelation (Relation *relation)
 Adds a relation. More...
 
int getNumRelations () const
 Returns number of relations. More...
 
RelationgetRelation (int index)
 Returns an relation specified by index. More...
 
TagListgetTags ()
 
int getNumTags () const
 
TaggetTag (int index)
 

Protected Member Functions

 Entity (const std::string &id)
 Constructor. More...
 

Detailed Description

A first-level MusicBrainz class.

All entities in MusicBrainz have unique IDs (which are absolute URIs) and may have any number of relations (Relation) to other entities. This class is abstract and should not be instantiated.

Relations are differentiated by their target type, that means, where they link to. MusicBrainz currently supports four target types (artists, releases, tracks, and URLs) each identified using a URI. To get all relations with a specific target type, you can use getRelations and pass one of the following constants as the parameter:

See also
Relation

Constructor & Destructor Documentation

MusicBrainz::Entity::Entity ( const std::string &  id)
protected

Constructor.

This should only used by derived classes.

Parameters
ida string containing an absolute URI
virtual MusicBrainz::Entity::~Entity ( )
virtual

Destructor.

Member Function Documentation

void MusicBrainz::Entity::addRelation ( Relation relation)

Adds a relation.

This method adds relation to the list of relations. The given relation has to be initialized, at least the target type has to be set.

Parameters
relationa pointer to Relation object to add
virtual std::string MusicBrainz::Entity::getId ( ) const
virtual

Returns a MusicBrainz ID.

Returns
a string containing a URI
int MusicBrainz::Entity::getNumRelations ( ) const

Returns number of relations.

This is equivalent to getRelations().size()

Returns
an int containing number of relations
See also
getRelations
int MusicBrainz::Entity::getNumTags ( ) const
Relation* MusicBrainz::Entity::getRelation ( int  index)

Returns an relation specified by index.

This is equivalent to getRelations()[index]

Returns
a pointer to Relation instance
See also
getRelations
RelationList MusicBrainz::Entity::getRelations ( const std::string &  targetType = std::string(),
const std::string &  relationType = std::string() 
) const

Returns a list of relations.

If targetType is given, only relations of that target type are returned. For MusicBrainz, the following target types are defined:

If targetType is Relation::TO_ARTIST, for example, this method returns all relations between this Entity and artists.

You may use the relationType parameter to further restrict the selection. If it is set, only relations with the given relation type are returned.

Parameters
targetTypea string containing an absolute URI
relationTypea string containing an absolute URI
Returns
a list of pointers to Relation objects
See also
Entity
Tag* MusicBrainz::Entity::getTag ( int  index)
TagList& MusicBrainz::Entity::getTags ( )
virtual void MusicBrainz::Entity::setId ( const std::string &  value)
virtual

Sets a MusicBrainz ID.

Parameters
valuea string containing an absolute URI