BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
grouped_orders_plugin.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Abit More, and contributors.
3  *
4  * The MIT License
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 #pragma once
25 
26 #include <graphene/app/plugin.hpp>
28 
29 namespace graphene { namespace grouped_orders {
30 using namespace chain;
31 
33 {
34  limit_order_group_key( const uint16_t g, const price& p ) : group(g), min_price(p) {}
36 
37  uint16_t group = 0;
38  price min_price;
39 
40  friend bool operator < ( const limit_order_group_key& a, const limit_order_group_key& b )
41  {
42  // price is ordered descendingly, same as limit_order_index
43  return std::tie( a.group, b.min_price ) < std::tie( b.group, a.min_price );
44  }
45  friend bool operator == ( const limit_order_group_key& a, const limit_order_group_key& b )
46  {
47  return std::tie( a.group, a.min_price ) == std::tie( b.group, b.min_price );
48  }
49 };
50 
52 {
53  limit_order_group_data( const price& p, const share_type s ) : max_price(p), total_for_sale(s) {}
55 
58 };
59 
60 namespace detail
61 {
62  class grouped_orders_plugin_impl;
63 }
64 
70 {
71  public:
73  ~grouped_orders_plugin() override;
74 
75  std::string plugin_name()const override;
76  void plugin_set_program_options(
77  boost::program_options::options_description& cli,
78  boost::program_options::options_description& cfg) override;
79  void plugin_initialize(
80  const boost::program_options::variables_map& options) override;
81  void plugin_startup() override;
82 
83  const flat_set<uint16_t>& tracked_groups()const;
84 
85  const map< limit_order_group_key, limit_order_group_data >& limit_order_groups();
86 
87  private:
88  std::unique_ptr<detail::grouped_orders_plugin_impl> my;
89 };
90 
91 } } //graphene::grouped_orders
92 
graphene::grouped_orders::limit_order_group_key::limit_order_group_key
limit_order_group_key(const uint16_t g, const price &p)
Definition: grouped_orders_plugin.hpp:34
graphene::grouped_orders::limit_order_group_data::limit_order_group_data
limit_order_group_data(const price &p, const share_type s)
Definition: grouped_orders_plugin.hpp:53
graphene::protocol::price
The price struct stores asset prices in the BitShares system.
Definition: asset.hpp:108
database.hpp
fc::operator<
bool operator<(const variant &a, const variant &b)
Definition: variant.cpp:734
plugin.hpp
graphene::grouped_orders::limit_order_group_data
Definition: grouped_orders_plugin.hpp:51
graphene::grouped_orders::limit_order_group_key::limit_order_group_key
limit_order_group_key()
Definition: grouped_orders_plugin.hpp:35
graphene::app::application
Definition: application.hpp:91
graphene::grouped_orders::limit_order_group_data::limit_order_group_data
limit_order_group_data()
Definition: grouped_orders_plugin.hpp:54
graphene::app::plugin
Definition: plugin.hpp:100
graphene::grouped_orders::grouped_orders_plugin
Definition: grouped_orders_plugin.hpp:69
graphene::protocol::share_type
safe< int64_t > share_type
Definition: types.hpp:309
graphene::grouped_orders::limit_order_group_data::total_for_sale
share_type total_for_sale
asset id is min_price.base.asset_id
Definition: grouped_orders_plugin.hpp:57
graphene::grouped_orders::limit_order_group_data::max_price
price max_price
Definition: grouped_orders_plugin.hpp:56
graphene::grouped_orders::limit_order_group_key
Definition: grouped_orders_plugin.hpp:32
FC_REFLECT
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
Definition: reflect.hpp:388
graphene::grouped_orders::limit_order_group_key::min_price
price min_price
Definition: grouped_orders_plugin.hpp:38
fc::operator==
bool operator==(const optional< T > &left, const optional< T > &right)
Definition: optional.hpp:249
graphene
Definition: api.cpp:48
graphene::grouped_orders::limit_order_group_key::group
uint16_t group
percentage, 1 means 1 / 10000
Definition: grouped_orders_plugin.hpp:37