|
#ifndef _HIGHSCOREMANAGAR_H
#define _HIGHSCOREMANAGAR_H
#pragma once
// Includes
#include <vector>
#include "events.h"
#include "tsingleton.h"
#include "highscoreentry.h"
// Event and Vector definitions
typedef Event<void, long> HighscoreEvent;
typedef vector<CHighscoreEntry> HighscoreVector;
typedef HighscoreVector::iterator HighscoreVectorIterator;
typedef HighscoreVector::reverse_iterator HighscoreVectorRevereseIterator;
using namespace std;
///////////////////////////////////////////////////////////////////////////////////
// Class CHighscoreManager
// is a class that manages highscores. Creates, deletes and inform others
// through events of creation and deletion.
//
// Author: Asa Meltzer
// Date: 07/2007
class CHighscoreManager
{
public:
// Globals
const static int MAX_SCORES = 10;
// Construction
CHighscoreManager();
virtual ~CHighscoreManager();
// Operations
void CreateHighscore(const CString& strName, long lScore, long lTime = -1, bool bRaisEvent = true);
void DeleteHighscore(const CString& strName, long lScore);
void DeleteHighscore(UINT nIndex);
void DeleteAll(bool bRaiseEvent = true);
// Access
const HighscoreVector& GetHighscoreArray() const;
// events
HighscoreEvent OnHighscoreCreatedEvent;
HighscoreEvent OnNotHighscoreEvent;
HighscoreEvent OnHighscoreDeletedEvent;
private:
// variables
HighscoreVector m_vecHighscores;
};
typedef TSingleton<CHighscoreManager> STHighscoreManager;
// Inline Access
// this will copy the vector
inline const HighscoreVector& CHighscoreManager::GetHighscoreArray() const
{
return m_vecHighscores;
}
#endif
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Software designer and programmer.
Programming languages:
MFC, C++, Java , C#, VB and sometimes C and assembly.