/usr/include/musicbrainz3/relation.h is in libmusicbrainz3-dev 3.0.2-2.5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | /*
* MusicBrainz -- The Internet music metadatabase
*
* Copyright (C) 2006 Lukas Lalinsky
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* $Id: relation.h 8466 2006-09-05 08:59:44Z luks $
*/
#ifndef __MUSICBRAINZ3_RELATION_H__
#define __MUSICBRAINZ3_RELATION_H__
#include <string>
#include <vector>
#include <musicbrainz3/musicbrainz.h>
namespace MusicBrainz
{
class Entity;
/**
* 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.
*/
class MB_API Relation
{
public:
//! Identifies relations linking to an artist.
static const std::string TO_ARTIST;
//! Identifies relations linking to a release.
static const std::string TO_RELEASE;
//! Identifies relations linking to a track.
static const std::string TO_TRACK;
//! Identifies relations linking to an URL.
static const std::string TO_URL;
enum Direction {
//! Relation reading direction doesn't matter.
DIR_BOTH,
//! Relation reading direction is from source to target.
DIR_FORWARD,
//! Relation reading direction is from target to source.
DIR_BACKWARD
};
//! A vector of strings (attributes).
typedef std::vector<std::string> Attributes;
/**
* Constructor.
*
* @param relationType a string containing an absolute URI
* @param targetType a string containing an absolute URI
* @param targetId a string containing an absolute URI
* @param direction one of Relation::DIR_FORWARD,
* Relation::DIR_BACKWARD, or Relation::DIR_BOTH
* @param attributes a list of strings containing absolute URIs
* @param beginDate a string containing a date
* @param endDate a string containing a date
* @param target an instance of a subclass of Entity, or NULL
*/
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);
/**
* Destructor.
*/
virtual ~Relation();
/**
* Returns this relation's type.
*
* @return a string containing an absolute URI
*/
std::string getType() const;
/**
* Sets this relation's type.
*
* @param type a string containing an absolute URI
*/
void setType(const std::string &type);
/**
* 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.
*
* @return a string containing an absolute URI
*/
std::string getTargetId() const;
/**
* Sets the target's ID.
*
* @param targetId a string containing an absolute URI
*
* @see getTargetId
*/
void setTargetId(const std::string &targetId);
/**
* Returns the target's type.
*
* For MusicBrainz data, the following target types are defined:
* - artists: Relation::TO_ARTIST
* - releases: Relation::TO_RELEASE
* - tracks: Relation::TO_TRACK
* - urls: Relation::TO_URL
*
* @return a string containing an absolute URI
*/
std::string getTargetType() const;
/**
* Sets the target's type.
*
* @param targetType a string containing an absolute URI
*
* @see getTargetType
*/
void setTargetType(const std::string &targetType);
/**
* 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.
*
* @return a string containing a date
*/
std::string getBeginDate() const;
/**
* Sets the begin date.
*
* @param dateStr a string containing a date
*
* @see getBeginDate
*/
void setBeginDate(const std::string &dateStr);
/**
* 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.
*
* @return a string containing a date
*
* @see getBeginDate
*/
std::string getEndDate() const;
/**
* Sets the end date.
*
* @param dateStr: a string containing a date
*
* @see getBeginDate
*/
void setEndDate(const std::string &dateStr);
/**
* 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.
*
* @return Relation::DIR_FORWARD, Relation::DIR_BACKWARD,
* or Relation::DIR_BOTH
*/
Direction getDirection() const;
/**
* Sets the reading direction.
*
* @param direction Relation::DIR_FORWARD,
* Relation::DIR_BACKWARD, or Relation::DIR_BOTH
*
* @see getDirection
*/
void setDirection(const Direction direction);
/**
* Returns a list of attributes describing this relation.
*
* The attributes permitted depend on the relation type.
*
* @return a list of strings containing absolute URIs
*/
Attributes &getAttributes();
/**
* Returns number of attributes.
*
* This is equivalent to \c getAttributes().size()
*
* @return an int containing number of attributes
*
* @see getAttributes
*/
int getNumAttributes() const;
/**
* Returns an attribute specified by index.
*
* This is equivalent to \c getAttributes()[index]
*
* @return a string containing the attribute
*
* @see getAttributes
*/
std::string getAttribute(int index) const;
/**
* Adds an attribute to the list.
*
* @param attribute a string containing an absolute URI
*/
void addAttribute(const std::string &attribute);
/**
* Returns this relation's target object.
*
* Note that URL relations never have a target object. Use the
* getTargetId method to get the URL.
*
* @return a subclass of Entity, or NULL
*/
Entity *getTarget() const;
/**
* Sets this relation's target object.
*
* Note that URL relations never have a target object, they
* are set using setTargetId.
*
* @param target a subclass of Entity, or NULL
*/
void setTarget(Entity *target);
private:
class RelationPrivate;
RelationPrivate *d;
};
}
#endif
|