ACE::Monitor_Control::Monitor_Base Class Reference

Base class from which the template monitor point class is derived. More...

#include <Monitor_Base.h>

Inheritance diagram for ACE::Monitor_Control::Monitor_Base:

Inheritance graph
[legend]
Collaboration diagram for ACE::Monitor_Control::Monitor_Base:

Collaboration graph
[legend]
List of all members.

Public Types

typedef Monitor_Control_Types::ConstraintList CONSTRAINTS
typedef CONSTRAINTS::const_iterator CONSTRAINT_ITERATOR

Public Member Functions

virtual void update (void)=0
virtual void receive (double value)
 Updates the monitor's data if it is a numeric floating point.
virtual void receive (size_t value)
 Updates the monitor's data if it is an integer size.
long add_constraint (const char *expression, Control_Action *action=0)
 Add a constraint, returns a unique constraint id.
Control_Actionremove_constraint (const long constraint_id)
CONSTRAINTSconstraints (void)
 Get all constraints.
void clear (void)
 Reset function.
void retrieve (Monitor_Control_Types::Data &data) const
 Data accessors.
void retrieve_and_clear (Monitor_Control_Types::Data &data)
void add_to_registry (const ACE_Time_Value &time=ACE_Time_Value::zero)
 Common to all monitors.
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 Member Functions

 Monitor_Base (void)
 Monitor_Base (const char *name)
virtual ~Monitor_Base (void)
virtual void clear_i (void)

Protected Attributes

Monitor_Control_Types::Data data_
ACE_SYNCH_MUTEX mutex_
CONSTRAINTS constraints_

Private Attributes

ACE_CString name_

Detailed Description

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.

Definition at line 50 of file Monitor_Base.h.


Member Typedef Documentation

typedef CONSTRAINTS::const_iterator ACE::Monitor_Control::Monitor_Base::CONSTRAINT_ITERATOR

Definition at line 55 of file Monitor_Base.h.

typedef Monitor_Control_Types::ConstraintList ACE::Monitor_Control::Monitor_Base::CONSTRAINTS

Definition at line 54 of file Monitor_Base.h.


Constructor & Destructor Documentation

ACE::Monitor_Control::Monitor_Base::Monitor_Base ( void   )  [protected]

Definition at line 24 of file Monitor_Base.cpp.

00025       : ACE_Refcountable_T<ACE_SYNCH_MUTEX> (1)
00026     {
00027     }

ACE::Monitor_Control::Monitor_Base::Monitor_Base ( const char *  name  )  [protected]

Definition at line 29 of file Monitor_Base.cpp.

00030       : ACE_Refcountable_T<ACE_SYNCH_MUTEX> (1)
00031       , name_ (name)
00032     {
00033     }

ACE::Monitor_Control::Monitor_Base::~Monitor_Base ( void   )  [protected, virtual]

Definition at line 35 of file Monitor_Base.cpp.

00036     {
00037     }


Member Function Documentation

long ACE::Monitor_Control::Monitor_Base::add_constraint ( const char *  expression,
Control_Action action = 0 
)

Add a constraint, returns a unique constraint id.

Thread-safe and guaranteed to be unique.

This is thread-safe on its own so we don't have to guard it here.

Since we know external key is unique, we don't check for failure.

Definition at line 40 of file Monitor_Base.cpp.

References ACE_GUARD_RETURN, ACE_SYNCH_MUTEX, ACE::Monitor_Control::Control_Action::add_ref(), ACE::Monitor_Control::Monitor_Point_Registry::constraint_id(), and ACE::Monitor_Control::Monitor_Point_Registry::instance().

00042     {
00043       /// Thread-safe and guaranteed to be unique.
00044       long id = Monitor_Point_Registry::instance ()->constraint_id ();
00045 
00046       CONSTRAINTS::value_type entry;
00047       entry.first = id;
00048       entry.second.expr = expression;
00049       entry.second.control_action = action;
00050 
00051       /// This is thread-safe on its own so we don't have
00052       /// to guard it here.
00053       action->add_ref ();
00054 
00055       {
00056         ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, -1);
00057 
00058         /// Since we know external key is unique,
00059         /// we don't check for failure.
00060         (void) this->constraints_.insert (entry);
00061       }
00062 
00063       return id;
00064     }

