blob: 38e8f3ed507dd8753394632573ed543cd92516f9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
// -*- C++ -*-
//=============================================================================
/**
* @file Monitor_Point_Registry.h
*
* $Id$
*
* @author Jeff Parsons <j.parsons@vanderbilt.edu>
*/
//=============================================================================
#ifndef MONITOR_POINT_REGISTRY_H
#define MONITOR_POINT_REGISTRY_H
#include /**/ "ace/pre.h"
#include "ace/Thread_Mutex.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/Synch_Traits.h"
#include "ace/Null_Mutex.h"
#include "ace/Hash_Map_Manager_T.h"
#include "ace/Monitor_Control_Types.h"
#include "ace/Singleton.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
namespace ACE
{
namespace Monitor_Control
{
class Monitor_Base;
/**
* @class Monitor_Point_Registry
*
* @brief Storage for instantiated monitor points.
*
*/
class ACE_Export Monitor_Point_Registry
{
public:
friend class ACE_Singleton<Monitor_Point_Registry, ACE_SYNCH_MUTEX>;
/// Used to help ensure that there is only a single instance
/// per process of Monitor_Point_Registry.
static Monitor_Point_Registry* instance (void);
/// Adds a monitor to the registry.
bool add (Monitor_Base* type);
/// Remove a monitor from the registry.
bool remove (const char* name);
/// Returns a list of names stored in the registry
Monitor_Control_Types::NameList names (void);
/// Increments the refcount, so the caller is responsible for
/// decrementing it when finished.
Monitor_Base* get (const ACE_CString& name) const;
/// Returns a unique id for a constraint when it is created.
long constraint_id (void);
/// Decrements the reference count on all remaining entries,
/// called right before we go out of scope (i.e., process exits).
void cleanup (void);
private:
/// Prevent that users can make an instance.
Monitor_Point_Registry (void);
/// Underlying container for the registry.
typedef ACE_Hash_Map_Manager<ACE_CString,
Monitor_Base*,
ACE_SYNCH_NULL_MUTEX> Map;
mutable ACE_SYNCH_MUTEX mutex_;
Map map_;
/// Since we're accessed as a singleton, we can keep track of
/// dispensing unique ids for constraints.
long constraint_id_;
};
}
}
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */
#include /**/ "ace/post.h"
#endif // MONITOR_POINT_REGISTRY_H
|