BitShares-Core  5.0.0
BitShares blockchain implementation and command-line interface 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 
56  price max_price;
58 };
59 
60 namespace detail
61 {
62  class grouped_orders_plugin_impl;
63 }
64 
70 {
71  public:
73  virtual ~grouped_orders_plugin();
74 
75  std::string plugin_name()const override;
76  virtual void plugin_set_program_options(
77  boost::program_options::options_description& cli,
78  boost::program_options::options_description& cfg) override;
79  virtual void plugin_initialize(
80  const boost::program_options::variables_map& options) override;
81  virtual 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:
89  std::unique_ptr<detail::grouped_orders_plugin_impl> my;
90 };
91 
92 } } //graphene::grouped_orders
93 
95 FC_REFLECT( graphene::grouped_orders::limit_order_group_data, (max_price)(total_for_sale) )
uint16_t group
percentage, 1 means 1 / 10000
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
Definition: reflect.hpp:386
Definition: api.cpp:56
limit_order_group_data(const price &p, const share_type s)
bool operator==(const optional< T > &left, const optional< T > &right)
Definition: optional.hpp:245
limit_order_group_key(const uint16_t g, const price &p)
bool operator<(const variant &a, const variant &b)
Definition: variant.cpp:734
share_type total_for_sale
asset id is min_price.base.asset_id