ManaPlus
Public Member Functions | Protected Attributes
UpdateListModel Class Reference

#include <updatelistmodel.h>

Inheritance diagram for UpdateListModel:
ListModel

Public Member Functions

 UpdateListModel (ServerInfo *const server)
 
int getNumberOfElements ()
 
std::string getElementAt (int i)
 
bool empty () const
 
- Public Member Functions inherited from ListModel
 ListModel ()
 
virtual ~ListModel ()
 

Protected Attributes

StringVect mNames
 
ServerInfomServer
 

Detailed Description

Definition at line 36 of file updatelistmodel.h.

Constructor & Destructor Documentation

◆ UpdateListModel()

UpdateListModel::UpdateListModel ( ServerInfo *const  server)
inlineexplicit

Definition at line 39 of file updatelistmodel.h.

39  :
40  ListModel(),
41  mNames(),
42  mServer(server)
43  {
44  FOR_EACH(STD_VECTOR<HostsGroup>::const_iterator,
45  it,
46  server->updateHosts)
47  {
48  const HostsGroup &group = *it;
49  mNames.push_back(group.name);
50  }
51  }
ListModel()
Definition: listmodel.h:82
std::vector< HostsGroup > updateHosts
Definition: serverinfo.h:54
StringVect mNames
ServerInfo * mServer
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25
std::string name
Definition: hostsgroup.h:39

References FOR_EACH, mNames, HostsGroup::name, and ServerInfo::updateHosts.

Member Function Documentation

◆ empty()

bool UpdateListModel::empty ( ) const
inline

Definition at line 67 of file updatelistmodel.h.

68  {
69  return mNames.empty();
70  }

References mNames.

◆ getElementAt()

std::string UpdateListModel::getElementAt ( int  i)
inlinevirtual

Gets an element at a certain index in the list.

Parameters
iAn index in the list.
Returns
An element as a string at the a certain index.

Implements ListModel.

Definition at line 60 of file updatelistmodel.h.

61  {
62  if (i >= getNumberOfElements() || i < 0)
63  return "???";
64  return mNames[i];
65  }

References getNumberOfElements(), and mNames.

◆ getNumberOfElements()

int UpdateListModel::getNumberOfElements ( )
inlinevirtual

Gets the number of elements in the list.

Returns
The number of elements in the list

Implements ListModel.

Definition at line 55 of file updatelistmodel.h.

56  {
57  return CAST_S32(mNames.size());
58  }
#define CAST_S32
Definition: cast.h:30

References CAST_S32, and mNames.

Referenced by getElementAt().

Field Documentation

◆ mNames

StringVect UpdateListModel::mNames
protected

Definition at line 73 of file updatelistmodel.h.

Referenced by empty(), getElementAt(), getNumberOfElements(), and UpdateListModel().

◆ mServer

ServerInfo* UpdateListModel::mServer
protected

Definition at line 74 of file updatelistmodel.h.


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