blob: 4a54586ec68bf1bb0f549245d929ecee9eeb314c (
plain)
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
|
/* -*- C++ -*- */
// $Id$
// ============================================================================
//
// = LIBRARY
// ace
//
// = FILENAME
// Service_Object.h
//
// = AUTHOR
// Doug Schmidt
//
// ============================================================================
#ifndef ACE_SERVICE_OBJECT_H
#define ACE_SERVICE_OBJECT_H
#include "ace/Shared_Object.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/Event_Handler.h"
class ACE_Export ACE_Service_Object : public ACE_Event_Handler, public ACE_Shared_Object
{
// = TITLE
// Provide the abstract base class common to all service
// implementations.
//
// = DESCRIPTION
// Classes that inherit from <ACE_Service_Objects> are capable
// of being registered with the <ACE_Reactor> (due to the
// <ACE_Event_Handler>, as well as being dynamically linked by
// the <ACE_Service_Config> (due to the <ACE_Shared_Object>).
public:
// = Initialization and termination methods.
ACE_Service_Object (ACE_Reactor * = 0);
// Constructor.
virtual ~ACE_Service_Object (void);
// Destructor.
virtual int suspend (void);
// Temporarily disable a service without removing it completely.
virtual int resume (void);
// Re-enable a previously suspended service.
};
// Forward decl.
class ACE_Service_Type_Impl;
class ACE_Export ACE_Service_Type
{
// = TITLE
// Keeps track of information related to the various
// <ACE_Service_Type_Impl> subclasses.
//
// = DESCRIPTION
// This class acts as the interface of the "Bridge" pattern.
public:
enum
{
DELETE_OBJ = 1,
// Delete the payload object.
DELETE_THIS = 2
// Delete the enclosing object.
};
// = Initialization and termination methods.
ACE_Service_Type (const ASYS_TCHAR *n,
ACE_Service_Type_Impl *o,
const ACE_SHLIB_HANDLE handle,
int active);
~ACE_Service_Type (void);
const ASYS_TCHAR *name (void) const;
void name (const ASYS_TCHAR *);
const char *chname (void) const;
const ACE_Service_Type_Impl *type (void) const;
void type (const ACE_Service_Type_Impl *,
int active = 1);
ACE_SHLIB_HANDLE handle (void) const;
void handle (const ACE_SHLIB_HANDLE);
void suspend (void) const;
void resume (void) const;
int active (void) const;
void active (int);
void fini (void);
// Calls <fini> on <type_>
int fini_called (void) const;
// Check if the service has been fini'ed.
void dump (void) const;
// Dump the state of an object.
ACE_ALLOC_HOOK_DECLARE;
// Declare the dynamic allocation hooks.
private:
const ASYS_TCHAR *name_;
// Humanly readible name of svc.
#if defined (ACE_HAS_MOSTLY_UNICODE_APIS)
char *chname_;
// This interface is used to pass char name when instantiate
// ACE_Parse_Node.
#endif /* ACE_HAS_MOSTLY_UNICODE_APIS */
const ACE_Service_Type_Impl *type_;
// Pointer to C++ object that implements the svc.
ACE_SHLIB_HANDLE handle_;
// Handle to shared object file (non-zero if dynamically linked).
int active_;
// 1 if svc is currently active, otherwise 0.
int fini_already_called_;
// 1 if <fini> on <type_> has already been called, otherwise 0.
};
class ACE_Export ACE_Service_Object_Ptr
{
// = TITLE
// This is a smart pointer that holds onto the associated
// <ACE_Service_Object> * until the current scope is left, at
// which point the object's <fini> hook is called and the
// service_object_ gets deleted.
//
// = DESCRIPTION
// This class is similar to the Standard C++ Library class
// <auto_ptr>. It is used in conjunction with statically linked
// <ACE_Service_Objects>, as shown in the
// ./netsvcs/server/main.cpp example.
public:
// = Initialization and termination methods.
ACE_Service_Object_Ptr (ACE_Service_Object *so);
// Acquire ownership of the <so>.
~ACE_Service_Object_Ptr (void);
// Release the held <ACE_Service_Object> by calling its <fini> hook.
ACE_Service_Object *operator-> ();
// Smart pointer to access the underlying <ACE_Service_Object>.
private:
ACE_Service_Object *service_object_;
// Holds the service object until we're done.
};
#if defined (__ACE_INLINE__)
#include "ace/Service_Object.i"
#endif /* __ACE_INLINE__ */
#endif /* ACE_SERVICE_OBJECT_H */
|