Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Monitor_Control / Windows_Monitor.cpp
blob2759ee6c2a0f4da9953845a3e51a0555b0172bc2
1 #include "ace/Monitor_Control/Windows_Monitor.h"
3 #if defined (ACE_HAS_WIN32_PDH)
5 #include "ace/Log_Category.h"
7 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
9 namespace ACE
11 namespace Monitor_Control
13 Windows_Monitor::Windows_Monitor (const ACE_TCHAR *path)
14 : value_ (0.0)
15 , path_ (path)
16 , query_ (0)
17 , counter_ (0)
18 , status_ (ERROR_SUCCESS)
20 this->init ();
23 void
24 Windows_Monitor::update_i ()
26 PdhCollectQueryData (this->query_);
27 PDH_FMT_COUNTERVALUE pdh_value;
29 PdhGetFormattedCounterValue (this->counter_,
30 PDH_FMT_DOUBLE,
32 &pdh_value);
34 this->value_ = pdh_value.doubleValue;
37 void
38 Windows_Monitor::clear_impl ()
40 this->init ();
43 void
44 Windows_Monitor::init ()
46 /// Create a query and a counter here so it doesn't have
47 /// to be done with each update.
49 this->status_ = ACE_TEXT_PdhOpenQuery (0, 0, &this->query_);
51 if (ERROR_SUCCESS != this->status_)
53 ACELIB_ERROR ((LM_DEBUG, ACE_TEXT ("PdhOpenQuery failed\n")));
56 this->status_ =
57 ACE_TEXT_PdhAddCounter (this->query_,
58 this->path_.c_str (),
60 &this->counter_);
62 if (ERROR_SUCCESS != this->status_)
64 ACELIB_ERROR ((LM_DEBUG,
65 ACE_TEXT ("PdhAddCounter %s failed\n"),
66 this->path_.c_str ()));
72 ACE_END_VERSIONED_NAMESPACE_DECL
74 #endif /* defined (ACE_HAS_WIN32_PDH) */