Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Service_Types.h
blobaf7179ed4c383b9be1dbc8936be38e7685225f2a
1 // -*- C++ -*-
3 //==========================================================================
4 /**
5 * @file Service_Types.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
8 */
9 //==========================================================================
11 #ifndef ACE_SERVICE_TYPE_H
12 #define ACE_SERVICE_TYPE_H
14 #include /**/ "ace/pre.h"
16 #include "ace/Service_Object.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 # pragma once
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
24 /**
25 * @class ACE_Service_Type_Impl
27 * @brief The abstract base class of the hierarchy that defines the
28 * contents of the ACE_Service_Repository. The subclasses of
29 * this class allow the configuration of ACE_Service_Objects,
30 * ACE_Modules, and ACE_Streams.
32 * This class provides the root of the implementation hierarchy
33 * of the "Bridge" pattern. It maintains a pointer to the
34 * appropriate type of service implementation, i.e.,
35 * ACE_Service_Object, ACE_Module, or ACE_Stream.
37 class ACE_Export ACE_Service_Type_Impl
39 public:
40 ACE_Service_Type_Impl (void *object,
41 const ACE_TCHAR *s_name,
42 u_int flags = 0,
43 ACE_Service_Object_Exterminator gobbler = 0,
44 int stype = ACE_Service_Type::INVALID_TYPE);
45 virtual ~ACE_Service_Type_Impl ();
47 // = Pure virtual interface (must be defined by the subclass).
48 virtual int suspend () const = 0;
49 virtual int resume () const = 0;
50 virtual int init (int argc, ACE_TCHAR *argv[]) const = 0;
51 virtual int fini () const;
52 virtual int info (ACE_TCHAR **str, size_t len) const = 0;
54 /// The pointer to the service.
55 void *object () const;
57 /// Get the name of the service.
58 const ACE_TCHAR *name () const;
60 /// Set the name of the service.
61 void name (const ACE_TCHAR *);
63 /// Dump the state of an object.
64 void dump () const;
66 /// get the service_type of this service
67 int service_type () const;
69 /// set the service_type of this service
70 void service_type (int stype);
72 /// Declare the dynamic allocation hooks.
73 ACE_ALLOC_HOOK_DECLARE;
75 protected:
76 /// Name of the service.
77 const ACE_TCHAR *name_;
79 /// Pointer to object that implements the service. This actually
80 /// points to an ACE_Service_Object, ACE_Module, or ACE_Stream.
81 void *obj_;
83 /// Destroy function to deallocate obj_.
84 ACE_Service_Object_Exterminator gobbler_;
86 /// Flags that control serivce behavior (particularly deletion).
87 u_int flags_;
89 /// type of this service
90 /// Used to properly manage the lifecycle of ACE_Modules and ACE_Streams
91 /// during shutdown
92 int service_type_;
95 /**
96 * @class ACE_Service_Object_Type
98 * @brief Define the methods for handling the configuration of
99 * ACE_Service_Objects.
101 class ACE_Export ACE_Service_Object_Type : public ACE_Service_Type_Impl
103 public:
104 ACE_Service_Object_Type (void *so,
105 const ACE_TCHAR *name,
106 u_int flags = 0,
107 ACE_Service_Object_Exterminator gobbler = 0,
108 int stype = ACE_Service_Type::SERVICE_OBJECT);
110 ~ACE_Service_Object_Type ();
112 // = Implement the hooks for <ACE_Service_Objects>.
113 virtual int suspend () const;
114 virtual int resume () const;
115 virtual int init (int argc, ACE_TCHAR *argv[]) const;
116 virtual int fini () const;
117 virtual int info (ACE_TCHAR **str, size_t len) const;
119 private:
120 /// Holds the initialization status (result of object->init())
121 mutable int initialized_;
125 * @class ACE_Module_Type
127 * @brief Define the methods for handling the configuration of
128 * ACE_Modules.
130 class ACE_Export ACE_Module_Type : public ACE_Service_Type_Impl
132 public:
133 ACE_Module_Type (void *m, // Really an ACE_Module *.
134 const ACE_TCHAR *identifier,
135 u_int flags = 0,
136 int stype = ACE_Service_Type::MODULE);
138 ~ACE_Module_Type ();
140 // = Implement the hooks for <ACE_Modules>.
141 virtual int suspend () const;
142 virtual int resume () const;
143 virtual int init (int argc, ACE_TCHAR *argv[]) const;
144 virtual int fini () const;
145 virtual int info (ACE_TCHAR **str, size_t len) const;
147 /// Get the link pointer.
148 ACE_Module_Type *link () const;
150 /// Set the link pointer.
151 void link (ACE_Module_Type *);
153 /// Dump the state of an object.
154 void dump () const;
156 /// Declare the dynamic allocation hooks.
157 ACE_ALLOC_HOOK_DECLARE;
159 private:
160 /// Pointer to the next ACE_Module_Type in an ACE_Stream_Type.
161 ACE_Module_Type *link_;
165 * @class ACE_Stream_Type
167 * @brief Define the methods for handling the configuration of
168 * ACE_Streams.
170 class ACE_Export ACE_Stream_Type : public ACE_Service_Type_Impl
172 public:
173 ACE_Stream_Type (void *s, // Really an ACE_Stream *.
174 const ACE_TCHAR *identifier,
175 u_int flags = 0,
176 int stype = ACE_Service_Type::STREAM);
178 ~ACE_Stream_Type ();
180 // = Implement the hooks for <ACE_Streams>.
181 virtual int suspend () const;
182 virtual int resume () const;
183 virtual int init (int argc, ACE_TCHAR *argv[]) const;
184 virtual int fini () const;
185 virtual int info (ACE_TCHAR **str, size_t len) const;
187 /// Add a new ACE_Module to the top of the ACE_Stream.
188 int push (ACE_Module_Type *new_module);
190 /// Search for @a module and remove it from the ACE_Stream.
191 int remove (ACE_Module_Type *module);
193 /// Locate the ACE_Module with @a mod_name.
194 ACE_Module_Type *find (const ACE_TCHAR *module_name) const;
196 /// Dump the state of an object.
197 void dump () const;
199 /// Declare the dynamic allocation hooks.
200 ACE_ALLOC_HOOK_DECLARE;
202 private:
203 /// Pointer to the head of the ACE_Module list.
204 ACE_Module_Type *head_;
207 ACE_END_VERSIONED_NAMESPACE_DECL
209 #if defined (__ACE_INLINE__)
210 #include "ace/Service_Types.inl"
211 #endif /* __ACE_INLINE__ */
213 #include /**/ "ace/post.h"
215 #endif /* _SERVICE_TYPE_H */