1 ////////////////////////////////////////////////////////////////////////////////
2 //            Copyright (C) 2004-2011 by The Allacrost Project
3 //            Copyright (C) 2012-2018 by Bertram (Valyria Tear)
4 //                         All Rights Reserved
5 //
6 // This code is licensed under the GNU GPL version 2. It is free software
7 // and you may modify it and/or redistribute it under the terms of this license.
8 // See http://www.gnu.org/copyleft/gpl.html for details.
9 ////////////////////////////////////////////////////////////////////////////////
10 
11 #ifndef __GLOBAL_SHOP_DATA_HANDLER_HEADER__
12 #define __GLOBAL_SHOP_DATA_HANDLER_HEADER__
13 
14 #include "shop_data.h"
15 
16 #include "script/script_read.h"
17 #include "script/script_write.h"
18 
19 #include <string>
20 #include <map>
21 
22 namespace vt_global
23 {
24 
25 class ShopDataHandler
26 {
27 
28 public:
ShopDataHandler()29     ShopDataHandler() {}
30     ~ShopDataHandler();
31 
32     //! \brief Clear all shop data
33     void Clear();
34 
35     //! \brief Gives the shop data corresponding to the current shop id.
36     //! Used to sync a given shop or save games
37     const ShopData& GetShopData(const std::string& shop_id);
38 
39     bool HasShopData(const std::string& shop_id) const;
40 
41     //! \brief Sets the current shop data to global manager.
42     void SetShopData(const std::string& shop_id, const ShopData& shop_data);
43 
44     /** \brief Load shop data from the save game
45     *** \param file Reference to an open file for reading save game data
46     **/
47     void LoadShopData(vt_script::ReadScriptDescriptor& file);
48 
49     /** \brief saves the shop data information. this is called from SaveGame()
50     *** \param file Reference to open and valid file for writting the data
51     **/
52     void SaveShopData(vt_script::WriteScriptDescriptor& file);
53 
54 private:
55     //! \brief A map of the curent shop data.
56     //! shop_id, corresponding shop data
57     std::map<std::string, ShopData> _shop_data;
58 };
59 
60 } // namespace vt_global
61 
62 #endif // __GLOBAL_SHOP_DATA_HANDLER_HEADER__
63