import the first version of cmslu
git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@460 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
73
core/session.cpp
Executable file
73
core/session.cpp
Executable file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* This file is a part of CMSLU -- Content Management System like Unix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2008, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "session.h"
|
||||
|
||||
|
||||
Session::Session()
|
||||
{
|
||||
Clear();
|
||||
|
||||
time = std::time(0);
|
||||
}
|
||||
|
||||
|
||||
void Session::Clear()
|
||||
{
|
||||
id = 0;
|
||||
time = 0;
|
||||
is_logged = false;
|
||||
user_id = 0;
|
||||
user.clear();
|
||||
done = Done::none;
|
||||
done_status = Error::ok;
|
||||
item.Clear();
|
||||
done_timer = 0;
|
||||
}
|
||||
|
||||
bool Session::operator==(const Session & s) const
|
||||
{
|
||||
return id == s.id;
|
||||
}
|
||||
|
||||
|
||||
bool Session::operator<(const Session & s) const
|
||||
{
|
||||
return id < s.id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool Session::DecTimer(int & timer)
|
||||
{
|
||||
if( timer == 0 )
|
||||
return false;
|
||||
|
||||
--timer;
|
||||
|
||||
if( timer == 0 )
|
||||
return true; // we must clear our variables
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Session::CheckTimers()
|
||||
{
|
||||
if( DecTimer(done_timer) )
|
||||
{
|
||||
done = Done::none;
|
||||
done_status = Error::ok;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user