Merge pull request #2317 from jwillemsen/jwi-deleteop
[ACE_TAO.git] / ACE / examples / C++NPv2 / Logging_Event_Handler.h
blob210e2eb7782a03a20fae5a089a589a6e6a14fd55
1 /*
2 ** Copyright 2002 Addison Wesley. All Rights Reserved.
3 */
5 #ifndef _LOGGING_EVENT_HANDLER_H
6 #define _LOGGING_EVENT_HANDLER_H
8 #include "ace/Event_Handler.h"
9 #include "ace/FILE_IO.h"
10 #include "ace/Reactor.h"
11 #include "ace/SOCK_Stream.h"
13 #include "Logging_Handler.h"
15 class Logging_Event_Handler : public ACE_Event_Handler
17 protected:
18 // File where log records are written.
19 ACE_FILE_IO log_file_;
21 // Connection to remote peer.
22 Logging_Handler logging_handler_;
24 public:
25 // Initialize the base class and logging handler.
26 Logging_Event_Handler (ACE_Reactor *reactor)
27 : ACE_Event_Handler (reactor),
28 logging_handler_ (log_file_) {};
30 virtual ~Logging_Event_Handler () {}; // No-op destructor.
32 // Activate the object.
33 virtual int open ();
35 // Called by a reactor when logging events arrive.
36 virtual int handle_input (ACE_HANDLE = ACE_INVALID_HANDLE);
38 // Called when this object is destroyed, e.g., when it's
39 // removed from a reactor.
40 virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE,
41 ACE_Reactor_Mask = 0);
43 // Return socket handle of the contained <Logging_Handler>.
44 virtual ACE_HANDLE get_handle () const {
45 // Need a non-const reference to call peer(), but that's
46 // safe since we call a const method using it.
47 Logging_Handler& h =
48 const_cast<Logging_Handler&> (logging_handler_);
49 return h.peer ().get_handle ();
52 // Get a reference to the contained <ACE_SOCK_Stream>.
53 ACE_SOCK_Stream &peer () { return logging_handler_.peer (); };
55 // Return a reference to the <log_file_>.
56 ACE_FILE_IO &log_file () { return log_file_; };
59 #endif /* _LOGGING_EVENT_HANDLER_H */