initial Timer class
[public/netxms.git] / src / server / core / timer.cpp
1 /*
2 ** NetXMS - Network Management System
3 ** Copyright (C) 2003-2014 Victor Kirhenshtein
4 **
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
14 **
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program; if not, write to the Free Software
17 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 **
19 ** File: timer.cpp
20 **
21 **/
22
23 #include "nxcore.h"
24
25 /**
26 * Timer queue
27 */
28 #ifdef _WIN32
29 HANDLE Timer::m_queue = CreateTimerQueue();
30 #endif
31
32 /**
33 * Timer constructor
34 */
35 Timer::Timer(const TCHAR *name, time_t startTime, TimerAction action, UINT32 node, StringMap *parameters)
36 {
37 m_name = _tcsdup_ex(name);
38 m_startTime = startTime;
39 m_action = action;
40 m_node = node;
41 m_parameters.addAll(parameters);
42 }
43
44 /**
45 * Destructor
46 */
47 Timer::~Timer()
48 {
49 free(m_name);
50 #ifdef _WIN32
51 DeleteTimerQueueTimer(m_queue, m_id, NULL);
52 #endif
53 }
54
55 /**
56 * Execute timer
57 */
58 void Timer::execute()
59 {
60 switch(m_action)
61 {
62 case TIMER_ACTION_SEND_EVENT:
63 PostEventWithNames();
64 break;
65 default:
66 DbgPrintf(4, _T("Unknown timer action %d"), m_action);
67 break;
68 }
69 }
70
71 /**
72 * Schedule timer
73 */
74 void Timer::schedule(Timer *t)
75 {
76 }
77
78 /**
79 * Cancel timer
80 */
81 void Timer::cancel(Timer *t)
82 {
83 }