Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Service_Types.h

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

Generated on Mon Jun 16 11:21:13 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002