winix/core/lastcontainer.h

83 lines
1.3 KiB
C++
Executable File

/*
* This file is a part of CMSLU -- Content Management System like Unix
* and is not publicly distributed
*
* Copyright (c) 2009, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfilelastcontainer33
#define headerfilelastcontainer33
#include <string>
#include <list>
#include <cstring>
#include <ctime>
#include "log.h"
// how many items we store in the 'last' function
#define LAST_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::string name;
// ip address
unsigned int ip;
// session id (used when logging out)
long session_id;
// start logging and end logging
tm start;
tm end;
LastItem();
bool IsLoggedOut();
};
class LastContainer
{
public:
typedef std::list<LastItem> LastTab;
typedef LastTab::iterator Iterator;
public:
// !! nie potrzebny, skasowac po stworzeniu jednej biblioteki cmslu.a
// chwilowo bez tego wystepuja problemy z linkowaniem
LastContainer();
Iterator Begin();
Iterator End();
void UserLogin(long user_id, const std::string & 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);
};
#endif