1 #include "ace/Monitor_Point_Registry.h"
2 #include "ace/Monitor_Base.h"
3 #include "ace/Monitor_Control_Action.h"
5 #include "ace/Monitor_Control/Monitor_Query.h"
6 #include "ace/Monitor_Control/Constraint_Interpreter.h"
7 #include "ace/Monitor_Control/Constraint_Visitor.h"
9 #if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
11 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
15 namespace Monitor_Control
17 Monitor_Point_Auto_Query::Monitor_Point_Auto_Query ()
22 Monitor_Point_Auto_Query::handle_timeout (
23 const ACE_Time_Value
& /* current */,
24 const void* monitor_query
)
26 const Monitor_Query
* const_mq
=
27 reinterpret_cast<const Monitor_Query
*> (monitor_query
);
29 Monitor_Query
* mq
= const_cast<Monitor_Query
*> (const_mq
);
36 //=========================================================
38 Monitor_Query::Monitor_Query (const char* monitor_name
)
41 ACE_CString
name_str (monitor_name
, 0, false);
42 this->monitor_
= Monitor_Point_Registry::instance ()->get (name_str
);
44 if (this->monitor_
== 0)
46 ACELIB_ERROR ((LM_ERROR
, "Monitor_Query - monitor lookup failed\n"));
51 Monitor_Query::query ()
53 if (this->monitor_
== 0)
55 ACELIB_ERROR ((LM_ERROR
, "Monitor_Query::query - null monitor\n"));
59 Monitor_Base::CONSTRAINTS
& list
= this->monitor_
->constraints ();
61 for (Monitor_Base::CONSTRAINT_ITERATOR
i (list
.begin ());
65 Constraint_Interpreter interpreter
;
66 interpreter
.build_tree (i
->second
.expr
.fast_rep ());
68 Monitor_Control_Types::Data
data (this->monitor_
->type ());
69 this->monitor_
->retrieve (data
);
70 Constraint_Visitor
visitor (data
);
71 bool satisfied
= interpreter
.evaluate (visitor
);
73 if (satisfied
&& i
->second
.control_action
!= 0)
75 i
->second
.control_action
->execute ();
82 ACE_END_VERSIONED_NAMESPACE_DECL
84 #endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */