Public Member Functions | |
virtual | ~Entity () |
Destructor. | |
virtual std::string | getId () const |
Returns a MusicBrainz ID. | |
virtual void | setId (const std::string &value) |
Sets a MusicBrainz ID. | |
RelationList | getRelations (const std::string &targetType=std::string(), const std::string &relationType=std::string()) const |
Returns a list of relations. | |
void | addRelation (Relation *relation) |
Adds a relation. | |
int | getNumRelations () const |
Returns number of relations. | |
Relation * | getRelation (int index) |
Returns an relation specified by index. | |
TagList & | getTags () |
int | getNumTags () const |
Tag * | getTag (int index) |
Protected Member Functions | |
Entity (const std::string &id) | |
Constructor. |
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:
MusicBrainz::Entity::Entity | ( | const std::string & | id | ) | [protected] |
Constructor.
This should only used by derived classes.
id | a string containing an absolute URI |
virtual MusicBrainz::Entity::~Entity | ( | ) | [virtual] |
Destructor.
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.
relation | a pointer to Relation object to add |
virtual std::string MusicBrainz::Entity::getId | ( | ) | const [virtual] |
int MusicBrainz::Entity::getNumRelations | ( | ) | const |
Returns number of relations.
This is equivalent to getRelations()
.size()
int MusicBrainz::Entity::getNumTags | ( | ) | const |
Relation* MusicBrainz::Entity::getRelation | ( | int | index | ) |
Returns an relation specified by index.
This is equivalent to getRelations()
[index]
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.
targetType | a string containing an absolute URI | |
relationType | a string containing an absolute URI |
Tag* MusicBrainz::Entity::getTag | ( | int | index | ) |
TagList& MusicBrainz::Entity::getTags | ( | ) |
virtual void MusicBrainz::Entity::setId | ( | const std::string & | value | ) | [virtual] |