Scorum
comment_objects.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <fc/shared_string.hpp>
4 #include <fc/shared_buffer.hpp>
5 
8 
11 
12 #include <boost/multi_index/composite_key.hpp>
13 
14 #include <limits>
15 
16 namespace scorum {
17 namespace chain {
18 
21 
22 class comment_object : public object<comment_object_type, comment_object>
23 {
24 public:
26  CHAINBASE_DEFAULT_DYNAMIC_CONSTRUCTOR(
27  comment_object, (category)(parent_permlink)(permlink)(title)(body)(json_metadata)(beneficiaries))
28 
29  id_type id;
30 
31  fc::shared_string category;
32  account_name_type parent_author;
33  fc::shared_string parent_permlink;
34  account_name_type author;
35  fc::shared_string permlink;
36 
37  fc::shared_string title;
38  fc::shared_string body;
39  fc::shared_string json_metadata;
40  time_point_sec last_update;
41  time_point_sec created;
42 
44  time_point_sec active;
45 
46  time_point_sec last_payout;
47 
49  uint16_t depth = 0;
50 
52  uint32_t children = 0;
53 
56  share_type net_rshares;
57 
59  share_type abs_rshares;
60 
63  share_type vote_rshares;
64 
66  share_type children_abs_rshares;
67 
69  time_point_sec cashout_time;
70 
72  uint64_t total_vote_weight = 0;
73 
74  int32_t net_votes = 0;
75 
76  id_type root_comment;
77 
79  asset max_accepted_payout = asset::maximum(SCORUM_SYMBOL);
80 
82  bool allow_replies = true;
83 
85  bool allow_votes = true;
86 
87  bool allow_curation_rewards = true;
88 
89  fc::shared_vector<beneficiary_route_type> beneficiaries;
90 
92  bool rewarded = false;
93 };
94 
99 class comment_vote_object : public object<comment_vote_object_type, comment_vote_object>
100 {
101 public:
102  CHAINBASE_DEFAULT_CONSTRUCTOR(comment_vote_object)
103 
104  id_type id;
105 
106  account_id_type voter;
107  comment_id_type comment;
108 
110  uint64_t weight = 0;
111 
113  share_type rshares;
114 
116  vote_weight_type vote_percent = 0;
117 
119  time_point_sec last_update;
120  int8_t num_changes = 0;
121 };
122 
123 template <uint16_t ObjectType, asset_symbol_type SymbolType>
124 class comment_statistic_object : public object<ObjectType, comment_statistic_object<ObjectType, SymbolType>>
125 {
126 public:
127  CHAINBASE_DEFAULT_CONSTRUCTOR(comment_statistic_object)
128 
129  typedef typename object<ObjectType, comment_statistic_object<ObjectType, SymbolType>>::id_type id_type;
130 
131  id_type id;
132 
133  comment_id_type comment;
134 
136  asset total_payout_value = asset(0, SymbolType);
137 
139  asset author_payout_value = asset(0, SymbolType);
140 
142  asset curator_payout_value = asset(0, SymbolType);
143 
145  asset beneficiary_payout_value = asset(0, SymbolType);
146 
148  asset fund_reward_value = asset(0, SymbolType);
149 
151  asset from_children_payout_value = asset(0, SymbolType);
152 
154  asset to_parent_payout_value = asset(0, SymbolType);
155 };
156 
157 using comment_statistic_scr_object = comment_statistic_object<comment_statistic_scr_object_type, SCORUM_SYMBOL>;
158 using comment_statistic_sp_object = comment_statistic_object<comment_statistic_sp_object_type, SP_SYMBOL>;
159 
160 struct by_created;
161 struct by_cashout_time;
162 struct by_permlink;
163 struct by_root;
164 struct by_parent;
165 struct by_last_update;
166 struct by_author_created;
167 struct by_author_rewarded;
168 
169 typedef shared_multi_index_container<comment_object,
170  indexed_by<
172  ordered_unique<tag<by_id>,
173  member<comment_object, comment_id_type, &comment_object::id>>,
174  ordered_unique<tag<by_created>,
175  composite_key<comment_object,
176  member<comment_object,
177  time_point_sec,
178  &comment_object::created>,
179  member<comment_object,
181  &comment_object::id>>>,
182  ordered_unique<tag<by_cashout_time>,
183  composite_key<comment_object,
184  member<comment_object,
185  time_point_sec,
186  &comment_object::cashout_time>,
187  member<comment_object,
189  &comment_object::id>>>,
190  ordered_unique<tag<by_permlink>,
192  composite_key<comment_object,
193  member<comment_object,
195  &comment_object::author>,
196  member<comment_object,
197  fc::shared_string,
198  &comment_object::permlink>>,
199  composite_key_compare<std::less<account_name_type>,
200  fc::strcmp_less>>,
201  ordered_unique<tag<by_root>,
202  composite_key<comment_object,
203  member<comment_object,
205  &comment_object::root_comment>,
206  member<comment_object,
208  &comment_object::id>>>,
209  ordered_unique<tag<by_parent>,
211  composite_key<comment_object,
212  member<comment_object,
214  &comment_object::parent_author>,
215  member<comment_object,
216  fc::shared_string,
217  &comment_object::parent_permlink>,
218  member<comment_object,
220  &comment_object::id>>,
221  composite_key_compare<std::less<account_name_type>,
222  fc::strcmp_less,
223  std::less<comment_id_type>>>
225 #ifndef IS_LOW_MEM
226  ,
227  ordered_unique<tag<by_author_created>,
228  composite_key<comment_object,
229  member<comment_object,
231  &comment_object::author>,
232  member<comment_object,
233  time_point_sec,
234  &comment_object::created>,
235  member<comment_object,
237  &comment_object::id>>,
238  composite_key_compare<std::less<account_name_type>,
239  std::greater<time_point_sec>,
240  std::less<comment_id_type>>>,
241  ordered_unique<tag<by_author_rewarded>,
242  composite_key<comment_object,
243  member<comment_object,
245  &comment_object::author>,
246  member<comment_object,
247  bool,
248  &comment_object::rewarded>,
249  member<comment_object,
250  time_point_sec,
251  &comment_object::last_payout>,
252  member<comment_object,
254  &comment_object::id>>,
255  composite_key_compare<std::less<account_name_type>,
256  std::greater<bool>,
257  std::greater<time_point_sec>,
258  std::less<comment_id_type>>>
259 #endif
260  >>
261  comment_index;
262 
263 struct by_comment_voter;
264 struct by_voter_comment;
265 struct by_comment_weight_voter;
266 struct by_voter_last_update;
267 typedef shared_multi_index_container<comment_vote_object,
268  indexed_by<ordered_unique<tag<by_id>,
269  member<comment_vote_object,
271  &comment_vote_object::id>>,
272  ordered_unique<tag<by_comment_voter>,
273  composite_key<comment_vote_object,
274  member<comment_vote_object,
276  &comment_vote_object::comment>,
277  member<comment_vote_object,
279  &comment_vote_object::voter>>>,
280  ordered_unique<tag<by_voter_comment>,
281  composite_key<comment_vote_object,
282  member<comment_vote_object,
284  &comment_vote_object::voter>,
285  member<comment_vote_object,
287  &comment_vote_object::comment>>>,
288  ordered_unique<tag<by_voter_last_update>,
289  composite_key<comment_vote_object,
290  member<comment_vote_object,
292  &comment_vote_object::voter>,
293  member<comment_vote_object,
294  time_point_sec,
295  &comment_vote_object::last_update>,
296  member<comment_vote_object,
298  &comment_vote_object::comment>>,
299  composite_key_compare<std::less<account_id_type>,
300  std::greater<time_point_sec>,
301  std::less<comment_id_type>>>,
302  ordered_unique<tag<by_comment_weight_voter>,
303  composite_key<comment_vote_object,
304  member<comment_vote_object,
306  &comment_vote_object::comment>,
307  member<comment_vote_object,
308  uint64_t,
309  &comment_vote_object::weight>,
310  member<comment_vote_object,
312  &comment_vote_object::voter>>,
313  composite_key_compare<std::less<comment_id_type>,
314  std::greater<uint64_t>,
315  std::less<account_id_type>>>>>
316  comment_vote_index;
317 
318 struct by_comment_id;
319 
320 template <typename CommentStatisticObjectType>
321 using comment_statistic_index
322  = shared_multi_index_container<CommentStatisticObjectType,
323  indexed_by<ordered_unique<tag<by_id>,
324  member<CommentStatisticObjectType,
325  typename CommentStatisticObjectType::id_type,
326  &CommentStatisticObjectType::id>>,
327  ordered_unique<tag<by_comment_id>,
328  member<CommentStatisticObjectType,
330  &CommentStatisticObjectType::comment>>>>;
331 
332 using comment_statistic_scr_index = comment_statistic_index<comment_statistic_scr_object>;
333 using comment_statistic_sp_index = comment_statistic_index<comment_statistic_sp_object>;
334 
335 } // namespace chain
336 } // namespace scorum
337 
338 // clang-format off
339 
340 FC_REFLECT( scorum::chain::comment_object,
341  (id)
342  (author)
343  (permlink)
344  (category)
345  (parent_author)
346  (parent_permlink)
347  (title)
348  (body)
349  (json_metadata)
350  (last_update)
351  (created)
352  (active)
353  (last_payout)
354  (depth)
355  (children)
356  (net_rshares)
357  (abs_rshares)
358  (vote_rshares)
359  (children_abs_rshares)
360  (cashout_time)
361  (total_vote_weight)
362  (net_votes)
363  (root_comment)
364  (max_accepted_payout)
365  (allow_replies)
366  (allow_votes)
367  (allow_curation_rewards)
368  (beneficiaries)
369  (rewarded)
370  )
371 CHAINBASE_SET_INDEX_TYPE( scorum::chain::comment_object, scorum::chain::comment_index )
372 
373 FC_REFLECT( scorum::chain::comment_vote_object,
374  (id)
375  (voter)
376  (comment)
377  (weight)
378  (rshares)
379  (vote_percent)
380  (last_update)
381  (num_changes)
382  )
383 CHAINBASE_SET_INDEX_TYPE( scorum::chain::comment_vote_object, scorum::chain::comment_vote_index )
384 
385 FC_REFLECT( scorum::chain::comment_statistic_scr_object,
386  (id)
387  (comment)
388  (total_payout_value)
389  (author_payout_value)
390  (curator_payout_value)
391  (beneficiary_payout_value)
392  (fund_reward_value)
393  (from_children_payout_value)
394  (to_parent_payout_value)
395  )
396 CHAINBASE_SET_INDEX_TYPE( scorum::chain::comment_statistic_scr_object, scorum::chain::comment_statistic_scr_index )
397 
398 FC_REFLECT( scorum::chain::comment_statistic_sp_object,
399  (id)
400  (comment)
401  (total_payout_value)
402  (author_payout_value)
403  (curator_payout_value)
404  (beneficiary_payout_value)
405  (fund_reward_value)
406  (from_children_payout_value)
407  (to_parent_payout_value)
408  )
409 CHAINBASE_SET_INDEX_TYPE( scorum::chain::comment_statistic_sp_object, scorum::chain::comment_statistic_sp_index )
410 
411 // clang-format on
#define SCORUM_SYMBOL
Definition: config.hpp:102
FC_REFLECT(appender_args,(appender)(stream)) FC_REFLECT_DERIVED(file_appender_args
oid< comment_object > comment_id_type
oid< account_object > account_id_type
oid< comment_vote_object > comment_vote_id_type
fc::safe< share_value_type > share_type
Definition: types.hpp:73
fc::fixed_string_16 account_name_type
Definition: types.hpp:62
int16_t vote_weight_type
Definition: types.hpp:70
Definition: asset.cpp:15
static asset maximum(asset_symbol_type id)
Definition: asset.hpp:37