Sokoban
Public Member Functions | Private Attributes | Friends | List of all members
User Class Reference

Represents the user especially his progress in map packs. More...

#include <User.h>

Public Member Functions

 User (const std::string &p_name)
 Constructor. More...
 
int get_progress (const std::string &m_name)
 Gets progres for map pack of user which is determined by his name. More...
 
void set_progress (const std::string &m_name, int lvl)
 Update progress for user and map pack if input parameter representing number of finished level is higher then current progress. More...
 
const std::string & get_name () const
 Gets name of the user which is represented by the instance of this class. More...
 

Private Attributes

std::string name
 
std::map< std::string, int > progress
 

Friends

std::ostream & operator<< (std::ostream &stream, const User &user)
 Operator <<. More...
 
bool operator< (const User &left_u, const User &right_u)
 Operator <. More...
 
bool operator== (const User &left_u, const User &right_u)
 Operator ==. More...
 

Detailed Description

Represents the user especially his progress in map packs.

Constructor & Destructor Documentation

◆ User()

User::User ( const std::string &  p_name)
inline

Constructor.

Creates an instance from user's name.

Parameters
p_nameName of user.

Member Function Documentation

◆ get_name()

const std::string& User::get_name ( ) const
inline

Gets name of the user which is represented by the instance of this class.

Returns
Name of the user.

◆ get_progress()

int User::get_progress ( const std::string &  m_name)
inline

Gets progres for map pack of user which is determined by his name.

Returns
Number of finished maps in map pack.

◆ set_progress()

void User::set_progress ( const std::string &  m_name,
int  lvl 
)
inline

Update progress for user and map pack if input parameter representing number of finished level is higher then current progress.

Parameters
m_nameName of the map pack.
lvlFinished level.

Friends And Related Function Documentation

◆ operator<

bool operator< ( const User left_u,
const User right_u 
)
friend

Operator <.

Compare two users according to their names.

Parameters
left_uLeft operand.
right_uRight operand.
Returns
Bool variable representing if left operand is less then the right.

◆ operator<<

std::ostream& operator<< ( std::ostream &  stream,
const User user 
)
friend

Operator <<.

Writes information about user's progress.

Parameters
streamOutput stream.
userUser whose progress should be written.

◆ operator==

bool operator== ( const User left_u,
const User right_u 
)
friend

Operator ==.

Parameters
left_uLeft operand.
right_uRight operand.
Returns
Bool variable representing if left operand is qeual to the right.

Member Data Documentation

◆ name

std::string User::name
private

name of user

◆ progress

std::map<std::string, int> User::progress
private

map of "map pack name" and user's progress in this pack


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