2014-11-10 08:27:31 -05:00
|
|
|
/**
|
|
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
|
|
*/
|
|
|
|
#ifndef OCARINA_CORE_TAGS_LIBRARY_H
|
|
|
|
#define OCARINA_CORE_TAGS_LIBRARY_H
|
|
|
|
|
|
|
|
#include <core/database.h>
|
|
|
|
|
|
|
|
/**
|
2014-11-14 08:19:08 -05:00
|
|
|
* 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
|
2014-11-10 08:27:31 -05:00
|
|
|
*/
|
2015-10-31 11:44:29 -04:00
|
|
|
struct library : public db_entry {
|
2015-10-23 10:21:12 -04:00
|
|
|
unsigned int li_size; /* This library's track count. */
|
|
|
|
bool li_enabled;/* True if this library is enabled. */
|
|
|
|
std::string li_path; /* This library's root path. */
|
2014-11-12 08:31:09 -05:00
|
|
|
|
2015-10-23 10:21:12 -04:00
|
|
|
library(); /**< Library tag constructor. */
|
2014-11-10 08:27:31 -05:00
|
|
|
|
|
|
|
/**
|
2014-11-14 08:19:08 -05:00
|
|
|
* Library tag constructor.
|
|
|
|
*
|
|
|
|
* @param path Path to the library directory on disk.
|
2014-11-10 08:27:31 -05:00
|
|
|
*/
|
2015-10-23 10:21:12 -04:00
|
|
|
library(const std::string &);
|
2014-11-10 08:27:31 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called to access the library tag's primary key.
|
2014-11-14 08:19:08 -05:00
|
|
|
*
|
|
|
|
* @return Library::_path.
|
2014-11-10 08:27:31 -05:00
|
|
|
*/
|
|
|
|
const std::string primary_key() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Read library information from file.
|
2014-11-14 08:19:08 -05:00
|
|
|
*
|
2014-11-10 08:27:31 -05:00
|
|
|
* @param file The file to read from.
|
|
|
|
*/
|
2015-09-10 08:00:42 -04:00
|
|
|
void read(file &);
|
2014-11-10 08:27:31 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Write library information to file.
|
2014-11-14 08:19:08 -05:00
|
|
|
*
|
2014-11-10 08:27:31 -05:00
|
|
|
* @param file The file to write to.
|
|
|
|
*/
|
2015-09-10 08:00:42 -04:00
|
|
|
void write(file &);
|
2014-11-10 08:27:31 -05:00
|
|
|
};
|
|
|
|
|
2015-09-28 10:08:11 -04:00
|
|
|
|
2015-09-28 09:45:50 -04:00
|
|
|
/* Called to initialize the library database. */
|
|
|
|
void library_db_init();
|
|
|
|
|
|
|
|
/* Called to clean up the library database. */
|
|
|
|
void library_db_deinit();
|
|
|
|
|
2015-10-23 13:32:20 -04:00
|
|
|
/* Called to access the library database. */
|
|
|
|
const database<struct library> *library_db_get();
|
|
|
|
|
2015-09-28 10:00:06 -04:00
|
|
|
/* Called to find a library tag by library path. */
|
|
|
|
struct library *library_find(const std::string &);
|
|
|
|
|
2015-09-28 10:08:11 -04:00
|
|
|
/* Called to get a library tag with a specific index. */
|
|
|
|
struct library *library_get(const unsigned int);
|
|
|
|
|
2015-09-28 09:55:29 -04:00
|
|
|
/* Called to remove a specific library tag. */
|
|
|
|
void library_remove(struct library *);
|
|
|
|
|
2015-10-23 14:19:42 -04:00
|
|
|
/* Called to configure if the library tag is enabled. */
|
|
|
|
void library_set_enabled(struct library *, bool);
|
|
|
|
|
2015-10-29 02:34:12 -04:00
|
|
|
/* Called to find the full path of files under the library directory. */
|
|
|
|
std::string library_file(struct library *, const std::string &);
|
|
|
|
|
2014-11-10 08:27:31 -05:00
|
|
|
#endif /* OCARINA_CORE_TAGS_LIBRARY_H */
|