Initial Patch of Auction House bot rev. 135
[auctionmangos.git] / dep / ACE_wrappers / ace / Monitor_Admin.cpp
blob5c60b2b902ed4729ec2a2a9857b06c9358b8bbdc
1 // $Id: Monitor_Admin.cpp 81753 2008-05-21 19:02:47Z parsons $
3 #include "ace/Monitor_Admin.h"
5 #if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
7 #include "ace/Reactor.h"
8 #include "ace/Monitor_Point_Registry.h"
10 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
12 namespace ACE
14 namespace Monitor_Control
16 int
17 Monitor_Point_Auto_Updater::handle_timeout (
18 const ACE_Time_Value& /* current_time */,
19 const void* monitor_point)
21 const Monitor_Base* const_mp =
22 reinterpret_cast<const Monitor_Base*> (monitor_point);
23 Monitor_Base* mp = const_cast<Monitor_Base*> (const_mp);
24 mp->update ();
25 return 0;
28 //====================================================================
30 Monitor_Admin::Monitor_Admin (void)
31 : reactor_ (ACE_Reactor::instance ()),
32 default_reactor_ (true)
35 Monitor_Admin::~Monitor_Admin (void)
37 if (this->default_reactor_)
39 /// Destroys the timers associated with our event handler
40 /// before its destructor is called.
41 ACE_Reactor::instance ()->close_singleton ();
44 /// We access the registry through ACE_Singleton, which
45 /// doesn't call the destructor, so we call this method to
46 /// do a remove_ref() on all monitor points left in the registry.
47 /// which needs to be done before the registry goes away.
48 Monitor_Point_Registry::instance ()->cleanup ();
51 bool
52 Monitor_Admin::monitor_point (Monitor_Base* monitor_point,
53 const ACE_Time_Value& time)
55 /// This call checks for a null monitor_point.
56 bool good_reg_add =
57 Monitor_Point_Registry::instance ()->add (monitor_point);
59 if (!good_reg_add)
61 ACE_ERROR_RETURN ((LM_ERROR,
62 "registration of %s failed\n",
63 monitor_point->name ()),
64 good_reg_add);
66 else if (time != ACE_Time_Value::zero)
68 this->reactor_->schedule_timer (&this->auto_updater_,
69 monitor_point,
70 ACE_Time_Value::zero,
71 time);
74 return good_reg_add;
77 Monitor_Base*
78 Monitor_Admin::monitor_point (const char* name)
80 ACE_CString name_str (name, 0, false);
81 return Monitor_Point_Registry::instance ()->get (name_str);
84 void
85 Monitor_Admin::auto_query (ACE_Event_Handler* handler,
86 Monitor_Query* query,
87 const ACE_Time_Value& time)
89 this->reactor_->schedule_timer (handler,
90 query,
91 ACE_Time_Value::zero,
92 time);
95 void
96 Monitor_Admin::reactor (ACE_Reactor* new_reactor)
98 this->reactor_ = new_reactor;
99 this->default_reactor_ = false;
102 ACE_Reactor*
103 Monitor_Admin::reactor (void) const
105 return this->reactor_;
110 ACE_END_VERSIONED_NAMESPACE_DECL
112 #endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */