mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
- Renamed /lib subfolders to lowercase
This commit is contained in:
118
lib/mapping/CMapService.h
Normal file
118
lib/mapping/CMapService.h
Normal file
@@ -0,0 +1,118 @@
|
||||
|
||||
/*
|
||||
* CMapService.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
class CMap;
|
||||
class CMapHeader;
|
||||
class CInputStream;
|
||||
|
||||
class IMapLoader;
|
||||
|
||||
/**
|
||||
* The map service provides loading of VCMI/H3 map files. It can
|
||||
* be extended to save maps later as well.
|
||||
*/
|
||||
class DLL_LINKAGE CMapService
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Loads the VCMI/H3 map file specified by the name.
|
||||
*
|
||||
* @param name the name of the map
|
||||
* @return a unique ptr to the loaded map class
|
||||
*/
|
||||
static std::unique_ptr<CMap> loadMap(const std::string & name);
|
||||
|
||||
/**
|
||||
* Loads the VCMI/H3 map header specified by the name.
|
||||
*
|
||||
* @param name the name of the map
|
||||
* @return a unique ptr to the loaded map header class
|
||||
*/
|
||||
static std::unique_ptr<CMapHeader> loadMapHeader(const std::string & name);
|
||||
|
||||
/**
|
||||
* Loads the VCMI/H3 map file from a buffer. This method is temporarily
|
||||
* in use to ease the transition to use the new map service.
|
||||
*
|
||||
* TODO Replace method params with a CampaignMapInfo struct which contains
|
||||
* a campaign loading object + name of map.
|
||||
*
|
||||
* @param buffer a pointer to a buffer containing the map data
|
||||
* @param size the size of the buffer
|
||||
* @return a unique ptr to the loaded map class
|
||||
*/
|
||||
static std::unique_ptr<CMap> loadMap(const ui8 * buffer, int size);
|
||||
|
||||
/**
|
||||
* Loads the VCMI/H3 map header from a buffer. This method is temporarily
|
||||
* in use to ease the transition to use the new map service.
|
||||
*
|
||||
* TODO Replace method params with a CampaignMapInfo struct which contains
|
||||
* a campaign loading object + name of map.
|
||||
*
|
||||
* @param buffer a pointer to a buffer containing the map header data
|
||||
* @param size the size of the buffer
|
||||
* @return a unique ptr to the loaded map class
|
||||
*/
|
||||
static std::unique_ptr<CMapHeader> loadMapHeader(const ui8 * buffer, int size);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Gets a map input stream object specified by a map name.
|
||||
*
|
||||
* @param name the name of the map
|
||||
* @return a unique ptr to the input stream class
|
||||
*/
|
||||
static std::unique_ptr<CInputStream> getStreamFromFS(const std::string & name);
|
||||
|
||||
/**
|
||||
* Gets a map input stream from a buffer.
|
||||
*
|
||||
* @param buffer a pointer to a buffer containing the map data
|
||||
* @param size the size of the buffer
|
||||
* @return a unique ptr to the input stream class
|
||||
*/
|
||||
static std::unique_ptr<CInputStream> getStreamFromMem(const ui8 * buffer, int size);
|
||||
|
||||
/**
|
||||
* Gets a map loader from the given stream. It performs checks to test
|
||||
* in which map format the map is.
|
||||
*
|
||||
* @param stream the input map stream
|
||||
* @return the constructed map loader
|
||||
*/
|
||||
static std::unique_ptr<IMapLoader> getMapLoader(std::unique_ptr<CInputStream> & stream);
|
||||
};
|
||||
|
||||
/**
|
||||
* Interface for loading a map.
|
||||
*/
|
||||
class DLL_LINKAGE IMapLoader
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Loads the VCMI/H3 map file.
|
||||
*
|
||||
* @return a unique ptr of the loaded map class
|
||||
*/
|
||||
virtual std::unique_ptr<CMap> loadMap() = 0;
|
||||
|
||||
/**
|
||||
* Loads the VCMI/H3 map header.
|
||||
*
|
||||
* @return a unique ptr of the loaded map header class
|
||||
*/
|
||||
virtual std::unique_ptr<CMapHeader> loadMapHeader() = 0;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user