added: container LastContainer (lastcontainer.h lastcontainer.cpp)
it consists of last logged users added: function 'last' git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@492 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
82
core/lastcontainer.h
Executable file
82
core/lastcontainer.h
Executable file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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
|
Reference in New Issue
Block a user