Public Types | |
| enum | Direction { DIR_BOTH, DIR_FORWARD, DIR_BACKWARD } |
| typedef std::vector< std::string > | Attributes |
| A vector of strings (attributes). | |
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. | |
| virtual | ~Relation () |
| Destructor. | |
| std::string | getType () const |
| Returns this relation's type. | |
| void | setType (const std::string &type) |
| Sets this relation's type. | |
| std::string | getTargetId () const |
| Returns the target's ID. | |
| void | setTargetId (const std::string &targetId) |
| Sets the target's ID. | |
| std::string | getTargetType () const |
| Returns the target's type. | |
| void | setTargetType (const std::string &targetType) |
| Sets the target's type. | |
| std::string | getBeginDate () const |
| Returns the begin date. | |
| void | setBeginDate (const std::string &dateStr) |
| Sets the begin date. | |
| std::string | getEndDate () const |
| Returns the end date. | |
| void | setEndDate (const std::string &dateStr) |
| Sets the end date. | |
| Direction | getDirection () const |
| Returns the reading direction. | |
| void | setDirection (const Direction direction) |
| Sets the reading direction. | |
| Attributes & | getAttributes () |
| Returns a list of attributes describing this relation. | |
| int | getNumAttributes () const |
| Returns number of attributes. | |
| std::string | getAttribute (int index) const |
| Returns an attribute specified by index. | |
| void | addAttribute (const std::string &attribute) |
| Adds an attribute to the list. | |
| Entity * | getTarget () const |
| Returns this relation's target object. | |
| void | setTarget (Entity *target) |
| Sets this relation's target object. | |
Static Public Attributes | |
| static const std::string | TO_ARTIST |
| Identifies relations linking to an artist. | |
| static const std::string | TO_RELEASE |
| Identifies relations linking to a release. | |
| static const std::string | TO_TRACK |
| Identifies relations linking to a track. | |
| static const std::string | TO_URL |
| Identifies relations linking to an URL. | |
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 MusicBrainz::Relation::~Relation | ( | ) | [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 |
const std::string MusicBrainz::Relation::TO_ARTIST [static] |
Identifies relations linking to an artist.
const std::string MusicBrainz::Relation::TO_RELEASE [static] |
Identifies relations linking to a release.
const std::string MusicBrainz::Relation::TO_TRACK [static] |
Identifies relations linking to a track.
const std::string MusicBrainz::Relation::TO_URL [static] |
Identifies relations linking to an URL.
1.5.8