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 80826 2008-03-04 14:51:23Z wotte $
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 private:
00111   /// Holds the initialization status (result of object->init())
00112   mutable int initialized_;
00113 };
00114 
00115 /**
00116  * @class ACE_Module_Type
00117  *
00118  * @brief Define the methods for handling the configuration of
00119  * ACE_Modules.
00120  */
00121 class ACE_Export ACE_Module_Type : public ACE_Service_Type_Impl
00122 {
00123 public:
00124   // = Initialization method.
00125   ACE_Module_Type (void *m, // Really an ACE_Module *.
00126                    const ACE_TCHAR *identifier,
00127                    u_int flags = 0);
00128 
00129   ~ACE_Module_Type (void);
00130 
00131   // = Implement the hooks for <ACE_Modules>.
00132   virtual int suspend (void) const;
00133   virtual int resume (void) const;
00134   virtual int init (int argc, ACE_TCHAR *argv[]) const;
00135   virtual int fini (void) const;
00136   virtual int info (ACE_TCHAR **str, size_t len) const;
00137 
00138   /// Get the link pointer.
00139   ACE_Module_Type *link (void) const;
00140 
00141   /// Set the link pointer.
00142   void link (ACE_Module_Type *);
00143 
00144   /// Dump the state of an object.
00145   void dump (void) const;
00146 
00147   /// Declare the dynamic allocation hooks.
00148   ACE_ALLOC_HOOK_DECLARE;
00149 
00150 private:
00151   /// Pointer to the next ACE_Module_Type in an ACE_Stream_Type.
00152   ACE_Module_Type *link_;
00153 };
00154 
00155 /**
00156  * @class ACE_Stream_Type
00157  *
00158  * @brief Define the methods for handling the configuration of
00159  * ACE_Streams.
00160  */
00161 class ACE_Export ACE_Stream_Type : public ACE_Service_Type_Impl
00162 {
00163 public:
00164   // = Initialization method.
00165   ACE_Stream_Type (void *s, // Really an ACE_Stream *.
00166                    const ACE_TCHAR *identifier,
00167                    u_int flags = 0);
00168 
00169   ~ACE_Stream_Type (void);
00170 
00171   // = Implement the hooks for <ACE_Streams>.
00172   virtual int suspend (void) const;
00173   virtual int resume (void) const;
00174   virtual int init (int argc, ACE_TCHAR *argv[]) const;
00175   virtual int fini (void) const;
00176   virtual int info (ACE_TCHAR **str, size_t len) const;
00177 
00178   /// Add a new  ACE_Module to the top of the ACE_Stream.
00179   int push (ACE_Module_Type *new_module);
00180 
00181   /// Search for @a module and remove it from the ACE_Stream.
00182   int remove (ACE_Module_Type *module);
00183 
00184   /// Locate the ACE_Module with @a mod_name.
00185   ACE_Module_Type *find (const ACE_TCHAR *mod_name) const;
00186 
00187   /// Dump the state of an object.
00188   void dump (void) const;
00189 
00190   /// Declare the dynamic allocation hooks.
00191   ACE_ALLOC_HOOK_DECLARE;
00192 
00193 private:
00194   /// Pointer to the head of the ACE_Module list.
00195   ACE_Module_Type *head_;
00196 };
00197 
00198 ACE_END_VERSIONED_NAMESPACE_DECL
00199 
00200 #if defined (__ACE_INLINE__)
00201 #include "ace/Service_Types.inl"
00202 #endif /* __ACE_INLINE__ */
00203 
00204 #include /**/ "ace/post.h"
00205 
00206 #endif /* _SERVICE_TYPE_H */

Generated on Tue Feb 2 17:18:42 2010 for ACE by  doxygen 1.4.7