blob: e99e21d80cd3bec09829254f8271a17ed482783c (
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
|
#ifndef CONTROL_REGISTRY_H
#define CONTROL_REGISTRY_H
#include /**/ "ace/pre.h"
#include "tao/TAO_Singleton.h"
#include "tao/Monitor/Monitor.h"
#include "orbsvcs/Notify/MonitorControl/Control.h"
#include "ace/Hash_Map_Manager_T.h"
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
class TAO_Notify_MC_Export TAO_Control_Registry
{
public:
/// Reusing NameList that comes from the TAO Monitor library.
typedef Monitor::NameList NameList;
/// Exception thrown in the event that something goes wrong
/// when adding to the registry
class TAO_Notify_MC_Export Map_Error
{
public:
enum ErrorReason
{
MAP_ERROR_BIND_FAILURE,
MAP_ERROR_INVALID_VALUE
};
ErrorReason why_;
Map_Error (ErrorReason why)
: why_ (why)
{
}
};
/// Return the singleton instance of the registry
static TAO_Control_Registry* instance ();
/// Empty out the map of objects
~TAO_Control_Registry ();
/// Adds an object to the map.
/// Throws Map_Error if the object is null or if there
/// is a fatal error adding it to the map.
/// Returns true if the object is successfully added to the map.
/// Returns false otherwise.
bool add (TAO_NS_Control* type);
/// Removes an object from the map.
/// Returns true if the object is successfully removed from the map.
/// Returns false otherwise.
bool remove (const ACE_CString& name);
/// Returns a list of names stored in the registry
const NameList& names ();
/// Gets an object from the map
/// Returns the object if it is successfully located.
/// Returns null otherwise.
TAO_NS_Control* get (const ACE_CString& name) const;
private:
typedef ACE_Hash_Map_Manager<ACE_CString,
TAO_NS_Control*,
ACE_SYNCH_NULL_MUTEX>
Map;
mutable TAO_SYNCH_RW_MUTEX mutex_;
Map map_;
NameList name_cache_;
};
TAO_END_VERSIONED_NAMESPACE_DECL
#include /**/ "ace/post.h"
#endif /* CONTROL_REGISTRY_H */
|