Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ONE::gui::ListModel Class Reference

Inheritance diagram for ONE::gui::ListModel:

Inheritance graph
[legend]
List of all members.

Detailed Description

model that holds a number of string s.

The model's size may be bounded via the ListModel::setMaximumCapacity function. The oldest entry is discarded when the bound is reached.
All modifying operations defined for the model notify the registered listeners of the change.

Author:
Daniel Seibert


Public Types

typedef Data::size_type index
typedef ListModelListenerLPtr

Public Member Functions

void add (const std::string &s)
 adds an item to the model
void addListModelListener (const LPtr &l)
void clear ()
 removes all items from the model
 EventDispatcher ()
void fireEvent (ListModelEvent &e) const
 notifies all registered listeners
const std::string & get (const index &pos) const
 retrieves an item from the model
index getMaximumCapacity () const
 retrieves the current maximum capacity
index getSize () const
 accesses the number of items in the model
index indexOf (const std::string &s) const
 searches the model for s
bool isEmpty () const
 checks if this model is empty
bool isMuted () const
 reflects this dispatcher's muted state.
 ListModel (const index &cap=UNBOUNDED)
 creates a model with an optional size limit.
void remove (const index &pos)
 removes an entry from the model
void removeListModelListener (const LPtr &l)
void setMaximumCapacity (const index &cap)
 changes the maximum capacity
void setMuted (bool mute)
 mutes or un-mutes the dispatcher

Static Public Attributes

static const index INVALID
 invalid index constant
static const index UNBOUNDED
 constant for a (quasi) unlimited number of entries

Protected Member Functions

void add (const LPtr &l)
 registers a listener
void remove (const LPtr &l)
 de-registers a listener.


Member Typedef Documentation

typedef Data::size_type ONE::gui::ListModel::index
 

typedef ListModelListener * ONE::util::EventDispatcher< ListModelEvent , ListModelListener , struct ListModelRelay >::LPtr [inherited]
 


Constructor & Destructor Documentation

ONE::gui::ListModel::ListModel const index cap = UNBOUNDED  ) 
 

creates a model with an optional size limit.

The default maximum capacity i UNBOUNDED for an unlimited number of entries.

Parameters:
cap the maximum capacity


Member Function Documentation

void ONE::util::EventDispatcher< ListModelEvent , ListModelListener , struct ListModelRelay >::add const LPtr l  )  [protected, inherited]
 

registers a listener

Parameters:
l a listener

void ONE::gui::ListModel::add const std::string &  s  ) 
 

adds an item to the model

If s contains line breaks, it is added as separate entries. If the maximum capacity is reached, the oldest entries will be discarded.

Parameters:
s the item

void ONE::gui::ListModelDispatcher::addListModelListener const LPtr l  )  [inline, inherited]
 

void ONE::gui::ListModel::clear  ) 
 

removes all items from the model

ONE::util::EventDispatcher< ListModelEvent , ListModelListener , struct ListModelRelay >::EventDispatcher  )  [inherited]
 

void ONE::util::EventDispatcher< ListModelEvent , ListModelListener , struct ListModelRelay >::fireEvent ListModelEvent &  e  )  const [inherited]
 

notifies all registered listeners

The listeners are called in the order in which they were added.
This function is provided primarily for use by subclasses. However, it may also be called from the outside in order to inject events into the system. Note that great care should be taken when doing so. For example, listeners generally rely on the event's source being identical to the instance that passes them around, i.e. this event dispatcher.

Parameters:
e the event to forward to each listener

const std::string& ONE::gui::ListModel::get const index pos  )  const
 

retrieves an item from the model

Note that pos is unchecked and that an invalid index will result in undefined behavior.

Parameters:
pos a valid index
Returns:
the item located at pos

index ONE::gui::ListModel::getMaximumCapacity  )  const
 

retrieves the current maximum capacity

index ONE::gui::ListModel::getSize  )  const
 

accesses the number of items in the model

index ONE::gui::ListModel::indexOf const std::string &  s  )  const
 

searches the model for s

Returns:
the index of the first item equal to s or INVALID if no such entry can be found

bool ONE::gui::ListModel::isEmpty  )  const
 

checks if this model is empty

bool ONE::util::EventDispatcher< ListModelEvent , ListModelListener , struct ListModelRelay >::isMuted  )  const [inherited]
 

reflects this dispatcher's muted state.

Returns:
true if the dispatcher is muted, false otherwise

void ONE::util::EventDispatcher< ListModelEvent , ListModelListener , struct ListModelRelay >::remove const LPtr l  )  [protected, inherited]
 

de-registers a listener.

This listener will no longer notify l of events, unless l is registered more than once. If so, a call to this function will only remove the first occurence of l.

Parameters:
l a listener

void ONE::gui::ListModel::remove const index pos  ) 
 

removes an entry from the model

Note that pos is unchecked and that an invalid index will result in undefined behavior.

Parameters:
pos the index for the item to be removed

void ONE::gui::ListModelDispatcher::removeListModelListener const LPtr l  )  [inline, inherited]
 

void ONE::gui::ListModel::setMaximumCapacity const index cap  ) 
 

changes the maximum capacity

If cap is smaller than the current maximum, the oldest items will be discarded until a size of cap is reached.

Parameters:
cap the new capacity

void ONE::util::EventDispatcher< ListModelEvent , ListModelListener , struct ListModelRelay >::setMuted bool  mute  )  [inherited]
 

mutes or un-mutes the dispatcher

Muted dispatchers no longer notify their listeners.


Member Data Documentation

const index ONE::gui::ListModel::INVALID [static]
 

invalid index constant

const index ONE::gui::ListModel::UNBOUNDED [static]
 

constant for a (quasi) unlimited number of entries


Generated on Wed Sep 7 19:03:18 2005 for ONEngine by  doxygen 1.4.3