Subversion Repositories public

Rev

Rev 47 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
45 luk 1
 
2
/// inotify cron daemon user tables header
3
/**
4
 * \file usertable.h
5
 *
6
 * inotify cron system
7
 *
8
 * Copyright (C) 2006 Lukas Jelinek, <lukas@aiken.cz>
9
 *
10
 * This program is free software; you can use it, redistribute
11
 * it and/or modify it under the terms of the GNU General Public
12
 * License, version 2 (see LICENSE-GPL).
13
 *  
14
 */
15
 
16
#ifndef _USERTABLE_H_
17
#define _USERTABLE_H_
18
 
19
#include <map>
20
 
21
#include "inotify-cxx.h"
22
#include "incrontab.h"
23
 
24
 
25
class UserTable;
26
 
27
 
28
typedef std::map<InotifyWatch*, UserTable*> IWUT_MAP;
29
typedef std::map<InotifyWatch*, InCronTabEntry*> IWCE_MAP;
30
 
31
class EventDispatcher
32
{
33
public:
34
  EventDispatcher(Inotify* pIn);
35
 
36
  ~EventDispatcher() {}
37
 
38
  void DispatchEvent(InotifyEvent& rEvt);
39
 
40
  void Register(InotifyWatch* pWatch, UserTable* pTab);
41
 
42
  void Unregister(InotifyWatch* pWatch);
43
 
44
  void UnregisterAll(UserTable* pTab);
45
 
46
private:
47
  Inotify* m_pIn;
48
  IWUT_MAP m_maps;
49
 
50
  UserTable* FindTable(InotifyWatch* pW);
51
};
52
 
53
 
54
class UserTable
55
{
56
public:
57
        UserTable(Inotify* pIn, EventDispatcher* pEd, const std::string& rUser);
58
        virtual ~UserTable();
59
 
60
  void Load();
61
 
62
  void Dispose();
63
 
64
  void OnEvent(InotifyEvent& rEvt);
65
private:
66
  Inotify* m_pIn;
67
  EventDispatcher* m_pEd;
68
  std::string m_user;
69
  InCronTab m_tab;
70
  IWCE_MAP m_map;
71
 
72
  InCronTabEntry* FindEntry(InotifyWatch* pWatch);
73
 
74
  bool PrepareArgs(const std::string& rCmd, int& argc, char**& argv);
75
};
76
 
77
#endif //_USERTABLE_H_