view libcommon/malikania/loader.hpp @ 99:0addfab87b17

Common: implement basic tilesets, closes #664
author David Demelier <markand@malikania.fr>
date Fri, 18 Aug 2017 18:45:07 +0200
parents f4d23ad4aa27
children 119bcc5a727e
line wrap: on
line source

/*
 * loader.hpp -- load shared resources files
 *
 * Copyright (c) 2013-2017 Malikania Authors
 *
 * 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_LOADER_HPP
#define MALIKANIA_LOADER_HPP

#include <string>

namespace mlk {

class game;
class locator;
class tileset;

/**
 * \brief Open resources files using a locator.
 *
 * This class is used to load resources files that are common to the server and
 * the client.
 *
 * \see client_loader
 */
class loader {
private:
    mlk::locator& m_locator;

public:
    /**
     * Construct the resources loader.
     *
     * \param locator the locator
     */
    loader(mlk::locator& locator);

    /**
     * Virtual destructor defaulted.
     */
    virtual ~loader() noexcept = default;

    /**
     * Get the underlying locator.
     *
     * \return the locator
     */
    inline mlk::locator& locator() noexcept
    {
        return m_locator;
    }

    /**
     * Load a game.
     *
     * \return the game
     * \throw std::runtime_error on errors
     */
    virtual game load_game() const;

    /**
     * Load a tileset.
     *
     * \param id the tileset id
     * \return a tileset ready to use
     * \throw std::runtime_error on errors
     */
    virtual tileset load_tileset(const std::string& id) const;
};

} // !mlk

#endif // !MALIKANIA_LOADER_HPP