creativity  v1.3.0
Agent-based model of creativity and piracy
BookState.hpp
1 #pragma once
2 #include <eris/Position.hpp>
3 #include <eris/SharedMember.hpp>
4 #include <cmath>
5 
6 namespace creativity {
7 class Book; // forward declaration
8 namespace state {
9 
12 class BookState final {
13  public:
15  BookState(const eris::SharedMember<Book> &b);
16 
18  BookState(const Book &b);
19 
24  explicit BookState(const unsigned int dimensions);
25 
27  eris::eris_id_t id;
28 
30  eris::eris_id_t author;
31 
33  eris::Position position;
34 
36  double quality;
37 
42  bool market_any() const { return not std::isnan(price); }
43 
48 
50  bool market_public() const { return market_any() and not market_private; }
51 
53  double price;
54 
56  double revenue;
57 
60 
62  double prize;
63 
66 
70  uint32_t sales;
71 
74 
77 
81  uint32_t sales_lifetime() const { return sales_lifetime_private + sales_lifetime_public; }
82 
84  uint32_t pirated;
85 
87  uint32_t pirated_lifetime;
88 
92  uint32_t copies() const { return pirated + sales; }
93 
97  uint32_t copies_lifetime() const { return pirated_lifetime + sales_lifetime_private + sales_lifetime_public; }
98 
100  eris::eris_time_t created;
101 
107 
109  uint32_t votes;
110 
112  uint32_t votes_lifetime;
113 };
114 
115 }}
eris::eris_time_t created
The period in which this book ws created. Directly related to age.
Definition: BookState.hpp:100
double quality
The quality parameter of this book, which is the mean of reader quality draws.
Definition: BookState.hpp:36
double prize_lifetime
The lifetime public/prize money received by the book&#39;s author for this book.
Definition: BookState.hpp:65
uint32_t sales_lifetime_public
The cumulative lifetime public market sales of this book, up to and including the current period...
Definition: BookState.hpp:76
bool market_private
True if this book is on the private market, false if on the public market or not on the market at all...
Definition: BookState.hpp:47
BookState(const eris::SharedMember< Book > &b)
Constructs a new BookState, setting its values using the given Book member.
Primary namespace for all Creativity library code.
Definition: config.hpp:4
uint32_t lifetime_private
The number of periods this book was (or has been) on the private market.
Definition: BookState.hpp:106
eris::eris_id_t id
Unique simulation ID of the book.
Definition: BookState.hpp:27
double revenue_lifetime
The cumulative lifetime private market revenue of this book, up to and including the current period...
Definition: BookState.hpp:59
double revenue
The private market revenue of this book this period.
Definition: BookState.hpp:56
uint32_t sales_lifetime_private
The cumulative lifetime private market sales of this book, up to and including the current period...
Definition: BookState.hpp:73
uint32_t copies() const
Returns the number of new copies created in the current period.
Definition: BookState.hpp:92
bool market_any() const
Returns true if this book was on either the private or public market this period, false if not...
Definition: BookState.hpp:42
uint32_t votes_lifetime
The lifetime number of votes the book has received.
Definition: BookState.hpp:112
uint32_t sales
The number of sales of copies of this book in the current period.
Definition: BookState.hpp:70
eris::eris_id_t author
The author of this book.
Definition: BookState.hpp:30
Class representing a particular book.
Definition: Book.hpp:33
bool market_public() const
Returns true if this book is on the public market this period.
Definition: BookState.hpp:50
uint32_t pirated_lifetime
The cumulative lifetime pirated copies of the book, up to and including the current period...
Definition: BookState.hpp:87
uint32_t pirated
The number of pirated copies of this book in the current period.
Definition: BookState.hpp:84
double prize
The public/prize money received by the book&#39;s author this period for this book.
Definition: BookState.hpp:62
eris::Position position
Position of the book.
Definition: BookState.hpp:33
uint32_t votes
The number of votes the book received this period.
Definition: BookState.hpp:109
uint32_t sales_lifetime() const
Returns the cumulative lifetime sales of this book, up to and including the current period...
Definition: BookState.hpp:81
double price
The market price of this book; will be NaN if this book was not on the market.
Definition: BookState.hpp:53
uint32_t copies_lifetime() const
Returns the cumulative lifetime copies of the book, up to and including the current period...
Definition: BookState.hpp:97
Records the various variables associated with a book.
Definition: BookState.hpp:12