Library: Move the Library tag into a new file
No code or documentation changes yet, just split things out for now. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
1e6bcf7451
commit
4d6cb81f77
|
@ -18,40 +18,6 @@ Database<Library> library_db("library.db", true);
|
|||
Database<Track> 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
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* @file
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <core/tags/library.h>
|
||||
|
||||
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;
|
||||
}
|
|
@ -9,6 +9,7 @@
|
|||
#include <core/tags/album.h>
|
||||
#include <core/tags/artist.h>
|
||||
#include <core/tags/genre.h>
|
||||
#include <core/tags/library.h>
|
||||
|
||||
|
||||
/**
|
||||
|
@ -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();
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
* @file
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
#ifndef OCARINA_CORE_TAGS_LIBRARY_H
|
||||
#define OCARINA_CORE_TAGS_LIBRARY_H
|
||||
|
||||
#include <core/database.h>
|
||||
|
||||
/**
|
||||
* 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 */
|
|
@ -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") ]
|
||||
|
|
Loading…
Reference in New Issue