winix/core/lastcontainer.h

88 lines
1.2 KiB
C++
Executable File

/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2009-2014, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfile_winix_core_lastcontainer
#define headerfile_winix_core_lastcontainer
#include <string>
#include <list>
#include <cstring>
#include <ctime>
#include "date/date.h"
namespace Winix
{
// how many items we store in the 'last' function
#define WINIX_LASTCONTAINER_TABLE_SIZE 100
struct LastItem
{
long user_id;
// additional we store the whole string-name
// (you can delete a user from the database but we can still print the name)
std::wstring name;
// ip address
unsigned int ip;
// session id (used when logging out)
long session_id;
// start logging and end logging
PT::Date start;
PT::Date end;
LastItem();
bool IsLoggedOut();
};
class LastContainer
{
public:
typedef std::list<LastItem> LastTab;
typedef LastTab::iterator Iterator;
public:
Iterator Begin();
Iterator End();
void UserLogin(long user_id, const std::wstring & name, unsigned int ip, long session_id);
void UserLogout(long user_id, long session_id);
private:
LastTab last_tab;
Iterator FindNotLoggedOut(long user_id, long session_id);
};
} // namespace Winix
#endif