void ACE::Monitor_Control::Monitor_Base::add_ref ( void   ) 

Definition at line 167 of file Monitor_Base.cpp.

Referenced by ACE::Monitor_Control::Monitor_Point_Registry::add().

00168     {
00169       (void) this->increment ();
00170     }

void ACE::Monitor_Control::Monitor_Base::add_to_registry ( const ACE_Time_Value time = ACE_Time_Value::zero  ) 

Common to all monitors.

Definition at line 142 of file Monitor_Base.cpp.

References ACE_ERROR, ACE::Monitor_Control::Monitor_Admin_Manager::admin(), ACE_Dynamic_Service< TYPE >::instance(), LM_ERROR, ACE::Monitor_Control::Monitor_Admin::monitor_point(), and ACE_OS::time().

00143     {
00144       MC_ADMINMANAGER *mgr =
00145         ACE_Dynamic_Service<MC_ADMINMANAGER>::instance ("MC_ADMINMANAGER");
00146 
00147       if (!mgr->admin ().monitor_point (this, time))
00148         {
00149           ACE_ERROR ((LM_ERROR,
00150                       "monitor point %s registration failed\n",
00151                       this->name ()));
00152         }
00153     }

void ACE::Monitor_Control::Monitor_Base::clear ( void   ) 

Reset function.

Reimplemented in ACE::Monitor_Control::Size_Monitor.

Definition at line 117 of file Monitor_Base.cpp.

References ACE_GUARD, ACE_SYNCH_MUTEX, and clear_i().

00118     {
00119       ACE_GUARD (ACE_SYNCH_MUTEX, guard, this->mutex_);
00120 
00121       this->clear_i ();
00122     }

void ACE::Monitor_Control::Monitor_Base::clear_i ( void   )  [protected, virtual]

Overridden in some monitors (for example the OS monitors) where clearing requires monitor-specific actions.

Definition at line 125 of file Monitor_Base.cpp.

References data_, ACE::Monitor_Control::Monitor_Control_Types::Data::timestamp_, ACE::Monitor_Control::Monitor_Control_Types::Data::value_, and ACE_Time_Value::zero.

Referenced by clear(), and retrieve_and_clear().

00126     {
00127       this->data_.value_ = 0.0;
00128       this->data_.timestamp_ = ACE_Time_Value::zero;
00129     }

Monitor_Base::CONSTRAINTS & ACE::Monitor_Control::Monitor_Base::constraints ( void   ) 

Get all constraints.

Definition at line 87 of file Monitor_Base.cpp.

References constraints_.

00088     {
00089       return this->constraints_;
00090     }

ACE_INLINE void ACE::Monitor_Control::Monitor_Base::name ( const char *  new_name  ) 

Definition at line 18 of file Monitor_Base.inl.

References name_.

00019     {
00020       this->name_ = new_name;
00021     }

ACE_INLINE const char * ACE::Monitor_Control::Monitor_Base::name ( void   )  const

Definition at line 11 of file Monitor_Base.inl.

References ACE_String_Base< CHAR >::c_str(), and name_.

Referenced by ACE::Monitor_Control::Monitor_Point_Registry::add().

00012     {
00013       return this->name_.c_str ();
00014     }

void ACE::Monitor_Control::Monitor_Base::receive ( size_t  value  )  [virtual]

Updates the monitor's data if it is an integer size.

Definition at line 100 of file Monitor_Base.cpp.

References ACE_GUARD, ACE_SYNCH_MUTEX, data_, ACE_OS::gettimeofday(), ACE::Monitor_Control::Monitor_Control_Types::Data::timestamp_, and ACE::Monitor_Control::Monitor_Control_Types::Data::value_.

00101     {
00102       ACE_GUARD (ACE_SYNCH_MUTEX, guard, this->mutex_);
00103 
00104       this->data_.timestamp_ = ACE_OS::gettimeofday ();
00105       this->data_.value_ = static_cast<double> (value);
00106     }

void ACE::Monitor_Control::Monitor_Base::receive ( double  value  )  [virtual]

Updates the monitor's data if it is a numeric floating point.

Definition at line 109 of file Monitor_Base.cpp.

