00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Monitor_Point_Registry.h 00006 * 00007 * $Id: Monitor_Point_Registry.h 81691 2008-05-14 11:09:21Z johnnyw $ 00008 * 00009 * @author Jeff Parsons <j.parsons@vanderbilt.edu> 00010 */ 00011 //============================================================================= 00012 00013 #ifndef MONITOR_POINT_REGISTRY_H 00014 #define MONITOR_POINT_REGISTRY_H 00015 00016 #include /**/ "ace/pre.h" 00017 00018 #include "ace/Thread_Mutex.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/Synch_Traits.h" 00027 #include "ace/Null_Mutex.h" 00028 #include "ace/Hash_Map_Manager_T.h" 00029 #include "ace/Monitor_Control_Types.h" 00030 #include "ace/Singleton.h" 00031 00032 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00033 00034 namespace ACE 00035 { 00036 namespace Monitor_Control 00037 { 00038 class Monitor_Base; 00039 00040 /** 00041 * @class Monitor_Point_Registry 00042 * 00043 * @brief Storage for instantiated monitor points. 00044 * 00045 */ 00046 class ACE_Export Monitor_Point_Registry 00047 { 00048 public: 00049 friend class ACE_Singleton<Monitor_Point_Registry, ACE_SYNCH_MUTEX>; 00050 00051 /// Used to help ensure that there is only a single instance 00052 /// per process of Monitor_Point_Registry. 00053 static Monitor_Point_Registry* instance (void); 00054 00055 /// Adds a monitor to the registry. 00056 bool add (Monitor_Base* type); 00057 00058 /// Remove a monitor from the registry. 00059 bool remove (const char* name); 00060 00061 /// Returns a list of names stored in the registry 00062 Monitor_Control_Types::NameList names (void); 00063 00064 /// Increments the refcount, so the caller is responsible for 00065 /// decrementing it when finished. 00066 Monitor_Base* get (const ACE_CString& name) const; 00067 00068 /// Returns a unique id for a constraint when it is created. 00069 long constraint_id (void); 00070 00071 /// Decrements the reference count on all remaining entries, 00072 /// called right before we go out of scope (i.e., process exits). 00073 void cleanup (void); 00074 00075 private: 00076 /// Prevent that users can make an instance. 00077 Monitor_Point_Registry (void); 00078 00079 /// Underlying container for the registry. 00080 typedef ACE_Hash_Map_Manager<ACE_CString, 00081 Monitor_Base*, 00082 ACE_SYNCH_NULL_MUTEX> Map; 00083 00084 mutable ACE_SYNCH_MUTEX mutex_; 00085 Map map_; 00086 00087 /// Since we're accessed as a singleton, we can keep track of 00088 /// dispensing unique ids for constraints. 00089 long constraint_id_; 00090 }; 00091 } 00092 } 00093 00094 ACE_END_VERSIONED_NAMESPACE_DECL 00095 00096 #endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */ 00097 00098 #include /**/ "ace/post.h" 00099 00100 #endif // MONITOR_POINT_REGISTRY_H