creativity  v1.3.0
Agent-based model of creativity and piracy
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
creativity::gui::BookStore Class Reference

Gtk::TreeModel::ColumnRecord subclass for handling Book information in the list of books in the main GUI window, and the list of authored books on the reader dialog. More...

#include <creativity/gui/BookStore.hpp>

Classes

class  ColRec
 ColumnRecord object for a BookStore. More...
 

Public Member Functions

virtual void appendColumnsTo (Gtk::TreeView &v) const override
 Takes a Gtk::TreeView and adds this object's columns to it. More...
 
- Public Member Functions inherited from creativity::gui::MemberStore< state::BookState >
const state::BookStatemember (const Path &path) const
 Gets the M Member from a Path. More...
 
const state::BookStatemember (const iterator &iter) const
 Gets the M Member from an iterator. More...
 
Path find (eris::eris_id_t id, size_t hint=0) const
 Returns the Path to the member with the given id. More...
 
Path find (eris::eris_id_t id, const iterator &iter) const
 Returns the Path to the member with the given id. More...
 
Path find (eris::eris_id_t id, const Path &hint) const
 Returns the Path to the member with the given id. More...
 

Static Public Member Functions

static Glib::RefPtr< BookStorecreate (std::shared_ptr< const state::State > state, eris::eris_id_t author=0)
 Interface class between a simulation's Books and a Gtk::TreeView. More...
 

Public Attributes

std::unique_ptr< ColReccolumns {new ColRec}
 The columns of this BookStore. More...
 

Protected Member Functions

 BookStore (std::shared_ptr< const state::State > &&state, eris::eris_id_t author)
 Protected constructor; this object should be constructed using create().
 
 BookStore (std::shared_ptr< const state::State > &&state, eris::eris_id_t author, std::unique_ptr< ColRec > &&cols)
 Protected constructor that overrides the default set of columns (for use by subclasses).
 
 BookStore (std::shared_ptr< const state::State > &&state, std::unique_ptr< ColRec > &&cols)
 Protected constructor that overrides the default set of columns but has no author parameter at all: members_ will not be populated (but should be populated by the subclass).
 
void initializeBooks ()
 Called during construction to populated members_ with either all books (if the author constructor parameter is 0) or an author's written books (if the author constructor parameter is non-zero). More...
 
virtual int get_n_columns_vfunc () const override
 Returns obj.columns->size(), the number of book model columns. More...
 
virtual GType get_column_type_vfunc (int index) const override
 Returns the column type of the given position. More...
 
virtual void get_value_vfunc (const iterator &iter, int column, Glib::ValueBase &value) const override
 Accesses a column value. More...
 
virtual void set_sort_column_id_vfunc (int sort_column_id, Gtk::SortType order) override
 Sets the model sort column and sort order. More...
 
- Protected Member Functions inherited from creativity::gui::MemberStore< state::BookState >
 MemberStore (std::shared_ptr< const state::State > &&state)
 Protected constructor; this object should be constructed from a subclass, typically via the subclass's static create() method. More...
 
virtual Gtk::TreeModelFlags get_flags_vfunc () const override
 Returns Gtk::TreeModel flags (specifically, the LIST_ONLY flag). More...
 
virtual bool get_iter_vfunc (const Path &path, iterator &iter) const override
 Converts a path to an iterator. More...
 
virtual bool iter_next_vfunc (const iterator &iter, iterator &iter_next) const override
 Takes an iterator, returns an iterator to the next item. More...
 
virtual bool iter_children_vfunc (const iterator &, iterator &) const override
 Returns false always: MemberStore elements cannot have children.
 
virtual bool iter_parent_vfunc (const iterator &, iterator &) const override
 Returns false always: MemberStore elemenets cannot have children/parents.
 
virtual bool iter_nth_child_vfunc (const iterator &, int, iterator &) const override
 Returns false always: MemberStore elements cannot have children.
 
virtual bool iter_has_child_vfunc (const iterator &) const override
 Returns false always: MemberStore elements cannot have children.
 
virtual int iter_n_children_vfunc (const iterator &) const override
 Returns 0 always: MemberStore elements have no children.
 
virtual bool iter_nth_root_child_vfunc (int n, iterator &iter) const override
 Obtains an iterator to the nth reader. More...
 
virtual int iter_n_root_children_vfunc () const override
 Returns the number of readers stored in this model.
 
virtual Path get_path_vfunc (const iterator &iter) const override
 Converts iterator iter into a Path.
 
virtual bool get_sort_column_id_vfunc (int *sort_column_id, Gtk::SortType *order) const override
 Accesses the current sort column and order. More...
 
virtual void sort_members (std::function< bool(const state::BookState &a, const state::BookState &b)> &compare, int sort_column_id, Gtk::SortType order)
 Called by subclasses, typically in set_sort_column_id_vfunc, to resort the current list of members using the given function. More...
 
void appendCol (Gtk::TreeView &v, const std::string &label, T &col, int width, bool sortable=true) const
 Appends a single column to the given view using the given label, width, and sortability. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from creativity::gui::MemberStore< state::BookState >
