/* -*- C++ -*- */ // $Id$ // ============================================================================ // // = LIBRARY // ace // // = FILENAME // Server_Logging_Handler_T.h // // = AUTHOR // Doug Schmidt and Per Andersson // // ============================================================================ #ifndef ACE_SERVER_LOGGING_HANDLER_T_H #define ACE_SERVER_LOGGING_HANDLER_T_H #include "ace/Synch.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/TLI_Acceptor.h" #include "ace/SOCK_Acceptor.h" #include "ace/Acceptor.h" #include "ace/SString.h" #include "ace/Atomic_Op.h" #if !defined (ACE_HAS_BROKEN_HPUX_TEMPLATES) && !defined (__GNUG__) #include "Base_Optimizer.h" #endif /* ! ACE_HAS_BROKEN_HPUX_TEMPLATES && ! __GNUG__ */ template class ACE_Server_Logging_Handler_T : public ACE_Svc_Handler { // = TITLE // Product object created by an . An // receives, and frames logging // records. The logging record is then processed by the // // // = DESCRIPTION // Defines the classes that perform server logging daemon // functionality. public: ACE_Server_Logging_Handler_T (ACE_Thread_Manager *, const LOG_MESSAGE_RECEIVER &receiver ); // Constructor. virtual int handle_input (ACE_HANDLE = ACE_INVALID_HANDLE); // Process remote logging records. protected: int handle_logging_record (void); // Receive the logging record from a client. int open_common (void); // Common parts of open function, sets hostname and diables NONBLOCK in peer // called from derived classes open method. #if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES) static COUNTER request_count_; // Count the number of logging records that arrive. #endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */ #if !defined (ACE_HAS_BROKEN_HPUX_TEMPLATES) && !defined (__GNUG__) Base_Optimizer receiver_; // Packs a LOG_MESSAGE_RECEIVER and ACE_CString attribute together // in a optimized fashion. The LOG_MESSAGE_RECEIVER class is often // a class with no instance data. #else LOG_MESSAGE_RECEIVER receiver_; ACE_CString host_name_; #endif /* ! ACE_HAS_BROKEN_HPUX_TEMPLATES && ! __GNUG__ */ const char *host_name (void); // Name of the host we are connected to. LOG_MESSAGE_RECEIVER &receiver (void){ return receiver_; } // The receiver of log records }; #if 1 //!defined (ACE_HAS_TLI) #define LOGGING_PEER_ACCEPTOR ACE_SOCK_ACCEPTOR #define LOGGING_PEER_STREAM ACE_SOCK_STREAM #else /* use sockets */ #define LOGGING_PEER_ACCEPTOR ACE_TLI_ACCEPTOR #define LOGGING_PEER_STREAM ACE_TLI_STREAM #endif /* ACE_HAS_TLI */ template class ACE_Server_Logging_Acceptor_T : public ACE_Strategy_Acceptor { // = TITLE // Factory that creates s scheduled with // and logging records proccessed by a // // // = DESCRIPTION // This class contains the service-specific methods that can't // easily be factored into the . public: ACE_Server_Logging_Acceptor_T (void); virtual int init (int argc, char *argv[]); // Dynamic linking hook. protected: int parse_args (int argc, char *argv[]); // Parse svc.conf arguments. virtual int make_svc_handler (SERVER_LOGGING_HANDLER *&); // Factory that creates a new . We need to // specialize this since the held by this Acceptor must be // passed into the . private: // At the moment each ACE_Server_Logging_Acceptor_T contains // a attribute that is passed to the // at construction. A better idea might // be to have accessor class as template argument. The accessor // should be a factory/strategy that hands the // ACE_Server_Logging_Acceptor_T instance references // to a . This makes it possible // to change how are created without chaning the // ACE_Server_Logging_Acceptor_T code. #if !defined (ACE_HAS_BROKEN_HPUX_TEMPLATES) && !defined (__GNUG__) Base_Optimizer receiver_; // Packs a LOG_MESSAGE_RECEIVER and ACE_CString attribute together // in a optimized fashion. The LOG_MESSAGE_RECEIVER class is often a // class with no instance data. #else LOG_MESSAGE_RECEIVER receiver_; SCHEDULE_STRATEGY schedule_strategy_; #endif /* ! ACE_HAS_BROKEN_HPUX_TEMPLATES && ! __GNUG__ */ SCHEDULE_STRATEGY &scheduling_strategy (void); // The scheduling strategy for the service. LOG_MESSAGE_RECEIVER &receiver (void); // The receiver of log records }; template class ACE_Server_Logging_Handler : public ACE_Server_Logging_Handler_T { // = TITLE // Product object created by a // >. An // receives, frames. The logging record // is then processed by the // // = DESCRIPTION // All clients are handled in the same thread. public: ACE_Server_Logging_Handler (ACE_Thread_Manager * = 0); ACE_Server_Logging_Handler (ACE_Thread_Manager *, const LOG_MESSAGE_RECEIVER &receiver); virtual int open (void* = 0); }; #if defined (ACE_HAS_THREADS) typedef ACE_Atomic_Op ACE_LOGGER_COUNTER; #define ACE_LOGGER_SYNCH ACE_MT_SYNCH #else typedef u_long ACE_LOGGER_COUNTER; #define ACE_LOGGER_SYNCH ACE_NULL_SYNCH #endif /* ACE_HAS_THREADS */ template class ACE_Thr_Server_Logging_Handler : public ACE_Server_Logging_Handler_T { // = TITLE // Product object created by a // // >. An receives, frames. The // logging record is then processed by the // // = DESCRIPTION // Each client is handled in its own separate thread. public: ACE_Thr_Server_Logging_Handler (ACE_Thread_Manager * = 0); ACE_Thr_Server_Logging_Handler (ACE_Thread_Manager *, const LOG_MESSAGE_RECEIVER &receiver); virtual int open (void * = 0); virtual int svc (void); }; #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) #include "Server_Logging_Handler_T.cpp" #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) #pragma implementation ("Server_Logging_Handler_T.cpp") #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ #endif /* ACE_SERVER_LOGGING_HANDLER_T_H */