ocarina/include/core/tags/library.h

132 lines
2.7 KiB
C++

/**
* Copyright 2014 (c) Anna Schumaker.
*/
#ifndef OCARINA_CORE_TAGS_LIBRARY_H
#define OCARINA_CORE_TAGS_LIBRARY_H
#include <core/database.h>
#include <core/tags/generic.h>
/**
* 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 {
private:
unsigned int _size; /**< Number of tracks in this library. */
std::string _path; /**< Path to the root directory of this library. */
bool _enabled; /**< Is this library path enabled? */
public:
Library(); /**< Library tag constructor. */
/**
* Library tag constructor.
*
* @param path Path to the library directory on disk.
*/
Library(const std::string &);
/**
* Called to access the library tag's primary key.
*
* @return Library::_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 &);
/**
* Called to check if this library path is currently enabled.
*
* @return Library::_enabled.
*/
const bool enabled();
/**
* Called to set if this library path is enabled.
*
* @param enabled True if this path should be enabled, false otherwise.
*/
void set_enabled(bool);
/**
* Called to access the number of tracks in this library.
*
* @return Library::_size.
*/
const unsigned int size();
/**
* Used to increase Library::_size by 1.
*/
void inc_size();
/**
* Used to decrease Library::_size by 1.
*/
void dec_size();
};
namespace tags
{
/** Called to read the library_db from disk. */
void init_library_db();
/**
* Called to look up a Library tag by library path. If no
* existing tag is found a new one will be created and
* returned to the caller.
*
* @param path The path to the library directory on disk.
* @return A matching Library tag.
*/
Library *get_library(const std::string &);
/**
* Called to look up a Library tag by tag index.
*
* @param index The index of the Library tag.
* @return A matching Library tag.
*/
Library *get_library(const unsigned int);
/**
* Called to remove a specific Library tag.
*
* @param library The Library tag to remove.
*/
void remove_library(Library *);
/**
* Called to find the number of rows in the library_db,
* including NULL rows.
*
* @return The Database::actual_size() of the library_db.
*/
unsigned int library_size();
}
#endif /* OCARINA_CORE_TAGS_LIBRARY_H */