static void copy_value_ (Glib::ValueBase &valueobj, const T &val)
 Helper method for the crap needed in get_value_vfunc(): creates a Glib::Value of the right type and copies it into the given Glib::ValueBase. More...
 
- Protected Attributes inherited from creativity::gui::MemberStore< state::BookState >
const std::shared_ptr< const state::Statestate_
 The state this MemberStore represents.
 
std::vector< std::reference_wrapper< const state::BookState > > members_
 The vector of members. Subclasses need to add all member references to this vector.
 
int stamp_
 Tracks model changes by being incremented whenever such a change occurs.
 

Detailed Description

Gtk::TreeModel::ColumnRecord subclass for handling Book information in the list of books in the main GUI window, and the list of authored books on the reader dialog.

Member Function Documentation

§ appendColumnsTo()

virtual void creativity::gui::BookStore::appendColumnsTo ( Gtk::TreeView &  v) const
overridevirtual

Takes a Gtk::TreeView and adds this object's columns to it.

Implements creativity::gui::MemberStore< state::BookState >.

Reimplemented in creativity::gui::LibraryStore.

§ create()

static Glib::RefPtr<BookStore> creativity::gui::BookStore::create ( std::shared_ptr< const state::State state,
eris::eris_id_t  author = 0 
)
static

Interface class between a simulation's Books and a Gtk::TreeView.

This internally stores a vector of Books which can be updated (if needed) by calling the update method.

This exposes the following columns:

  • ID
  • author ID
  • x position
  • y position
  • position string (made from x position and y position)
  • quality (reader-perceived quality may diff)
  • price (NaN if not on market)
  • revenue
  • revenue_lifetime
  • market_private (true if on private market, false otherwise)
  • market_public (true if on public market, false otherwise)
  • market_any (true if on any market, false otherwise)
  • market_str (string: "Priv.", "Pub.", or "No")
  • age (in simulation periods)
  • creation date (i.e. simulation period)
  • current sales
  • lifetime private sales
  • lifetime public sales
  • lifetime sales (private + public)
  • current pirated copies
  • lifetime pirated copies
  • lifetime copies (= lifetime pirated copies + lifetime sales)
  • lifetime (# periods on market)
Parameters
statethe simulation state object containing the books to list
authorthe author whose books to list. Omit or set to 0 to list all books.

§ get_column_type_vfunc()

virtual GType creativity::gui::BookStore::get_column_type_vfunc ( int  index) const
overrideprotectedvirtual

Returns the column type of the given position.

See the list of virtual columns in the class description.

See also
BookStore::ColRec

Implements creativity::gui::MemberStore< state::BookState >.

§ get_n_columns_vfunc()

virtual int creativity::gui::BookStore::get_n_columns_vfunc ( ) const
overrideprotectedvirtual

Returns obj.columns->size(), the number of book model columns.

Implements creativity::gui::MemberStore< state::BookState >.

§ get_value_vfunc()

virtual void creativity::gui::BookStore::get_value_vfunc ( const iterator &  iter,
int  column,
Glib::ValueBase &  value 
) const
overrideprotectedvirtual

Accesses a column value.

Parameters
itera valid iterator referencing the row to access
columnthe index of the column to access
valuea Glib::Value<TYPE> object (where TYPE is the appropriate type for the requested column) in which to store the value.

Implements creativity::gui::MemberStore< state::BookState >.

Reimplemented in creativity::gui::LibraryStore.

§ initializeBooks()

void creativity::gui::BookStore::initializeBooks ( )
protected

Called during construction to populated members_ with either all books (if the author constructor parameter is 0) or an author's written books (if the author constructor parameter is non-zero).

This is not called in the subclass constructor that has no author parameter (explicit or implicit) at all.

§ set_sort_column_id_vfunc()

virtual void creativity::gui::BookStore::set_sort_column_id_vfunc ( int  sort_column_id,
Gtk::SortType  order 
)
overrideprotectedvirtual

Sets the model sort column and sort order.

If the sort_column and order differ from the current values, the model data is resorted. If resorting occurs, the sort_column_changed and rows_reordered signals will fire.

This uses a stable sort: elements that are equal under the new sort column will preserve their current ordering. Note that this means that sorting by the current column but in the opposite order will not reverse the ordering of equal-value elements.

Parameters
sort_column_idthe index of the new sort column
orderthe new sort order (Gtk::SORT_ASCENDING or Gtk::SORT_DESCENDING).

Implements creativity::gui::MemberStore< state::BookState >.

Reimplemented in creativity::gui::LibraryStore.

Member Data Documentation

§ columns

std::unique_ptr<ColRec> creativity::gui::BookStore::columns {new ColRec}

The columns of this BookStore.

For example, to access the price column, use bookstore.columns->price.

Inheritance diagram for creativity::gui::BookStore:
[legend]
Collaboration diagram for creativity::gui::BookStore:
[legend]

The documentation for this class was generated from the following file: