summaryrefslogtreecommitdiff
path: root/ACE/ace/Monitor_Base.h
diff options
context:
space:
mode:
authorJohnny Willemsen <jwillemsen@remedy.nl>2008-04-28 10:33:06 +0000
committerJohnny Willemsen <jwillemsen@remedy.nl>2008-04-28 10:33:06 +0000
commita6e4862a47ce814fc57a21dd1c588945d666c2c6 (patch)
tree470b30489e93bf7832f87b0c17e8f5797abd9fdb /ACE/ace/Monitor_Base.h
parentec52b1be10867395b69481557e8076a27642b25d (diff)
downloadATCD-a6e4862a47ce814fc57a21dd1c588945d666c2c6.tar.gz
Diffstat (limited to 'ACE/ace/Monitor_Base.h')
-rw-r--r--ACE/ace/Monitor_Base.h128
1 files changed, 128 insertions, 0 deletions
diff --git a/ACE/ace/Monitor_Base.h b/ACE/ace/Monitor_Base.h
new file mode 100644
index 00000000000..859deb8cea3
--- /dev/null
+++ b/ACE/ace/Monitor_Base.h
@@ -0,0 +1,128 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file Monitor_Base.h
+ *
+ * $Id$
+ *
+ * @author Jeff Parsons <j.parsons@vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef MONITOR_BASE_H
+#define MONITOR_BASE_H
+
+#include /**/ "ace/pre.h"
+
+#include "ace/Monitor_Control_Types.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
+
+#include "ace/Refcountable_T.h"
+#include "ace/Thread_Mutex.h"
+#include "ace/Synch_Traits.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+class ETCL_Constraint;
+
+namespace ACE
+{
+ namespace MonitorControl
+ {
+ class Control_Action;
+
+ /**
+ * @class Monitor_Base
+ *
+ * @brief Base class from which the template monitor point class is
+ * derived.
+ *
+ * All the operations are pure virtual so they can
+ * be implemented in the 'disabled' template specialization
+ * as no-ops.
+ */
+ class ACE_Export Monitor_Base
+ : private ACE_Refcountable_T<ACE_SYNCH_MUTEX>
+ {
+ public:
+ typedef Monitor_Control_Types::ConstraintList CONSTRAINTS;
+ typedef CONSTRAINTS::const_iterator CONSTRAINT_ITERATOR;
+
+ /// Implemented by the most-derived class. Does the actual
+ /// work of fetching the monitored value.
+ virtual void update (void) = 0;
+
+ /// Updates the monitor's data if it is a numeric floating point.
+ virtual void receive (double value);
+
+ /// Updates the monitor's data if it is an integer size.
+ virtual void receive (size_t value);
+
+ /// Add a constraint, returns a unique constraint id.
+ long add_constraint (const char* expression,
+ Control_Action* action = 0);
+
+ /// Remove a constraint and return the associated control action,
+ /// which may be shared, for deletion or further use.
+ Control_Action* remove_constraint (const long constraint_id);
+
+ /// Get all constraints
+ CONSTRAINTS& constraints (void);
+
+ /// Reset function.
+ void clear (void);
+
+ /// Data accessors.
+ void retrieve (Monitor_Control_Types::Data& data) const;
+ void retrieve_and_clear (Monitor_Control_Types::Data& data);
+
+ /// Common to all monitors.
+
+ void add_to_registry (
+ const ACE_Time_Value& time = ACE_Time_Value::zero);
+ void remove_from_registry (void);
+
+ const char* name (void) const;
+ void name (const char* new_name);
+
+ void add_ref (void);
+ void remove_ref (void);
+
+ protected:
+ Monitor_Base (void);
+ Monitor_Base (const char* name);
+ virtual ~Monitor_Base (void);
+
+ /// Overridden in some monitors (for example the OS monitors) where
+ /// clearing requires monitor-specific actions.
+ virtual void clear_i (void);
+
+ protected:
+ Monitor_Control_Types::Data data_;
+ mutable ACE_SYNCH_MUTEX mutex_;
+
+ CONSTRAINTS constraints_;
+
+ private:
+ ACE_CString name_;
+ };
+ }
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#if defined (__ACE_INLINE__)
+#include "ace/Monitor_Base.inl"
+#endif /* __ACE_INLINE__ */
+
+#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
+
+#include /**/ "ace/post.h"
+
+#endif // MONITOR_BASE_H