summaryrefslogtreecommitdiff
path: root/ace/Service_Record.h
blob: f2ce2492c26500896647b8904852eb970fd09c8d (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
/* -*- C++ -*- */
// $Id$

// ============================================================================
//
// = LIBRARY
//    ace
// 
// = FILENAME
//    Service_Record.h
//
// = AUTHOR
//    Doug Schmidt 
// 
// ============================================================================

#if !defined (ACE_SERVICE_RECORD_H)
#define ACE_SERVICE_RECORD_H

#include "ace/Service_Object.h"
#include "ace/Synch.h"
#include "ace/Stream.h"

typedef ACE_Stream<ACE_SYNCH> MT_Stream;
typedef ACE_Module<ACE_SYNCH> MT_Module;
typedef ACE_Task<ACE_SYNCH> MT_Task;

class ACE_Export ACE_Service_Object_Type : public ACE_Service_Type
  // = TITLE
  //     Define the methods for handling <ACE_Service_Objects>.
{
public:
  ACE_Service_Object_Type (ACE_Service_Object *so, 
			   const char *name, 
			   u_int flags = 0);
  virtual int suspend (void) const;
  virtual int resume (void) const;
  virtual int init (int argc, char *argv[]) const;
  virtual int fini (void) const;
  virtual int info (char **str, size_t len) const;
};

class ACE_Export ACE_Module_Type : public ACE_Service_Type
  // = TITLE
  //     Define the methods for handling <ACE_Modules>.
{
public:
  ACE_Module_Type (MT_Module *m, 
		   const char *identifier, 
		   u_int flags = 0);

  virtual int suspend (void) const;
  virtual int resume (void) const;
  virtual int init (int argc, char *argv[]) const;
  virtual int fini (void) const;
  virtual int info (char **str, size_t len) const;

  ACE_Module_Type *link (void) const;
  void link (ACE_Module_Type *);

  void dump (void) const;
  // Dump the state of an object.

  ACE_ALLOC_HOOK_DECLARE;
  // Declare the dynamic allocation hooks.

private:
  ACE_Module_Type *next_;
};

class ACE_Export ACE_Stream_Type : public ACE_Service_Type
  // = TITLE
  //     Define the methods for handling <ACE_Streams>.
{
public:
  ACE_Stream_Type (MT_Stream *s, 
		   const char *identifier, 
		   u_int flags = 0);

  virtual int suspend (void) const;
  virtual int resume (void) const;
  virtual int init (int argc, char *argv[]) const;
  virtual int fini (void) const;
  virtual int info (char **str, size_t len) const;

  int push (ACE_Module_Type *new_module);
  int remove (ACE_Module_Type *module);
  ACE_Module_Type *find (const char *mod_name) const;

  void dump (void) const;
  // Dump the state of an object.

  ACE_ALLOC_HOOK_DECLARE;
  // Declare the dynamic allocation hooks.

private:
  ACE_Module_Type *head_;
};

class ACE_Export ACE_Service_Record
  // = TITLE
  //      Packaging interface for the various types of
  //      <ACE_Service_Types>.
{
public:
  // = Initialization and termination methods.
  ACE_Service_Record (const char *n, 
		      ACE_Service_Type *o, 
		      const void *handle, 
		      int active);
  ~ACE_Service_Record (void);
			 
  const char *name (void) const;
  void name (const char *);

  const ACE_Service_Type *type (void) const;
  void type (const ACE_Service_Type *, 
	     int active = 1);

  const void *handle (void) const;
  void handle (const void *);

  void suspend (void) const;
  void resume (void) const;
  int  active (void) const;
  void active (int);

  void dump (void) const;
  // Dump the state of an object.

  ACE_ALLOC_HOOK_DECLARE;
  // Declare the dynamic allocation hooks.

private:
  const char *name_;   
  // Humanly readible name of svc.

  const ACE_Service_Type *type_;
  // Pointer to C++ object that implements the svc.

  const void *handle_; 
  // Handle to shared object file (non-zero if dynamically linked).

  int active_;  
  // 1 if svc is currently active, otherwise 0.
};

#if defined (__ACE_INLINE__)
#include "ace/Service_Record.i"
#endif /* __ACE_INLINE__ */

#endif /* _SERVICE_RECORD_H */