Main Page
Related Pages
Namespaces
Classes
Files
Workshop
Donate
Hausmi
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Service.h
Go to the documentation of this file.
1
/*
2
* Service.h
3
*
4
* This file is part of the HausmiSEP project
5
*
6
* Copyright (C) 2012, 2013 Marco Alvarado (malvcr@gmail.com)
7
*
8
* This program is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
11
* (at your option) any later version.
12
*
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public License
19
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
*/
21
22
#ifndef SERVICE_H_
23
#define SERVICE_H_
24
25
#include <
HSEP/Thread.h
>
26
27
#include <string>
28
#include <fstream>
29
30
using namespace
std;
31
32
namespace
HSEP {
33
40
class
ServiceThread
:
public
Thread
{
41
fstream* aServiceLogPtr;
42
string
aName;
43
string
aStatus;
44
protected
:
45
virtual
bool
prepare();
46
virtual
void
dispose();
47
48
public
:
49
ServiceThread
(
50
string
pName
51
);
52
virtual
~
ServiceThread
();
53
54
const
string
&
statusRef
()
const
{
55
return
aStatus;
56
}
57
58
void
log(
string
pData);
59
60
};
// Service Thread class
61
66
class
ServiceThreadFactory
{
67
public
:
68
virtual
~ServiceThreadFactory
() {}
69
74
virtual
ServiceThread
* createPtr() = 0;
75
};
// ServiceThreadFactory class
76
88
class
Service
{
89
90
static
ServiceThread
* aThreadInstance;
91
bool
aTerminate;
/*< controls the body internal cycle for external control procedures */
92
Mutex
aTermMutex;
93
94
protected
:
95
96
int
aPid
;
97
int
aSid
;
98
string
aName
;
99
100
friend
void
TerminateHandler
(
int
pSignal);
101
102
bool
_continue();
103
104
public
:
111
Service
(
112
string
pName,
113
ServiceThreadFactory
& pServiceThreadFactory
114
);
115
virtual
~
Service
();
116
121
int
body();
122
126
void
finish();
127
128
};
// Service class
129
130
}
// HSEP namespace
131
132
#endif
/* SERVICE_H_ */
HSEP.0.1
include
HSEP
Service.h
Generated on Fri Jul 19 2013 12:00:29 by
1.8.2