/*
- Copyright (C) 2008 Paul Davis
+ Copyright (C) 2008 Paul Davis
Author: Sakari Bergen
This program is free software; you can redistribute it and/or modify it
using namespace Glib;
using namespace ARDOUR;
+SessionMetadata *SessionMetadata::_metadata = NULL; //singleton instance
+
SessionMetadata::SessionMetadata ()
-{
+{
/*** General ***/
map.insert (Property ("comment", ""));
map.insert (Property ("copyright", ""));
map.insert (Property ("mixer", ""));
//map.insert (Property ("performers", "")); // Multiple values [instrument]
+ /*** Education... ***/
+ map.insert (Property ("instructor", ""));
+ map.insert (Property ("course", ""));
+
/*** Album info ***/
map.insert (Property ("album", ""));
map.insert (Property ("compilation", ""));
//map.insert (Property ("lyrics", ""));
//map.insert (Property ("media", ""));
//map.insert (Property ("label", ""));
- //map.insert (Property ("barcode", ""));
+ map.insert (Property ("barcode", ""));
//map.insert (Property ("encoded_by", ""));
//map.insert (Property ("catalog_number", ""));
//map.insert (Property ("album_artist_sort", ""));
//map.insert (Property ("artist_sort", ""));
//map.insert (Property ("title_sort", ""));
+
+ /*** Globals ***/
+ user_map.insert (Property ("user_name", ""));
+ user_map.insert (Property ("user_email", ""));
+ user_map.insert (Property ("user_web", ""));
+ user_map.insert (Property ("user_organization", ""));
+ user_map.insert (Property ("user_country", ""));
}
SessionMetadata::~SessionMetadata ()
}
XMLNode *
-SessionMetadata::get_xml (const ustring & name)
+SessionMetadata::get_xml (const string & name)
{
- ustring value = get_value (name);
+ string value = get_value (name);
if (value.empty()) {
return 0;
}
-
+
XMLNode val ("value", value);
XMLNode * node = new XMLNode (name);
node->add_child_copy (val);
-
+
return node;
}
-ustring
-SessionMetadata::get_value (const ustring & name) const
+string
+SessionMetadata::get_value (const string & name) const
{
PropertyMap::const_iterator it = map.find (name);
if (it == map.end()) {
- // Should not be reached!
- std::cerr << "Programming error in SessionMetadata::get_value" << std::endl;
- return "";
+ it = user_map.find (name);
+ if (it == user_map.end()) {
+ // Should not be reached, except if loading metadata from a newer version with a new type
+ std::cerr << "Programming error in SessionMetadata::get_value (" << name << ")" << std::endl;
+ return "";
+ }
}
-
+
return it->second;
}
uint32_t
-SessionMetadata::get_uint_value (const ustring & name) const
+SessionMetadata::get_uint_value (const string & name) const
{
return atoi (get_value (name).c_str());
}
void
-SessionMetadata::set_value (const ustring & name, const ustring & value)
+SessionMetadata::set_value (const string & name, const string & value)
{
PropertyMap::iterator it = map.find (name);
if (it == map.end()) {
- // Should not be reached!
- std::cerr << "Programming error in SessionMetadata::set_value" << std::endl;
- return;
+ it = user_map.find (name);
+ if (it == user_map.end()) {
+ // Should not be reached, except if loading metadata from a newer version with a new type
+ std::cerr << "Programming error in SessionMetadata::set_value (" << name << ")" << std::endl;
+ return;
+ }
}
-
+
it->second = value;
}
void
-SessionMetadata::set_value (const ustring & name, uint32_t value)
+SessionMetadata::set_value (const string & name, uint32_t value)
{
std::ostringstream oss;
oss << value;
{
XMLNode * node = new XMLNode ("Metadata");
XMLNode * prop;
-
+
for (PropertyMap::const_iterator it = map.begin(); it != map.end(); ++it) {
if ((prop = get_xml (it->first))) {
node->add_child_nocopy (*prop);
}
}
-
+
return *node;
}
int
-SessionMetadata::set_state (const XMLNode & state)
+SessionMetadata::set_state (const XMLNode & state, int /*version_num*/)
{
const XMLNodeList & children = state.children();
- ustring name;
- ustring value;
+ string name;
+ string value;
XMLNode * node;
-
+
for (XMLNodeConstIterator it = children.begin(); it != children.end(); it++) {
node = *it;
if (node->children().empty()) {
continue;
}
-
+
name = node->name();
node = *node->children().begin();
value = node->content();
-
+
set_value (name, value);
}
-
+
return 0;
}
+
+XMLNode &
+SessionMetadata::get_user_state ()
+{
+ XMLNode * node = new XMLNode ("Metadata");
+ XMLNode * prop;
+
+ for (PropertyMap::const_iterator it = user_map.begin(); it != user_map.end(); ++it) {
+ if ((prop = get_xml (it->first))) {
+ node->add_child_nocopy (*prop);
+ }
+ }
+
+ return *node;
+}
+
/*** Accessing ***/
-ustring
+string
SessionMetadata::comment () const
{
return get_value("comment");
}
-ustring
+string
SessionMetadata::copyright () const
{
return get_value("copyright");
}
-ustring
+string
SessionMetadata::isrc () const
{
return get_value("isrc");
return get_uint_value("year");
}
-ustring
+string
SessionMetadata::grouping () const
{
return get_value("grouping");
}
-ustring
+string
+SessionMetadata::barcode () const
+{
+ return get_value("barcode");
+}
+
+string
SessionMetadata::title () const
{
return get_value("title");
}
-ustring
+string
SessionMetadata::subtitle () const
{
return get_value("subtitle");
}
-ustring
+string
SessionMetadata::artist () const
{
return get_value("artist");
}
-ustring
+string
SessionMetadata::album_artist () const
{
return get_value("album_artist");
}
-ustring
+string
SessionMetadata::lyricist () const
{
return get_value("lyricist");
}
-ustring
+string
SessionMetadata::composer () const
{
return get_value("composer");
}
-ustring
+string
SessionMetadata::conductor () const
{
return get_value("conductor");
}
-ustring
+string
SessionMetadata::remixer () const
{
return get_value("remixer");
}
-ustring
+string
SessionMetadata::arranger () const
{
return get_value("arranger");
}
-ustring
+string
SessionMetadata::engineer () const
{
return get_value("engineer");
}
-ustring
+string
SessionMetadata::producer () const
{
return get_value("producer");
}
-ustring
+string
SessionMetadata::dj_mixer () const
{
return get_value("dj_mixer");
}
-ustring
+string
SessionMetadata::mixer () const
{
return get_value("mixer");
}
-ustring
+string
SessionMetadata::album () const
{
return get_value("album");
}
-ustring
+string
SessionMetadata::compilation () const
{
return get_value("compilation");
}
-ustring
+string
SessionMetadata::disc_subtitle () const
{
return get_value("disc_subtitle");
return get_uint_value("total_tracks");
}
-ustring
+string
SessionMetadata::genre () const
{
return get_value("genre");
}
+string
+SessionMetadata::instructor () const
+{
+ return get_value("instructor");
+}
+
+string
+SessionMetadata::course () const
+{
+ return get_value("course");
+}
+
+
+string
+SessionMetadata::user_name () const
+{
+ return get_value("user_name");
+}
+
+string
+SessionMetadata::user_email () const
+{
+ return get_value("user_email");
+}
+
+string
+SessionMetadata::user_web () const
+{
+ return get_value("user_web");
+}
+
+string
+SessionMetadata::organization () const
+{
+ return get_value("user_organization");
+}
+
+string
+SessionMetadata::country () const
+{
+ return get_value("user_country");
+}
+
+
+
/*** Editing ***/
void
-SessionMetadata::set_comment (const ustring & v)
+SessionMetadata::set_comment (const string & v)
{
set_value ("comment", v);
}
void
-SessionMetadata::set_copyright (const ustring & v)
+SessionMetadata::set_copyright (const string & v)
{
set_value ("copyright", v);
}
void
-SessionMetadata::set_isrc (const ustring & v)
+SessionMetadata::set_isrc (const string & v)
{
set_value ("isrc", v);
}
}
void
-SessionMetadata::set_grouping (const ustring & v)
+SessionMetadata::set_grouping (const string & v)
{
set_value ("grouping", v);
}
void
-SessionMetadata::set_title (const ustring & v)
+SessionMetadata::set_barcode (const string & v)
+{
+ set_value ("barcode", v);
+}
+
+void
+SessionMetadata::set_title (const string & v)
{
set_value ("title", v);
}
void
-SessionMetadata::set_subtitle (const ustring & v)
+SessionMetadata::set_subtitle (const string & v)
{
set_value ("subtitle", v);
}
void
-SessionMetadata::set_artist (const ustring & v)
+SessionMetadata::set_artist (const string & v)
{
set_value ("artist", v);
}
void
-SessionMetadata::set_album_artist (const ustring & v)
+SessionMetadata::set_album_artist (const string & v)
{
set_value ("album_artist", v);
}
void
-SessionMetadata::set_lyricist (const ustring & v)
+SessionMetadata::set_lyricist (const string & v)
{
set_value ("lyricist", v);
}
void
-SessionMetadata::set_composer (const ustring & v)
+SessionMetadata::set_composer (const string & v)
{
set_value ("composer", v);
}
void
-SessionMetadata::set_conductor (const ustring & v)
+SessionMetadata::set_conductor (const string & v)
{
set_value ("conductor", v);
}
void
-SessionMetadata::set_remixer (const ustring & v)
+SessionMetadata::set_remixer (const string & v)
{
set_value ("remixer", v);
}
void
-SessionMetadata::set_arranger (const ustring & v)
+SessionMetadata::set_arranger (const string & v)
{
set_value ("arranger", v);
}
void
-SessionMetadata::set_engineer (const ustring & v)
+SessionMetadata::set_engineer (const string & v)
{
set_value ("engineer", v);
}
void
-SessionMetadata::set_producer (const ustring & v)
+SessionMetadata::set_producer (const string & v)
{
set_value ("producer", v);
}
void
-SessionMetadata::set_dj_mixer (const ustring & v)
+SessionMetadata::set_dj_mixer (const string & v)
{
set_value ("dj_mixer", v);
}
void
-SessionMetadata::set_mixer (const ustring & v)
+SessionMetadata::set_mixer (const string & v)
{
set_value ("mixer", v);
}
void
-SessionMetadata::set_album (const ustring & v)
+SessionMetadata::set_album (const string & v)
{
set_value ("album", v);
}
void
-SessionMetadata::set_compilation (const ustring & v)
+SessionMetadata::set_compilation (const string & v)
{
set_value ("compilation", v);
}
void
-SessionMetadata::set_disc_subtitle (const ustring & v)
+SessionMetadata::set_disc_subtitle (const string & v)
{
set_value ("disc_subtitle", v);
}
}
void
-SessionMetadata::set_genre (const ustring & v)
+SessionMetadata::set_genre (const string & v)
{
set_value ("genre", v);
}
+
+void
+SessionMetadata::set_instructor (const string & v)
+{
+ set_value ("instructor", v);
+}
+
+void
+SessionMetadata::set_course (const string & v)
+{
+ set_value ("course", v);
+}
+
+void
+SessionMetadata::set_user_name (const string & v)
+{
+ set_value ("user_name", v);
+}
+
+void
+SessionMetadata::set_user_email (const string & v)
+{
+ set_value ("user_email", v);
+}
+
+void
+SessionMetadata::set_user_web (const string & v)
+{
+ set_value ("user_web", v);
+}
+
+void
+SessionMetadata::set_organization (const string & v)
+{
+ set_value ("user_organization", v);
+}
+void
+SessionMetadata::set_country (const string & v)
+{
+ set_value ("user_country", v);
+}