References ACE_GUARD, ACE_SYNCH_MUTEX, data_, ACE_OS::gettimeofday(), ACE::Monitor_Control::Monitor_Control_Types::Data::timestamp_, and ACE::Monitor_Control::Monitor_Control_Types::Data::value_.

00110     {
00111       ACE_GUARD (ACE_SYNCH_MUTEX, guard, this->mutex_);
00112       this->data_.timestamp_ = ACE_OS::gettimeofday ();
00113       this->data_.value_ = data;
00114     }

Control_Action * ACE::Monitor_Control::Monitor_Base::remove_constraint ( const long  constraint_id  ) 

Remove a constraint and return the associated control action, which may be shared, for deletion or further use.

Definition at line 67 of file Monitor_Base.cpp.

References ACE_GUARD_RETURN, ACE_SYNCH_MUTEX, constraints_, ACE_Array_Map< Key, Value, EqualTo >::erase(), and ACE_Array_Map< Key, Value, EqualTo >::find().

00068     {
00069       Control_Action* retval = 0;
00070 
00071       {
00072         ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->mutex_, 0);
00073 
00074         CONSTRAINT_ITERATOR i = this->constraints_.find (constraint_id);
00075 
00076         if (i != this->constraints_.end ())
00077           {
00078             retval = i->second.control_action;
00079             (void) this->constraints_.erase (constraint_id);
00080           }
00081       }
00082 
00083       return retval;
00084     }

void ACE::Monitor_Control::Monitor_Base::remove_from_registry ( void   ) 

Definition at line 156 of file Monitor_Base.cpp.

References ACE_ERROR, ACE::Monitor_Control::Monitor_Point_Registry::instance(), and LM_ERROR.

00157     {
00158       if (!Monitor_Point_Registry::instance ()->remove (this->name ()))
00159         {
00160           ACE_ERROR ((LM_ERROR,
00161                       "monitor point %s unregistration failed\n",
00162                       this->name ()));
00163         }
00164     }

void ACE::Monitor_Control::Monitor_Base::remove_ref ( void   ) 

Definition at line 173 of file Monitor_Base.cpp.

References ACE_Refcountable_T< ACE_SYNCH_MUTEX >::decrement().

00174     {
00175       long const new_count = this->decrement ();
00176 
00177       if (new_count == 0)
00178         {
00179           delete this;
00180         }
00181     }

void ACE::Monitor_Control::Monitor_Base::retrieve ( Monitor_Control_Types::Data data  )  const

Data accessors.

Definition at line 93 of file Monitor_Base.cpp.

References ACE_GUARD, ACE_SYNCH_MUTEX, and data_.

00094     {
00095       ACE_GUARD (ACE_SYNCH_MUTEX, guard, this->mutex_);
00096       data = this->data_;
00097     }

void ACE::Monitor_Control::Monitor_Base::retrieve_and_clear ( Monitor_Control_Types::Data data  ) 

Definition at line 133 of file Monitor_Base.cpp.

References ACE_GUARD, ACE_SYNCH_MUTEX, clear_i(), and data_.

00134     {
00135       ACE_GUARD (ACE_SYNCH_MUTEX, guard, this->mutex_);
00136 
00137       data = this->data_;
00138       this->clear_i ();
00139     }

virtual void ACE::Monitor_Control::Monitor_Base::update ( void   )  [pure virtual]

Implemented by the most-derived class. Does the actual work of fetching the monitored value.

Implemented in ACE::Monitor_Control::Size_Monitor.


Member Data Documentation

CONSTRAINTS ACE::Monitor_Control::Monitor_Base::constraints_ [protected]

Definition at line 110 of file Monitor_Base.h.

Referenced by constraints(), and remove_constraint().

Monitor_Control_Types::Data ACE::Monitor_Control::Monitor_Base::data_ [protected]

Definition at line 107 of file Monitor_Base.h.

Referenced by clear_i(), receive(), retrieve(), and retrieve_and_clear().

ACE_SYNCH_MUTEX ACE::Monitor_Control::Monitor_Base::mutex_ [mutable, protected]

Definition at line 108 of file Monitor_Base.h.

ACE_CString ACE::Monitor_Control::Monitor_Base::name_ [private]

Definition at line 113 of file Monitor_Base.h.

Referenced by name().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:36:04 2010 for ACE by  doxygen 1.4.7