Advertisement
Guest User

Untitled

a guest
Oct 12th, 2013
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1.  
  2.  
  3. //Includes
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. //Local Project Includes
  9. #include "Timer.h"
  10.  
  11. //Boost
  12.  
  13. #include <boost/thread/thread.hpp>
  14. #include <boost/exception/all.hpp>
  15. #include <boost/bind.hpp>
  16.  
  17. class Timer {
  18.  
  19. private:
  20. bool UserLoginStatus;
  21.  
  22. public:
  23. void StartTimer();
  24. void SetLoginStatus(bool LoginStatus);
  25. };
  26.  
  27. //Starts the Timer
  28. void Timer::StartTimer() {
  29. //While The User Is Logged in
  30. while(this->UserLoginStatus == true) {
  31. try { //Try to sleep for 15 minutes
  32. boost::this_thread::sleep( boost::posix_time::seconds((60 * 15))); //Sleep For 15 Minutes
  33. //logout() Logout User
  34. }
  35.  
  36. catch(NotIdleException except) { //This is Thrown if the user enters a command (is not idle)
  37.  
  38. }
  39. }
  40. }
  41.  
  42.  
  43. //Change User Login LoginStatus
  44. void Timer::SetLoginStatus(bool LoginStatus) {
  45. this->UserLoginStatus = LoginStatus;
  46. }
  47.  
  48.  
  49. class NotIdleException {
  50.  
  51. public:
  52. NotIdleException(const char* pStr = "There's a problem") : pMessage(pStr) {
  53.  
  54. }
  55. const char* what() const {
  56. return pMessage;
  57. }
  58.  
  59. private:
  60. const char* pMessage;
  61.  
  62. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement