libmusicbrainz3
3.0.3
|
Represents a relation between two Entities. More...
Public Types | |
enum | Direction { DIR_BOTH, DIR_FORWARD, DIR_BACKWARD } |
typedef std::vector< std::string > | Attributes |
A vector of strings (attributes). More... | |
Public Member Functions | |
Relation (const std::string &relationType=std::string(), const std::string &targetType=std::string(), const std::string &targetId=std::string(), const Direction direction=DIR_BOTH, const Attributes &attributes=Attributes(), const std::string &beginDate=std::string(), const std::string &endDate=std::string(), Entity *target=NULL) | |
Constructor. More... | |
virtual | ~Relation () |
Destructor. More... | |
std::string | getType () const |
Returns this relation's type. More... | |
void | setType (const std::string &type) |
Sets this relation's type. More... | |
std::string | getTargetId () const |
Returns the target's ID. More... | |
void | setTargetId (const std::string &targetId) |
Sets the target's ID. More... | |
std::string | getTargetType () const |
Returns the target's type. More... | |
void | setTargetType (const std::string &targetType) |
Sets the target's type. More... | |
std::string | getBeginDate () const |
Returns the begin date. More... | |
void | setBeginDate (const std::string &dateStr) |
Sets the begin date. More... | |
std::string | getEndDate () const |
Returns the end date. More... | |
void | setEndDate (const std::string &dateStr) |
Sets the end date. More... | |
Direction | getDirection () const |
Returns the reading direction. More... | |
void | setDirection (const Direction direction) |
Sets the reading direction. More... | |
Attributes & | getAttributes () |
Returns a list of attributes describing this relation. More... | |
int | getNumAttributes () const |
Returns number of attributes. More... | |
std::string | getAttribute (int index) const |
Returns an attribute specified by index. More... | |
void | addAttribute (const std::string &attribute) |
Adds an attribute to the list. More... | |
Entity * | getTarget () const |
Returns this relation's target object. More... | |
void | setTarget (Entity *target) |
Sets this relation's target object. More... | |
Static Public Attributes | |
static const std::string | TO_ARTIST |
Identifies relations linking to an artist. More... | |
static const std::string | TO_RELEASE |
Identifies relations linking to a release. More... | |
static const std::string | TO_TRACK |
Identifies relations linking to a track. More... | |
static const std::string | TO_URL |
Identifies relations linking to an URL. More... | |
Represents a relation between two Entities.
There may be an arbitrary number of relations between all first class objects in MusicBrainz. The Relation itself has multiple attributes, which may or may not be used for a given relation type.
Note that a Relation object only contains the target but not the source end of the relation.
typedef std::vector<std::string> MusicBrainz::Relation::Attributes |
A vector of strings (attributes).
MusicBrainz::Relation::Relation | ( | const std::string & | relationType = std::string() , |
const std::string & | targetType = std::string() , |
||
const std::string & | targetId = std::string() , |
||
const Direction | direction = DIR_BOTH , |
||
const Attributes & | attributes = Attributes() , |
||
const std::string & | beginDate = std::string() , |
||
const std::string & | endDate = std::string() , |
||
Entity * | target = NULL |
||
) |
Constructor.
relationType | a string containing an absolute URI |
targetType | a string containing an absolute URI |
targetId | a string containing an absolute URI |
direction | one of Relation::DIR_FORWARD, Relation::DIR_BACKWARD, or Relation::DIR_BOTH |
attributes | a list of strings containing absolute URIs |
beginDate | a string containing a date |
endDate | a string containing a date |
target | an instance of a subclass of Entity, or NULL |
|
virtual |
Destructor.
void MusicBrainz::Relation::addAttribute | ( | const std::string & | attribute | ) |
Adds an attribute to the list.
attribute | a string containing an absolute URI |
std::string MusicBrainz::Relation::getAttribute | ( | int | index | ) | const |
Returns an attribute specified by index.
This is equivalent to getAttributes()
[index]
Attributes& MusicBrainz::Relation::getAttributes | ( | ) |
Returns a list of attributes describing this relation.
The attributes permitted depend on the relation type.
std::string MusicBrainz::Relation::getBeginDate | ( | ) | const |
Returns the begin date.
The definition depends on the relation's type. It may for example be the day of a marriage or the year an artist joined a band. For other relation types this may be undefined.
Direction MusicBrainz::Relation::getDirection | ( | ) | const |
Returns the reading direction.
The direction may be one of Relation::DIR_FORWARD, Relation::DIR_BACKWARD, or Relation::DIR_BOTH, depending on how the relation should be read. For example, if direction is Relation::DIR_FORWARD for a cover relation, it is read as "X is a cover of Y". Some relations are bidirectional, like marriages. In these cases, the direction is Relation::DIR_BOTH.
std::string MusicBrainz::Relation::getEndDate | ( | ) | const |
Returns the end date.
As with the begin date, the definition depends on the relation's type. Depending on the relation type, this may or may not be defined.
int MusicBrainz::Relation::getNumAttributes | ( | ) | const |
Returns number of attributes.
This is equivalent to getAttributes()
.size()
Entity* MusicBrainz::Relation::getTarget | ( | ) | const |
Returns this relation's target object.
Note that URL relations never have a target object. Use the getTargetId method to get the URL.
std::string MusicBrainz::Relation::getTargetId | ( | ) | const |
Returns the target's ID.
This is the ID the relation points to. It is an absolute URI, and in case of an URL relation, it is a URL.
std::string MusicBrainz::Relation::getTargetType | ( | ) | const |
Returns the target's type.
For MusicBrainz data, the following target types are defined:
std::string MusicBrainz::Relation::getType | ( | ) | const |
Returns this relation's type.
void MusicBrainz::Relation::setBeginDate | ( | const std::string & | dateStr | ) |
void MusicBrainz::Relation::setDirection | ( | const Direction | direction | ) |
Sets the reading direction.
direction | Relation::DIR_FORWARD, Relation::DIR_BACKWARD, or Relation::DIR_BOTH |
void MusicBrainz::Relation::setEndDate | ( | const std::string & | dateStr | ) |
void MusicBrainz::Relation::setTarget | ( | Entity * | target | ) |
Sets this relation's target object.
Note that URL relations never have a target object, they are set using setTargetId.
target | a subclass of Entity, or NULL |
void MusicBrainz::Relation::setTargetId | ( | const std::string & | targetId | ) |
void MusicBrainz::Relation::setTargetType | ( | const std::string & | targetType | ) |
Sets the target's type.
targetType | a string containing an absolute URI |
void MusicBrainz::Relation::setType | ( | const std::string & | type | ) |
Sets this relation's type.
type | a string containing an absolute URI |
|
static |
Identifies relations linking to an artist.
|
static |
Identifies relations linking to a release.
|
static |
Identifies relations linking to a track.
|
static |
Identifies relations linking to an URL.