Mercurial > malikania
view libdb-sqlite/malikania/server/db/sqlite_character.hpp @ 158:4b292c20124c
Misc: update copyrights
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 09 Jan 2018 13:15:07 +0100 |
parents | 532f259557dd |
children |
line wrap: on
line source
/* * sqlite_character.hpp -- database character object (SQLite implementation) * * Copyright (c) 2013-2018 David Demelier <markand@malikania.fr> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef MALIKANIA_DB_SQLITE_CHARACTER_HPP #define MALIKANIA_DB_SQLITE_CHARACTER_HPP /** * \file sqlite_character.hpp * \brief Database character object (SQLite implementation). */ #include <malikania/server/db/character.hpp> #include "common.hpp" namespace mlk { namespace server { class sqlite_database; /** * \brief Database character object (SQLite implementation). */ class sqlite_character : public character { private: sqlite_database& db_; public: class sqlite_dao; protected: /** * \copydoc character::do_set_level */ void do_set_level(std::uint16_t level) override; /** * \copydoc character::do_save */ void do_save(std::uint64_t account_id) override; /** * \copydoc character::do_remove */ void do_remove() override; public: /** * Construct the sqlite character. * * \pre instance != nullptr * \param nickname the nickname * \param classname the classname * \param db the sqlite_database owner */ inline sqlite_character(std::string nickname, std::string classname, sqlite_database& db) noexcept : character(std::move(nickname), std::move(classname)) , db_(db) { } }; /** * \brief DAO for characters (SQLite implementation). */ class sqlite_character::sqlite_dao { private: sqlite_database& db_; std::unique_ptr<character> get(stmt_ptr& stmt); character_list get_all(stmt_ptr stmt); public: /** * Construct the DAO. * * \param db the sqlite_database owner */ inline sqlite_dao(sqlite_database& db) noexcept : db_(db) { } /** * Get the set of characters for the given account. */ character_list characters_for_account(std::uint64_t account_id); }; } // !server } // !mlk #endif // !MALIKANIA_DB_SQLITE_CHARACTER_HPP