Use =default for skeleton copy constructor
[ACE_TAO.git] / ACE / ace / Monitor_Admin.cpp
blobd739c88fbe2abdd08dc566e2bb9eb0c5a0e4a342
1 #include "ace/Monitor_Admin.h"
3 #if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
5 #include "ace/Reactor.h"
6 #include "ace/Monitor_Point_Registry.h"
8 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
10 namespace ACE
12 namespace Monitor_Control
14 int
15 Monitor_Point_Auto_Updater::handle_timeout (
16 const ACE_Time_Value& /* current_time */,
17 const void* monitor_point)
19 const Monitor_Base* const_mp =
20 reinterpret_cast<const Monitor_Base*> (monitor_point);
21 Monitor_Base* mp = const_cast<Monitor_Base*> (const_mp);
22 mp->update ();
23 return 0;
26 //====================================================================
28 Monitor_Admin::Monitor_Admin ()
29 : reactor_ (ACE_Reactor::instance ()),
30 default_reactor_ (true)
33 Monitor_Admin::~Monitor_Admin ()
35 if (this->default_reactor_)
37 /// Destroys the timers associated with our event handler
38 /// before its destructor is called.
39 ACE_Reactor::instance ()->close_singleton ();
42 /// We access the registry through ACE_Singleton, which
43 /// doesn't call the destructor, so we call this method to
44 /// do a remove_ref() on all monitor points left in the registry.
45 /// which needs to be done before the registry goes away.
46 Monitor_Point_Registry::instance ()->cleanup ();
49 bool
50 Monitor_Admin::monitor_point (Monitor_Base* monitor_point,
51 const ACE_Time_Value& time)
53 /// This call checks for a null monitor_point.
54 bool good_reg_add =
55 Monitor_Point_Registry::instance ()->add (monitor_point);
57 if (!good_reg_add)
59 ACELIB_ERROR_RETURN ((LM_ERROR,
60 "registration of %s failed\n",
61 monitor_point->name ()),
62 good_reg_add);
64 else if (time != ACE_Time_Value::zero)
66 this->reactor_->schedule_timer (&this->auto_updater_,
67 monitor_point,
68 ACE_Time_Value::zero,
69 time);
72 return good_reg_add;
75 Monitor_Base*
76 Monitor_Admin::monitor_point (const char* name)
78 ACE_CString name_str (name, 0, false);
79 return Monitor_Point_Registry::instance ()->get (name_str);
82 void
83 Monitor_Admin::auto_query (ACE_Event_Handler* handler,
84 Monitor_Query* query,
85 const ACE_Time_Value& time)
87 this->reactor_->schedule_timer (handler,
88 query,
89 ACE_Time_Value::zero,
90 time);
93 void
94 Monitor_Admin::reactor (ACE_Reactor* new_reactor)
96 this->reactor_ = new_reactor;
97 this->default_reactor_ = false;
100 ACE_Reactor*
101 Monitor_Admin::reactor () const
103 return this->reactor_;
108 ACE_END_VERSIONED_NAMESPACE_DECL
110 #endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */