00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Monitor_Admin.h 00006 * 00007 * $Id: Monitor_Admin.h 81691 2008-05-14 11:09:21Z johnnyw $ 00008 * 00009 * @author Jeff Parsons <j.parsons@vanderbilt.edu> 00010 */ 00011 //============================================================================= 00012 00013 #ifndef MONITOR_ADMIN_H 00014 #define MONITOR_ADMIN_H 00015 00016 #include /**/ "ace/pre.h" 00017 00018 #include "ace/Event_Handler.h" 00019 00020 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00021 #pragma once 00022 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00023 00024 #if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1) 00025 00026 #include "ace/Monitor_Base.h" 00027 00028 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00029 00030 namespace ACE 00031 { 00032 namespace Monitor_Control 00033 { 00034 class MonitorQuery; 00035 00036 /** 00037 * @class Monitor_Point_Auto_Updater 00038 * 00039 * @brief Automates periodic updating of monitor point classes. 00040 * 00041 * A single instance of this class is held by the Admin 00042 * class below. For a monitor point that must periodically 00043 * check what they are monitoring, the admin class registers 00044 * the monitor point with the ACE reactor. Each time the 00045 * interval times out, the reactor will call the 00046 * handle_timeout() method below, and pass in the appropriate 00047 * monitor point. The handle_timeout() method will in turn 00048 * call the appropriate method on the monitor point to get 00049 * it to update its data. 00050 */ 00051 class Monitor_Point_Auto_Updater : public ACE_Event_Handler 00052 { 00053 public: 00054 /// Override of ACE base class method. 00055 virtual int handle_timeout (const ACE_Time_Value& interval, 00056 const void* monitor_point); 00057 }; 00058 00059 /** 00060 * @class Admin 00061 * 00062 * @brief Accesses monitor points or groups and manages the registries. 00063 * 00064 * Responsible for adding and removing monitor points and creating 00065 * automatic periodic actions that update or query monitor points. 00066 */ 00067 class ACE_Export Monitor_Admin 00068 { 00069 public: 00070 Monitor_Admin (void); 00071 ~Monitor_Admin (void); 00072 00073 /// Add or access monitor points in a global registry 00074 /// If the ACE_Time_Value arg is non-zero, 00075 /// the monitor point, the auto updater member, and the given time 00076 /// interval are passed to our reactor's register_timeout() 00077 /// method. 00078 00079 bool monitor_point (Monitor_Base* monitor_point, 00080 const ACE_Time_Value& time); 00081 Monitor_Base* monitor_point (const char* name); 00082 00083 /// Works similarly to monitor_point() above, but registers the 00084 /// handler arg's handle_timeout() method with the reactor, 00085 /// instead of our auto_updater_'s handle_timeout(). 00086 void auto_query (ACE_Event_Handler* handler, 00087 MonitorQuery* query, 00088 const ACE_Time_Value& time); 00089 00090 /// This mutator allows the application to create its own reactor 00091 /// and substitute it for the default reactor. 00092 void reactor (ACE_Reactor* new_reactor); 00093 ACE_Reactor* reactor (void) const; 00094 00095 private: 00096 Monitor_Point_Auto_Updater auto_updater_; 00097 ACE_Reactor* reactor_; 00098 bool default_reactor_; 00099 }; 00100 } 00101 } 00102 00103 ACE_END_VERSIONED_NAMESPACE_DECL 00104 00105 #endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */ 00106 00107 #include /**/ "ace/post.h" 00108 00109 #endif // MONITOR_ADMIN_H