Library: Update documentation for the Library tag

I also take the chance to remove the corresponding section of the DESIGN
file.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2014-11-14 08:19:08 -05:00
parent ce8b3ada03
commit d88f008728
3 changed files with 26 additions and 61 deletions

45
DESIGN
View File

@ -120,51 +120,6 @@ Tag Database:
Library Tag:
The library tag is used to store a single directory added to Ocarina
by the user. It is not an ID3 tag, and is instead something I use
internally to keep track of paths added by the user. The count field
will be managed by the Track tag class.
- Library:
class Library : public DatabaseEntry {
public:
std::string root_path;
unsigned int count;
bool enabled;
Library();
Library(const std::string &);
const std::string primary_key() const;
void read(File &);
void write(File &);
};
- File Format:
File << enabled << root_path
- API:
Library();
Initialize an invalid Library instance.
Set count = 0.
Set enabled = false.
Library(const std::string &path);
Set root_path from the provided path.
Set count = 0.
Set enabled = true.
const std::string Library :: primary_key() const;
Use root_path as the primary key,
void read(File &f);
Read a library path from file.
void write(File &f);
Write a library path to file.
Track Tag: Track Tag:
The track tag is used to store information about a single track in the The track tag is used to store information about a single track in the
user's music collection. user's music collection.

View File

@ -9,8 +9,8 @@ Library :: Library()
{ {
} }
Library :: Library(const std::string &s) Library :: Library(const std::string &path)
: _size(0), _path(s), _enabled(true) : _size(0), _path(path), _enabled(true)
{ {
} }
@ -19,15 +19,15 @@ const std::string Library :: primary_key() const
return _path; return _path;
} }
void Library :: read(File &f) void Library :: read(File &file)
{ {
f >> _enabled; file >> _enabled;
_path = f.getline(); _path = file.getline();
} }
void Library :: write(File &f) void Library :: write(File &file)
{ {
f << _enabled << " " << _path; file << _enabled << " " << _path;
} }
const bool Library :: enabled() const bool Library :: enabled()

View File

@ -8,7 +8,15 @@
#include <core/database.h> #include <core/database.h>
/** /**
* Library tag * The Library tag is used to store a single directory added
* to Ocarina by the user.
*
* When writing a Library tag to disk, write out the _enabled
* and _path fields for each tag.
*
* ... << enabled1 << path1
* ... << enabled2 << path2
* ... << enabled3 << path3
*/ */
class Library : public DatabaseEntry { class Library : public DatabaseEntry {
private: private:
@ -17,29 +25,32 @@ private:
bool _enabled; /**< Is this library path enabled? */ bool _enabled; /**< Is this library path enabled? */
public: public:
/** Library constructor */ Library(); /**< Library tag constructor. */
Library();
/** /**
* Library constructor * Library tag constructor.
* @param path Path to the library on disk. *
* @param path Path to the library directory on disk.
*/ */
Library(const std::string &); Library(const std::string &);
/** /**
* Called to access the library tag's primary key. * Called to access the library tag's primary key.
* @return Library::root_path *
* @return Library::_path.
*/ */
const std::string primary_key() const; const std::string primary_key() const;
/** /**
* Read library information from file. * Read library information from file.
*
* @param file The file to read from. * @param file The file to read from.
*/ */
void read(File &); void read(File &);
/** /**
* Write library information to file. * Write library information to file.
*
* @param file The file to write to. * @param file The file to write to.
*/ */
void write(File &); void write(File &);
@ -59,7 +70,6 @@ public:
*/ */
void set_enabled(bool); void set_enabled(bool);
/** /**
* Called to access the number of tracks in this library. * Called to access the number of tracks in this library.
* *
@ -68,12 +78,12 @@ public:
const unsigned int size(); const unsigned int size();
/** /**
* Used to increase _size by 1. * Used to increase Library::_size by 1.
*/ */
void inc_size(); void inc_size();
/** /**
* Used to decrease _size by 1. * Used to decrease Library::_size by 1.
*/ */
void dec_size(); void dec_size();
}; };