1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
/*
** $Id: Logging_Event_Handler.h 80826 2008-03-04 14:51:23Z wotte $
**
** Copyright 2002 Addison Wesley. All Rights Reserved.
*/
#ifndef _LOGGING_EVENT_HANDLER_H
#define _LOGGING_EVENT_HANDLER_H
#include "ace/Event_Handler.h"
#include "ace/FILE_IO.h"
#include "ace/Reactor.h"
#include "ace/SOCK_Stream.h"
#include "Logging_Handler.h"
class Logging_Event_Handler : public ACE_Event_Handler
{
protected:
// File where log records are written.
ACE_FILE_IO log_file_;
// Connection to remote peer.
Logging_Handler logging_handler_;
public:
// Initialize the base class and logging handler.
Logging_Event_Handler (ACE_Reactor *reactor)
: ACE_Event_Handler (reactor),
logging_handler_ (log_file_) {};
virtual ~Logging_Event_Handler () {}; // No-op destructor.
// Activate the object.
virtual int open ();
// Called by a reactor when logging events arrive.
virtual int handle_input (ACE_HANDLE = ACE_INVALID_HANDLE);
// Called when this object is destroyed, e.g., when it's
// removed from a reactor.
virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE,
ACE_Reactor_Mask = 0);
// Return socket handle of the contained <Logging_Handler>.
virtual ACE_HANDLE get_handle (void) const {
// Need a non-const reference to call peer(), but that's
// safe since we call a const method using it.
Logging_Handler& h =
const_cast<Logging_Handler&> (logging_handler_);
return h.peer ().get_handle ();
};
// Get a reference to the contained <ACE_SOCK_Stream>.
ACE_SOCK_Stream &peer () { return logging_handler_.peer (); };
// Return a reference to the <log_file_>.
ACE_FILE_IO &log_file () { return log_file_; };
};
#endif /* _LOGGING_EVENT_HANDLER_H */
|