-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrequirement.h
166 lines (137 loc) · 3.33 KB
/
requirement.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
** Copyright (C) 2010 Eff'Innov Technologies. All rights reserved.
** May not be redistributed without prior written permission.
**
** Based on Java version by DeltaDore, subject to DeltaDore copyrights
**
** Note: Eff'Innov Technologies disclaims responsibility for any malfunction
** or error that may arise from any change to the current file, provided that such
** change have not been submitted to and formerly approved by Eff'Innov Technologies,
** prior to the occurence of such malfunction or error
**
** Author: Mickael Leforestier ([email protected])
**
** History log:
** ------------------------------------------------------------------------------
** Author | Date | Changes
** ------------------------------------------------------------------------------
** mleforestier | 092410 | First version
** ylebret | 280212 | refactoring
*/
#ifndef REQUIREMENT_H
#define REQUIREMENT_H
#include <stdlib.h>
#include <string>
#include <vector>
#include <list>
#include <pthread.h>
#include <time.h>
#include <string.h>
#include <stdio.h>
//#include <iostream>
//#include <assert.h>
using namespace std;
namespace deltadoreX2d
{
typedef unsigned char byte;
typedef enum
{
SECURITY = 0x00,
COMMON,
REMOTE,
METERING,
SENSOR,
ENROLLEMENT,
HVAC,
LIGHT,
ROLLERSHUTTER,
DIAGNOSTIC,
OTHER
} Family;
class X2dException : public exception
{
public:
X2dException();
X2dException(const std::string& description);
~X2dException() throw();
const char* what() const throw();
private:
std::string m_description;
};
// pthread version
// may be adapted to another library
class RecursiveLock
{
public:
RecursiveLock();
~RecursiveLock();
void lock();
void unlock();
private:
pthread_mutex_t m_lock;
};
// pthread version
// may be adapted to another library
class Runnable
{
public:
Runnable();
~Runnable();
void start();
void join();
void sleep(); // may be used to lower cpu consumption if needed
virtual void run()=0;
private:
static void* start_routine(void* arg);
pthread_t m_thread;
};
class InputStream
{
public :
virtual ~InputStream(){};
virtual void close()= 0; // may be used to prevent blocking behavior when stopping
virtual int read(void* buffer, int size) = 0;
};
class OutputStream
{
public :
virtual ~OutputStream(){};
virtual void close()=0; // may be used to prevent blocking behavior when stopping
virtual int write(void* buffer, int size) = 0;
};
// C time version
// may be adapted to another library
class Date
{
public :
Date();
Date(time_t date);
~Date();
time_t getValue() const;
int getElapsedSecondsSince(Date date);
private :
time_t m_date;
};
// C time version
// may be adapted to another library
class Calendar
{
public :
Calendar();
~Calendar();
static const int YEAR;
static const int MONTH;
static const int DAY_OF_MONTH;
static const int HOUR_OF_DAY;
static const int MINUTE;
static const int SECOND;
static const int MILLISECOND;
int get(int type) const;
void set(int type, int value);
Date getTime();
void setTime(const Date& time);
private :
struct tm m_calendar;
};
}
#endif // REQUIREMENT_H