[6916] Fixed typos in spell checking code.
[getmangos.git] / dep / ACE_wrappers / ace / Service_Object.h
blobd64cebba6c4882ef463c864a51c72f0abce923ca
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file Service_Object.h
7 * $Id: Service_Object.h 81388 2008-04-23 14:02:05Z johnnyw $
9 * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
11 //=============================================================================
13 #ifndef ACE_SERVICE_OBJECT_H
14 #define ACE_SERVICE_OBJECT_H
15 #include /**/ "ace/pre.h"
17 #include "ace/Shared_Object.h"
18 #include "ace/Svc_Conf_Tokens.h"
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 # pragma once
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
24 #include "ace/Event_Handler.h"
25 #include "ace/DLL.h"
27 #include "ace/Service_Gestalt.h"
29 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
31 #define ACE_Component ACE_Service_Object
33 /**
34 * @class ACE_Service_Object
36 * @brief Provide the abstract base class common to all service
37 * implementations.
39 * Classes that inherit from ACE_Service_Objects are capable
40 * of being registered with the ACE_Reactor (due to the
41 * ACE_Event_Handler, as well as being dynamically linked by
42 * the ACE_Service_Config (due to the ACE_Shared_Object).
44 class ACE_Export ACE_Service_Object
45 : public ACE_Event_Handler,
46 public ACE_Shared_Object
48 public:
49 // = Initialization and termination methods.
50 /// Constructor.
51 ACE_Service_Object (ACE_Reactor * = 0);
53 /// Destructor.
54 virtual ~ACE_Service_Object (void);
56 /// Temporarily disable a service without removing it completely.
57 virtual int suspend (void);
59 /// Re-enable a previously suspended service.
60 virtual int resume (void);
63 // Forward decl.
64 class ACE_Service_Type_Impl;
66 /**
67 * @class ACE_Service_Type
69 * @brief Keeps track of information related to the various
70 * ACE_Service_Type_Impl subclasses.
72 * This class acts as the interface of the "Bridge" pattern.
74 class ACE_Export ACE_Service_Type
76 public:
77 enum
79 /// Delete the payload object.
80 DELETE_OBJ = 1,
82 /// Delete the enclosing object.
83 DELETE_THIS = 2
86 enum
88 SERVICE_OBJECT = ACE_SVC_OBJ_T,
89 MODULE = ACE_MODULE_T,
90 STREAM = ACE_STREAM_T,
91 INVALID_TYPE = -1
94 // = Initialization and termination methods.
95 ACE_Service_Type (const ACE_TCHAR *n,
96 ACE_Service_Type_Impl *o,
97 const ACE_DLL &dll,
98 bool active);
99 ACE_Service_Type (const ACE_TCHAR *n,
100 ACE_Service_Type_Impl *o,
101 ACE_SHLIB_HANDLE handle,
102 bool active);
103 ~ACE_Service_Type (void);
105 const ACE_TCHAR *name (void) const;
106 void name (const ACE_TCHAR *);
108 const ACE_Service_Type_Impl *type (void) const;
109 void type (const ACE_Service_Type_Impl *, bool active = true);
111 /// Is this just a stub for the real thing?
112 bool is_forward_declaration (void) const;
114 int suspend (void) const;
115 int resume (void) const;
116 bool active (void) const;
117 void active (bool turnon);
119 /// Calls <fini> on <type_>
120 int fini (void);
122 /// Check if the service has been fini'ed.
123 bool fini_called (void) const;
125 /// Dump the state of an object.
126 void dump (void) const;
128 /// Get to the DLL's implentation
129 const ACE_DLL & dll (void) const;
131 /// Sets the DLL
132 void dll (const ACE_DLL&);
134 /// Declare the dynamic allocation hooks.
135 ACE_ALLOC_HOOK_DECLARE;
137 private:
138 /// Humanly readible name of svc.
139 const ACE_TCHAR *name_;
141 /// Pointer to C++ object that implements the svc.
142 const ACE_Service_Type_Impl *type_;
144 /// ACE_DLL representing the shared object file (non-zero if
145 /// dynamically linked).
146 mutable ACE_DLL dll_;
148 /// true if svc is currently active, otherwise false.
149 bool active_;
151 /// true if <fini> on <type_> has already been called, otherwise false.
152 bool fini_already_called_;
156 * @class ACE_Service_Object_Ptr
158 * @brief This is a smart pointer that holds onto the associated
159 * ACE_Service_Object * until the current scope is left, at
160 * which point the object's <fini> hook is called and the
161 * service_object_ gets deleted.
163 * This class is similar to the Standard C++ Library class
164 * <auto_ptr>. It is used in conjunction with statically linked
165 * <ACE_Service_Objects>, as shown in the
166 * ./netsvcs/server/main.cpp example.
168 class ACE_Export ACE_Service_Object_Ptr
170 public:
171 // = Initialization and termination methods.
172 /// Acquire ownership of the @a so.
173 ACE_Service_Object_Ptr (ACE_Service_Object *so);
175 /// Release the held ACE_Service_Object by calling its <fini> hook.
176 ~ACE_Service_Object_Ptr (void);
178 /// Smart pointer to access the underlying ACE_Service_Object.
179 ACE_Service_Object *operator-> ();
181 private:
182 /// Holds the service object until we're done.
183 ACE_Service_Object *service_object_;
186 #if defined (ACE_OPENVMS)
188 * @class ACE_Dynamic_Svc_Registrar
190 * @brief Used to register Service allocator function by its full name.
192 class ACE_Dynamic_Svc_Registrar
194 public:
195 ACE_Dynamic_Svc_Registrar (const ACE_TCHAR* alloc_name,
196 void* svc_allocator);
198 #endif
200 ACE_END_VERSIONED_NAMESPACE_DECL
202 #if defined (__ACE_INLINE__)
203 #include "ace/Service_Object.inl"
204 #endif /* __ACE_INLINE__ */
206 #include /**/ "ace/post.h"
207 #endif /* ACE_SERVICE_OBJECT_H */