1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
#include "ace/Log_Msg.h"
#include "ace/Monitor_Base.h"
#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
using namespace ACE_VERSIONED_NAMESPACE_NAME::ACE::Monitor_Control;
void
error (const char* msg)
{
#if defined (ACE_NLOGGING)
ACE_UNUSED_ARG (msg);
#endif /* ACE_NLOGGING */
ACE_ERROR ((LM_ERROR, "%s\n", msg));
ACE_OS::exit (1);
}
#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
int
ACE_TMAIN (int, ACE_TCHAR*[])
{
#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
try
{
Monitor_Base counter ("counter", Monitor_Control_Types::MC_COUNTER);
counter.receive (0.0);
counter.receive (0.0);
counter.receive (0.0);
if (!ACE::is_equal (counter.last_sample(), 3.0))
{
error ("Counter Monitor_Control::receive() failed");
}
Monitor_Base number ("number", Monitor_Control_Types::MC_NUMBER);
size_t size = 8;
number.receive (size);
size = 10;
number.receive (size);
size = 42;
number.receive (size);
if (!ACE::is_equal (number.average (), 20.0))
{
error ("Number Monitor_Base::average() failed");
}
if (!ACE::is_equal (number.minimum_sample (), 8.0))
{
error ("Number Monitor_Base::minimum_sample() failed");
}
if (!ACE::is_equal (number.maximum_sample (), 42.0))
{
error ("Number Monitor_Base::maximum_sample() failed");
}
if (!ACE::is_equal (number.sum_of_squares (), 1928.0))
{
error ("Number Monitor_Base::sum_of_squares() failed");
}
Monitor_Base stime ("time", Monitor_Control_Types::MC_TIME);
stime.receive (1183466309.01234);
stime.receive (1183466377.9922);
stime.receive (1083466309.88374);
if (!ACE::is_equal (stime.average (), 1150132998.96276))
{
error ("Time Monitor_Base::average() failed");
}
if (!ACE::is_equal (stime.minimum_sample (), 1083466309.88374))
{
error ("Time Monitor_Base::minimum_sample() failed");
}
if (!ACE::is_equal (stime.maximum_sample (), 1183466377.9922))
{
error ("Time Monitor_Base::maximum_sample() failed");
}
Monitor_Base interval ("interval", Monitor_Control_Types::MC_INTERVAL);
interval.receive (.8);
interval.receive (.1);
interval.receive (.42);
// This multiplication and casting is necessary since the machine
// representation of the floating point values in the receive()
// calls are not exactly what is represented by the text of the code.
if (static_cast<int> (interval.average () * 100) != 44)
{
error ("Interval Monitor_Base::average() failed");
}
if (!ACE::is_equal (interval.minimum_sample (), 0.1))
{
error ("Interval Monitor_Base::minimum_sample() failed");
}
if (!ACE::is_equal (interval.maximum_sample (), 0.8))
{
error ("Interval Monitor_Base::maximum_sample() failed");
}
if (static_cast<int> (interval.sum_of_squares () * 10000) != 8264)
{
error ("Interval Monitor_Base::sum_of_squares() failed");
}
Monitor_Base list ("list", Monitor_Control_Types::MC_LIST);
Monitor_Control_Types::NameList l;
l.push_back ("one");
l.push_back ("two");
l.push_back ("three");
list.receive (l);
if (list.count () != 3)
{
error ("List Monitor_Base::receive() failed");
}
/// Test for memory leaks (with valgrind).
list.clear ();
list.receive (l);
}
catch (...)
{
error ("Caught an unexpected exception type");
}
#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
return 0;
}
|