diff --git a/core/tags.cpp b/core/tags.cpp index b45ef1db..26d6c85a 100644 --- a/core/tags.cpp +++ b/core/tags.cpp @@ -18,40 +18,6 @@ Database library_db("library.db", true); Database track_db("track.db", false); -/** - * - * Library tag - * - */ - -Library :: Library() - : count(0), enabled(false) -{ -} - -Library :: Library(const std::string &s) - : root_path(s), count(0), enabled(true) -{ -} - -const std::string Library :: primary_key() const -{ - return root_path; -} - -void Library :: read(File &f) -{ - f >> enabled; - root_path = f.getline(); -} - -void Library :: write(File &f) -{ - f << enabled << " " << root_path; -} - - - /** * * Track tag diff --git a/core/tags/library.cpp b/core/tags/library.cpp new file mode 100644 index 00000000..8edef7c1 --- /dev/null +++ b/core/tags/library.cpp @@ -0,0 +1,31 @@ +/** + * @file + * Copyright 2014 (c) Anna Schumaker. + */ +#include + +Library :: Library() + : count(0), enabled(false) +{ +} + +Library :: Library(const std::string &s) + : root_path(s), count(0), enabled(true) +{ +} + +const std::string Library :: primary_key() const +{ + return root_path; +} + +void Library :: read(File &f) +{ + f >> enabled; + root_path = f.getline(); +} + +void Library :: write(File &f) +{ + f << enabled << " " << root_path; +} diff --git a/include/core/tags.h b/include/core/tags.h index c2097903..7c0bac6c 100644 --- a/include/core/tags.h +++ b/include/core/tags.h @@ -9,6 +9,7 @@ #include #include #include +#include /** @@ -36,47 +37,6 @@ enum sort_t { }; -/** - * Library tag - */ -class Library : public DatabaseEntry { -public: - /** Path to the directory containing this library's audio files */ - std::string root_path; - /** Number of tracks in this library */ - unsigned int count; - /** True if the library is enabled, false otherwise */ - bool enabled; - - /** Library constructor */ - Library(); - - /** - * Library constructor - * @param path Path to the library on disk. - */ - Library(const std::string &); - - /** - * Called to access the library tag's primary key. - * @return Library::root_path - */ - const std::string primary_key() const; - - /** - * Read library information from file. - * @param file The file to read from. - */ - void read(File &); - - /** - * Write library information to file. - * @param file The file to write to. - */ - void write(File &); -}; - - class Track : public DatabaseEntry { private: void set_length_str(); diff --git a/include/core/tags/library.h b/include/core/tags/library.h new file mode 100644 index 00000000..8360b147 --- /dev/null +++ b/include/core/tags/library.h @@ -0,0 +1,50 @@ +/** + * @file + * Copyright 2014 (c) Anna Schumaker. + */ +#ifndef OCARINA_CORE_TAGS_LIBRARY_H +#define OCARINA_CORE_TAGS_LIBRARY_H + +#include + +/** + * Library tag + */ +class Library : public DatabaseEntry { +public: + /** Path to the directory containing this library's audio files */ + std::string root_path; + /** Number of tracks in this library */ + unsigned int count; + /** True if the library is enabled, false otherwise */ + bool enabled; + + /** Library constructor */ + Library(); + + /** + * Library constructor + * @param path Path to the library on disk. + */ + Library(const std::string &); + + /** + * Called to access the library tag's primary key. + * @return Library::root_path + */ + const std::string primary_key() const; + + /** + * Read library information from file. + * @param file The file to read from. + */ + void read(File &); + + /** + * Write library information to file. + * @param file The file to write to. + */ + void write(File &); +}; + +#endif /* OCARINA_CORE_TAGS_LIBRARY_H */ diff --git a/tests/core/Sconscript b/tests/core/Sconscript index 7a059fda..496c6aea 100644 --- a/tests/core/Sconscript +++ b/tests/core/Sconscript @@ -18,6 +18,7 @@ test( "tags/generic" ) test( "tags/artist" ) test( "tags/album" ) test( "tags/genre" ) +objs += [ get_test_obj("tags/library", "core") ] test_env.UsePackage("taglib") objs += [ get_test_obj("tags", "core") ]