Scorum
game.hpp
Go to the documentation of this file.
1 #pragma once
8 
9 namespace scorum {
10 namespace chain {
11 
12 struct dynamic_global_property_service_i;
13 struct betting_property_service_i;
14 
15 struct game_service_i : public base_service_i<game_object>
16 {
18 
19  virtual const game_object& create_game(const uuid_type& uuid,
20  const std::string& json_metadata,
21  fc::time_point_sec start,
22  uint32_t auto_resolve_delay_sec,
23  const game_type& game,
24  const fc::flat_set<market_type>& markets)
25  = 0;
26 
27  virtual void finish(const game_object& game, const fc::flat_set<wincase_type>& wincases) = 0;
28  virtual void update_markets(const game_object& game, const fc::flat_set<market_type>& markets) = 0;
29 
30  virtual bool is_exists(int64_t game_id) const = 0;
31  virtual bool is_exists(const uuid_type& uuid) const = 0;
32 
33  virtual const game_object& get_game(int64_t game_id) const = 0;
34  virtual const game_object& get_game(const uuid_type& uuid) const = 0;
35 
36  virtual std::vector<object_cref_type> get_games(fc::time_point_sec start) const = 0;
37 };
38 
39 class dbs_game : public dbs_service_base<game_service_i>
40 {
41  friend class dbservice_dbs_factory;
42 
43 protected:
44  explicit dbs_game(database& db);
45 
46 public:
48 
49  virtual const game_object& create_game(const uuid_type& uuid,
50  const std::string& json_metadata,
51  fc::time_point_sec start,
52  uint32_t auto_resolve_delay_sec,
53  const game_type& game,
54  const fc::flat_set<market_type>& markets) override;
55  virtual void finish(const game_object& game, const fc::flat_set<wincase_type>& wincases) override;
56  virtual void update_markets(const game_object& game, const fc::flat_set<market_type>& markets) override;
57 
58  virtual bool is_exists(int64_t game_id) const override;
59  bool is_exists(const uuid_type& uuid) const override;
60 
61  virtual const game_object& get_game(int64_t game_id) const override;
62  virtual const game_object& get_game(const uuid_type& uuid) const override;
63  virtual std::vector<object_cref_type> get_games(fc::time_point_sec start) const override;
64 
65 private:
66  dynamic_global_property_service_i& _dprops_service;
67  betting_property_service_i& _betting_props_service;
69 };
70 }
71 }
tracks the blockchain state in an extensible manner
Definition: database.hpp:52
virtual void finish(const game_object &game, const fc::flat_set< wincase_type > &wincases) override
Definition: game.cpp:45
dbs_game(database &db)
Definition: game.cpp:11
virtual const game_object & create_game(const uuid_type &uuid, const std::string &json_metadata, fc::time_point_sec start, uint32_t auto_resolve_delay_sec, const game_type &game, const fc::flat_set< market_type > &markets) override
Definition: game.cpp:19
virtual std::vector< object_cref_type > get_games(fc::time_point_sec start) const override
Definition: game.cpp:89
virtual const game_object & get_game(int64_t game_id) const override
Definition: game.cpp:79
virtual void update_markets(const game_object &game, const fc::flat_set< market_type > &markets) override
Definition: game.cpp:60
fc::static_variant< soccer_game, hockey_game > game_type
Definition: game.hpp:14
Definition: asset.cpp:15
boost::uuids::uuid uuid_type
Definition: types.hpp:53
virtual const game_object & get_game(int64_t game_id) const =0
virtual const game_object & get_game(const uuid_type &uuid) const =0
virtual bool is_exists(const uuid_type &uuid) const =0
virtual std::vector< object_cref_type > get_games(fc::time_point_sec start) const =0
virtual void update_markets(const game_object &game, const fc::flat_set< market_type > &markets)=0
virtual const game_object & create_game(const uuid_type &uuid, const std::string &json_metadata, fc::time_point_sec start, uint32_t auto_resolve_delay_sec, const game_type &game, const fc::flat_set< market_type > &markets)=0
virtual void finish(const game_object &game, const fc::flat_set< wincase_type > &wincases)=0
virtual bool is_exists(int64_t game_id) const =0