Go to the documentation of this file.00001
00002
00003 #include "ace/Monitor_Point_Registry.h"
00004 #include "ace/Monitor_Base.h"
00005 #include "ace/Monitor_Control_Action.h"
00006
00007 #include "ace/Monitor_Control/Monitor_Query.h"
00008 #include "ace/Monitor_Control/Constraint_Interpreter.h"
00009 #include "ace/Monitor_Control/Constraint_Visitor.h"
00010
00011 #if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
00012
00013 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00014
00015 namespace ACE
00016 {
00017 namespace Monitor_Control
00018 {
00019 int
00020 Monitor_Point_Auto_Query::handle_timeout (
00021 const ACE_Time_Value& ,
00022 const void* monitor_query)
00023 {
00024 const Monitor_Query* const_mq =
00025 reinterpret_cast<const Monitor_Query*> (monitor_query);
00026
00027 Monitor_Query* mq = const_cast<Monitor_Query*> (const_mq);
00028
00029 mq->query ();
00030
00031 return 0;
00032 }
00033
00034
00035
00036 Monitor_Query::Monitor_Query (const char* monitor_name)
00037 : monitor_ (0)
00038 {
00039 ACE_CString name_str (monitor_name, 0, false);
00040 this->monitor_ = Monitor_Point_Registry::instance ()->get (name_str);
00041
00042 if (this->monitor_ == 0)
00043 {
00044 ACE_ERROR ((LM_ERROR, "Monitor_Query - monitor lookup failed\n"));
00045 }
00046 }
00047
00048 void
00049 Monitor_Query::query (void)
00050 {
00051 if (this->monitor_ == 0)
00052 {
00053 ACE_ERROR ((LM_ERROR, "Monitor_Query::query - null monitor\n"));
00054 return;
00055 }
00056
00057 Monitor_Base::CONSTRAINTS& list = this->monitor_->constraints ();
00058
00059 for (Monitor_Base::CONSTRAINT_ITERATOR i (list.begin ());
00060 i != list.end ();
00061 ++i)
00062 {
00063 Constraint_Interpreter interpreter;
00064 interpreter.build_tree (i->second.expr.fast_rep ());
00065
00066 Monitor_Control_Types::Data data (this->monitor_->type ());
00067 this->monitor_->retrieve (data);
00068 Constraint_Visitor visitor (data);
00069 bool satisfied = interpreter.evaluate (visitor);
00070
00071 if (satisfied && i->second.control_action != 0)
00072 {
00073 i->second.control_action->execute ();
00074 }
00075 }
00076 }
00077 }
00078 }
00079
00080 ACE_END_VERSIONED_NAMESPACE_DECL
00081
00082 #endif