Monitor_Base.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  * @file Monitor_Base.h
00006  *
00007  * $Id: Monitor_Base.h 81691 2008-05-14 11:09:21Z johnnyw $
00008  *
00009  * @author Jeff Parsons <j.parsons@vanderbilt.edu>
00010  */
00011 //=============================================================================
00012 
00013 #ifndef MONITOR_BASE_H
00014 #define MONITOR_BASE_H
00015 
00016 #include /**/ "ace/pre.h"
00017 
00018 #include "ace/Monitor_Control_Types.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 #pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)
00025 
00026 #include "ace/Refcountable_T.h"
00027 #include "ace/Thread_Mutex.h"
00028 #include "ace/Synch_Traits.h"
00029 
00030 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00031 
00032 class ETCL_Constraint;
00033 
00034 namespace ACE
00035 {
00036   namespace Monitor_Control
00037   {
00038     class Control_Action;
00039 
00040     /**
00041      * @class Monitor_Base
00042      *
00043      * @brief Base class from which the template monitor point class is
00044      *        derived.
00045      *
00046      * All the operations are pure virtual so they can
00047      * be implemented in the 'disabled' template specialization
00048      * as no-ops.
00049      */
00050     class ACE_Export Monitor_Base
00051       : private ACE_Refcountable_T<ACE_SYNCH_MUTEX>
00052     {
00053     public:
00054       typedef Monitor_Control_Types::ConstraintList CONSTRAINTS;
00055       typedef CONSTRAINTS::const_iterator CONSTRAINT_ITERATOR;
00056 
00057       /// Implemented by the most-derived class. Does the actual
00058       /// work of fetching the monitored value.
00059       virtual void update (void) = 0;
00060 
00061       /// Updates the monitor's data if it is a numeric floating point.
00062       virtual void receive (double value);
00063 
00064       /// Updates the monitor's data if it is an integer size.
00065       virtual void receive (size_t value);
00066 
00067       /// Add a constraint, returns a unique constraint id.
00068       long add_constraint (const char* expression,
00069                            Control_Action* action = 0);
00070 
00071       /// Remove a constraint and return the associated control action,
00072       /// which may be shared, for deletion or further use.
00073       Control_Action* remove_constraint (const long constraint_id);
00074 
00075       /// Get all constraints
00076       CONSTRAINTS& constraints (void);
00077 
00078       /// Reset function.
00079       void clear (void);
00080 
00081       /// Data accessors.
00082       void retrieve (Monitor_Control_Types::Data& data) const;
00083       void retrieve_and_clear (Monitor_Control_Types::Data& data);
00084 
00085       /// Common to all monitors.
00086 
00087       void add_to_registry (
00088         const ACE_Time_Value& time = ACE_Time_Value::zero);
00089       void remove_from_registry (void);
00090 
00091       const char* name (void) const;
00092       void name (const char* new_name);
00093 
00094       void add_ref (void);
00095       void remove_ref (void);
00096 
00097     protected:
00098       Monitor_Base (void);
00099       Monitor_Base (const char* name);
00100       virtual ~Monitor_Base (void);
00101 
00102       /// Overridden in some monitors (for example the OS monitors) where
00103       /// clearing requires monitor-specific actions.
00104       virtual void clear_i (void);
00105 
00106     protected:
00107       Monitor_Control_Types::Data data_;
00108       mutable ACE_SYNCH_MUTEX mutex_;
00109 
00110       CONSTRAINTS constraints_;
00111 
00112     private:
00113       ACE_CString name_;
00114     };
00115   }
00116 }
00117 
00118 ACE_END_VERSIONED_NAMESPACE_DECL
00119 
00120 #if defined (__ACE_INLINE__)
00121 #include "ace/Monitor_Base.inl"
00122 #endif /* __ACE_INLINE__ */
00123 
00124 #endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
00125 
00126 #include /**/ "ace/post.h"
00127 
00128 #endif // MONITOR_BASE_H

Generated on Tue Feb 2 17:18:41 2010 for ACE by  doxygen 1.4.7