Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Monitor_Base.h
blobc327755e9566416df012d2c954486d99f0ea18b3
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Monitor_Base.h
7 * @author Jeff Parsons <j.parsons@vanderbilt.edu>
8 */
9 //=============================================================================
11 #ifndef MONITOR_BASE_H
12 #define MONITOR_BASE_H
14 #include /**/ "ace/pre.h"
16 #include "ace/Monitor_Control_Types.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 #pragma once
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
24 #include "ace/Refcountable_T.h"
25 #include "ace/Thread_Mutex.h"
26 #include "ace/Synch_Traits.h"
27 #include "ace/CDR_Base.h"
29 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
31 class ETCL_Constraint;
33 namespace ACE
35 namespace Monitor_Control
37 class Control_Action;
39 /**
40 * @class Monitor_Base
42 * @brief Base class from which the template monitor point class is
43 * derived.
45 class ACE_Export Monitor_Base
46 : private ACE_Refcountable_T<ACE_SYNCH_MUTEX>
48 public:
49 typedef Monitor_Control_Types::ConstraintList CONSTRAINTS;
50 typedef CONSTRAINTS::const_iterator CONSTRAINT_ITERATOR;
52 Monitor_Base (const char* name,
53 Monitor_Control_Types::Information_Type type);
54 virtual ~Monitor_Base ();
56 /// Implemented by the most-derived class. Does the actual
57 /// work of fetching the monitored value.
58 virtual void update ();
60 /// Updates the monitor's data if it is a numeric floating point.
61 virtual void receive (double data);
63 /// Updates the monitor's data if it is an integer size.
64 virtual void receive (size_t data);
66 /// Updates the monitor's data if it is a string type.
67 virtual void receive (const Monitor_Control_Types::NameList& data);
69 /// Add a constraint, returns a unique constraint id.
70 long add_constraint (const char* expression,
71 Control_Action* action = 0);
73 /// Remove a constraint and return the associated control action,
74 /// which may be shared, for deletion or further use.
75 Control_Action* remove_constraint (const long constraint_id);
77 /// Get all constraints
78 CONSTRAINTS& constraints ();
80 /// Reset function.
81 virtual void clear ();
83 /// Data accessors.
84 void retrieve (Monitor_Control_Types::Data& data) const;
85 void retrieve_and_clear (Monitor_Control_Types::Data& data);
87 /// Common to all monitors.
89 void add_to_registry (
90 const ACE_Time_Value& time = ACE_Time_Value::zero);
91 void remove_from_registry ();
93 const char* name () const;
94 void name (const char* new_name);
96 void add_ref ();
97 void remove_ref ();
99 /// Calculate the average of the accumulated samples.
100 double average () const;
102 /// Calculate the sum of the squares of the samples.
103 double sum_of_squares () const;
105 /// Returns the number of samples
106 size_t count () const;
108 /// Returns the minimum sample value
109 double minimum_sample () const;
111 /// Returns the maximum sample value
112 double maximum_sample () const;
114 /// Returns the most recent sample value
115 double last_sample () const;
117 /// Return the type of this statistic
118 Monitor_Control_Types::Information_Type type () const;
120 /// Return the list or error msg if wrong type.
121 Monitor_Control_Types::NameList get_list () const;
123 protected:
124 /// Overridden in some monitors (for example the OS monitors) where
125 /// clearing requires monitor-specific actions.
126 virtual void clear_i ();
128 protected:
129 Monitor_Control_Types::Data data_;
130 mutable ACE_SYNCH_MUTEX mutex_;
132 CONSTRAINTS constraints_;
134 private:
135 ACE_CString name_;
140 ACE_END_VERSIONED_NAMESPACE_DECL
142 #if defined (__ACE_INLINE__)
143 #include "ace/Monitor_Base.inl"
144 #endif /* __ACE_INLINE__ */
146 #endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
148 #include /**/ "ace/post.h"
150 #endif // MONITOR_BASE_H