Service_Types.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //==========================================================================
00004 /**
00005  *  @file    Service_Types.h
00006  *
00007  *  Service_Types.h,v 4.25 2005/10/28 16:14:55 ossama Exp
00008  *
00009  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00010  */
00011 //==========================================================================
00012 
00013 #ifndef ACE_SERVICE_TYPE_H
00014 #define ACE_SERVICE_TYPE_H
00015 
00016 #include /**/ "ace/pre.h"
00017 
00018 #include "ace/Service_Object.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00025 
00026 /**
00027  * @class ACE_Service_Type_Impl
00028  *
00029  * @brief The abstract base class of the hierarchy that defines the
00030  * contents of the ACE_Service_Repository.  The subclasses of
00031  * this class allow the configuration of ACE_Service_Objects,
00032  * ACE_Modules, and ACE_Streams.
00033  *
00034  * This class provides the root of the implementation hierarchy
00035  * of the "Bridge" pattern.  It maintains a pointer to the
00036  * appropriate type of service implementation, i.e.,
00037  * ACE_Service_Object, ACE_Module, or ACE_Stream.
00038  */
00039 class ACE_Export ACE_Service_Type_Impl
00040 {
00041 public:
00042   // = Initialization and termination methods.
00043   ACE_Service_Type_Impl (void *object,
00044                          const ACE_TCHAR *s_name,
00045                          u_int flags = 0,
00046                          ACE_Service_Object_Exterminator gobbler = 0);
00047   virtual ~ACE_Service_Type_Impl (void);
00048 
00049   // = Pure virtual interface (must be defined by the subclass).
00050   virtual int suspend (void) const = 0;
00051   virtual int resume (void) const = 0;
00052   virtual int init (int argc, ACE_TCHAR *argv[]) const = 0;
00053   virtual int fini (void) const;
00054   virtual int info (ACE_TCHAR **str, size_t len) const = 0;
00055 
00056   /// The pointer to the service.
00057   void *object (void) const;
00058 
00059   /// Get the name of the service.
00060   const ACE_TCHAR *name (void) const;
00061 
00062   /// Set the name of the service.
00063   void name (const ACE_TCHAR *);
00064 
00065   /// Dump the state of an object.
00066   void dump (void) const;
00067 
00068   /// Declare the dynamic allocation hooks.
00069   ACE_ALLOC_HOOK_DECLARE;
00070 
00071 protected:
00072   /// Name of the service.
00073   const ACE_TCHAR *name_;
00074 
00075   /// Pointer to object that implements the service.  This actually
00076   /// points to an ACE_Service_Object, ACE_Module, or ACE_Stream.
00077   void *obj_;
00078 
00079   /// Destroy function to deallocate obj_.
00080   ACE_Service_Object_Exterminator gobbler_;
00081 
00082   /// Flags that control serivce behavior (particularly deletion).
00083   u_int flags_;
00084 };
00085 
00086 /**
00087  * @class ACE_Service_Object_Type
00088  *
00089  * @brief Define the methods for handling the configuration of
00090  * ACE_Service_Objects.
00091  */
00092 class ACE_Export ACE_Service_Object_Type : public ACE_Service_Type_Impl
00093 {
00094 public:
00095   // = Initialization method.
00096   ACE_Service_Object_Type (void *so,
00097                            const ACE_TCHAR *name,
00098                            u_int flags = 0,
00099                            ACE_Service_Object_Exterminator gobbler = 0);
00100 
00101   ~ACE_Service_Object_Type (void);
00102 
00103   // = Implement the hooks for <ACE_Service_Objects>.
00104   virtual int suspend (void) const;
00105   virtual int resume (void) const;
00106   virtual int init (int argc, ACE_TCHAR *argv[]) const;
00107   virtual int fini (void) const;
00108   virtual int info (ACE_TCHAR **str, size_t len) const;
00109 };
00110 
00111 /**
00112  * @class ACE_Module_Type
00113  *
00114  * @brief Define the methods for handling the configuration of
00115  * ACE_Modules.
00116  */
00117 class ACE_Export ACE_Module_Type : public ACE_Service_Type_Impl
00118 {
00119 public:
00120   // = Initialization method.
00121   ACE_Module_Type (void *m, // Really an <ACE_Module> *.
00122                    const ACE_TCHAR *identifier,
00123                    u_int flags = 0);
00124 
00125   ~ACE_Module_Type (void);
00126 
00127   // = Implement the hooks for <ACE_Modules>.
00128   virtual int suspend (void) const;
00129   virtual int resume (void) const;
00130   virtual int init (int argc, ACE_TCHAR *argv[]) const;
00131   virtual int fini (void) const;
00132   virtual int info (ACE_TCHAR **str, size_t len) const;
00133 
00134   /// Get the link pointer.
00135   ACE_Module_Type *link (void) const;
00136 
00137   /// Set the link pointer.
00138   void link (ACE_Module_Type *);
00139 
00140   /// Dump the state of an object.
00141   void dump (void) const;
00142 
00143   /// Declare the dynamic allocation hooks.
00144   ACE_ALLOC_HOOK_DECLARE;
00145 
00146 private:
00147   /// Pointer to the next ACE_Module_Type in an ACE_Stream_Type.
00148   ACE_Module_Type *link_;
00149 };
00150 
00151 /**
00152  * @class ACE_Stream_Type
00153  *
00154  * @brief Define the methods for handling the configuration of
00155  * ACE_Streams.
00156  */
00157 class ACE_Export ACE_Stream_Type : public ACE_Service_Type_Impl
00158 {
00159 public:
00160   // = Initialization method.
00161   ACE_Stream_Type (void *s, // Really an <ACE_Stream> *.
00162                    const ACE_TCHAR *identifier,
00163                    u_int flags = 0);
00164 
00165   ~ACE_Stream_Type (void);
00166 
00167   // = Implement the hooks for <ACE_Streams>.
00168   virtual int suspend (void) const;
00169   virtual int resume (void) const;
00170   virtual int init (int argc, ACE_TCHAR *argv[]) const;
00171   virtual int fini (void) const;
00172   virtual int info (ACE_TCHAR **str, size_t len) const;
00173 
00174   /// Add a new  ACE_Module to the top of the ACE_Stream.
00175   int push (ACE_Module_Type *new_module);
00176 
00177   /// Search for @a module and remove it from the ACE_Stream.
00178   int remove (ACE_Module_Type *module);
00179 
00180   /// Locate the ACE_Module with @a mod_name.
00181   ACE_Module_Type *find (const ACE_TCHAR *mod_name) const;
00182 
00183   /// Dump the state of an object.
00184   void dump (void) const;
00185 
00186   /// Declare the dynamic allocation hooks.
00187   ACE_ALLOC_HOOK_DECLARE;
00188 
00189 private:
00190   /// Pointer to the head of the ACE_Module list.
00191   ACE_Module_Type *head_;
00192 };
00193 
00194 ACE_END_VERSIONED_NAMESPACE_DECL
00195 
00196 #if defined (__ACE_INLINE__)
00197 #include "ace/Service_Types.inl"
00198 #endif /* __ACE_INLINE__ */
00199 
00200 #include /**/ "ace/post.h"
00201 
00202 #endif /* _SERVICE_TYPE_H */

Generated on Thu Nov 9 09:42:03 2006 for ACE by doxygen 1.3.6