2 #include <eris/WrappedPositional.hpp> 3 #include <eris/good/Discrete.hpp> 6 #include <eris/random/truncated_normal_distribution.hpp> 33 class Book final :
public eris::WrappedPositional<eris::good::Discrete> {
52 unsigned int order,
double quality);
55 eris::eris_time_t
age()
const;
60 const eris::eris_time_t&
created()
const;
93 const unsigned int&
order()
const;
101 void added()
override;
113 void weakDepRemoved(eris::SharedMember<eris::Member>, eris::eris_id_t old)
override;
122 eris::SharedMember<Reader>
author()
const;
143 eris::SharedMember<BookMarket>
market()
const;
148 double price()
const;
165 unsigned int sales(eris::eris_time_t t)
const;
179 unsigned int pirated(eris::eris_time_t t)
const;
205 double revenue(eris::eris_time_t t)
const;
211 double prize(eris::eris_time_t t)
const;
221 uint32_t
votes(eris::eris_time_t t)
const;
228 unsigned int copies()
const;
249 void recordSale(
unsigned int new_sales,
double new_revenue);
264 void vote(uint32_t count);
284 eris::eris_time_t created_ = 0, left_private_market_ = 0, public_market_created_ = 0;
285 uint32_t copies_private_total_ = 0, copies_pirated_total_ = 0, copies_public_total_ = 0,
287 double revenue_private_total_ = 0, revenue_public_total_ = 0, prize_total_ = 0;
288 std::map<eris::eris_time_t, uint32_t> copies_sold_, copies_pirated_, votes_;
289 std::map<eris::eris_time_t, double> revenue_, prize_;
290 eris::SharedMember<Reader> author_;
291 const unsigned int order_ = 0;
292 bool market_private_ =
true;
293 eris::eris_id_t market_id_ = 0;
294 eris::random::truncated_normal_distribution<double> quality_dist_;
bool hasAnyMarket() const
Returns true if this book is currently on the market, false if there is no associated market for this...
double currRevenue() const
Returns the revenue of this book so far in the current period.
double lifeRevenue() const
Returns the lifelong revenue (from both private and public markets) of this book. ...
double lifeRevenuePublic() const
Returns the lifelong public revenue of this book.
double qualityMean() const
Returns the mean quality level determined by the author at book creation time.
double lifePrize() const
Returns the lifetime prize money earned by the author for this book.
const eris::eris_time_t & publicMarketCreated() const
Returns the simulation period in which the book was first placed on the public market or 0 if the boo...
eris::SharedMember< Reader > author() const
Returns the author who created this Book.
Primary namespace for all Creativity library code.
Definition: config.hpp:4
void recordPiracy(unsigned int new_copies)
Increase the number of pirated copies of this book for the current period.
double lifeRevenuePrivate() const
Returns the lifelong private market revenue of this book.
uint32_t lifeVotes() const
Returns the lifetime number of votes for this book.
unsigned int currPirated() const
Returns the number of pirated copies of this book so far in the current period.
bool hasPublicMarket() const
True if the book is currently on the public market.
bool hasPrivateMarket() const
Returns true if this book's current market exists and is a private market, that is, on the market as controlled by the book's author.
eris::eris_time_t age() const
Returns the age of the book, in simulation periods.
double currPrize() const
Returns the prize money earned by the author for this book in the current period. ...
unsigned int queryCopies() const
Queries the simulation for the number of copies of this book in existence.
unsigned int sales(eris::eris_time_t t) const
Returns the number of sales in simulation period t.
unsigned int privateMarketPeriods() const
Returns the number of periods the book has been (or was) available on the private market...
unsigned int lifePirated() const
Returns the lifelong number of pirated copies of this book.
uint32_t votes(eris::eris_time_t t) const
Returns the number of votes for this book in the simulation period t
const eris::eris_time_t & created() const
Returns the simulation period in which the book became available (i.e.
bool livingAuthor() const
Returns true if this Book's author is still in the simulation, false otherwise.
unsigned int copies() const
Returns lifeSales() + lifePirated() (but atomically), reflecting the number of copies of the book tha...
unsigned int lifeSalesPublic() const
Returns the lifelong number of public market sales of this book.
void added() override
When the Book is added to the simulation it also creates an associated BookMarket object that handles...
void setMarket(eris::SharedMember< BookMarket > market)
Sets a new market for this book.
double lifeProfitPrivate() const
Calculates the lifetime profit of this book from the private market, not including initial creation c...
unsigned int currSales() const
Returns the number of sales of this book so far in the current period.
const eris::eris_time_t & leftPrivateMarket() const
Returns the first simulation period in which the book was no longer on the private market...
unsigned int lifeSales() const
Returns the lifelong number of sales (on both private and public markets) of this book...
uint32_t currVotes() const
Returns the number of votes for this book in the current period.
eris::SharedMember< BookMarket > market() const
Returns the BookMarket that sells this Book (which could be a PublicBookMarket if hasPublicMarket() i...
Class representing a particular book.
Definition: Book.hpp:33
double prize(eris::eris_time_t t) const
Returns the prize money earned by the author for this book in simulation period t ...
double revenue(eris::eris_time_t t) const
Returns the revenue earned by this book in simulation period t
void weakDepRemoved(eris::SharedMember< eris::Member >, eris::eris_id_t old) override
When the market is removed from the simulation, record it by clearing the stored market.
Central class for a creativity simulation; this class handles setting up the simulation according to ...
Definition: Creativity.hpp:22
const unsigned int & order() const
Returns the order of this book in the author's set of books.
double qualityDraw()
Draws a quality value for this book.
void vote(uint32_t count)
Called by a reader to cast one or more votes for this book, when under the public sharing with votes ...
void recordSale(unsigned int new_sales, double new_revenue)
Increase the sales and revenue of this book for the current period.
void recordPrize(double prize)
Record public money received by the author for this book.
eris::eris_time_t lastSale() const
Returns the last simulation period t in which this book had at least one sale, or 0 if this book has ...
unsigned int pirated(eris::eris_time_t t) const
Returns the number of pirated copies in simulation period t
unsigned int lifeSalesPrivate() const
Returns the lifelong number of private market sales of this book.
Book()=delete
Not default constructible.
double price() const
Returns the current market price of this book.