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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
#include "PolicyFactory_Registry.h"
ACE_RCSID (tao,
PolicyFactory_Registry,
"$Id$")
// ****************************************************************
TAO_PolicyFactory_Registry::TAO_PolicyFactory_Registry (void)
: factories_ (TAO_DEFAULT_POLICY_FACTORY_REGISTRY_SIZE)
{
}
TAO_PolicyFactory_Registry::~TAO_PolicyFactory_Registry (void)
{
TABLE::ITERATOR end = this->factories_.end ();
for (TABLE::ITERATOR i = this->factories_.begin (); i != end; ++i)
CORBA::release ((*i).int_id_);
this->factories_.close ();
}
void
TAO_PolicyFactory_Registry::register_policy_factory (
CORBA::PolicyType type,
PortableInterceptor::PolicyFactory_ptr policy_factory
ACE_ENV_ARG_DECL)
{
if (CORBA::is_nil (policy_factory))
ACE_THROW (CORBA::BAD_PARAM (
CORBA_SystemException::_tao_minor_code (
TAO_DEFAULT_MINOR_CODE,
EINVAL),
CORBA::COMPLETED_NO));
PortableInterceptor::PolicyFactory_ptr factory =
PortableInterceptor::PolicyFactory::_duplicate (policy_factory);
int result = this->factories_.bind (type,
factory);
if (result == 1)
{
// PolicyFactory of given type already exists.
ACE_THROW (CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 16,
CORBA::COMPLETED_NO));
}
else if (result == -1)
{
// Could not add PolicyFactory due to internal bind failures.
ACE_THROW (CORBA::INTERNAL ());
}
}
CORBA::Policy_ptr
TAO_PolicyFactory_Registry::create_policy (CORBA::PolicyType type,
const CORBA::Any &value
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
CORBA::PolicyError))
{
PortableInterceptor::PolicyFactory_ptr policy_factory =
PortableInterceptor::PolicyFactory::_nil ();
if (this->factories_.find (type,
policy_factory) == -1)
{
// Policy factory corresponding to given policy type does not
// exist in policy factory map.
ACE_THROW_RETURN (
CORBA::PolicyError (CORBA::BAD_POLICY_TYPE), // @@ Right exception?
CORBA::Policy::_nil ());
}
return policy_factory->create_policy (type,
value
ACE_ENV_ARG_PARAMETER);
}
CORBA::Policy_ptr
TAO_PolicyFactory_Registry::_create_policy (CORBA::PolicyType type
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
CORBA::PolicyError))
{
PortableInterceptor::PolicyFactory_ptr policy_factory =
PortableInterceptor::PolicyFactory::_nil ();
if (this->factories_.find (type,
policy_factory) == -1)
{
// Policy factory corresponding to given policy type does not
// exist in policy factory map.
ACE_THROW_RETURN (
CORBA::PolicyError (CORBA::BAD_POLICY_TYPE), // @@ Right exception?
CORBA::Policy::_nil ());
}
return policy_factory->_create_policy (type
ACE_ENV_ARG_PARAMETER);
}
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
template class ACE_Map_Entry<CORBA::PolicyType, PortableInterceptor::PolicyFactory_ptr>;
template class ACE_Map_Iterator_Base<CORBA::PolicyType, PortableInterceptor::PolicyFactory_ptr, ACE_Null_Mutex>;
template class ACE_Map_Iterator<CORBA::PolicyType, PortableInterceptor::PolicyFactory_ptr, ACE_Null_Mutex>;
template class ACE_Map_Reverse_Iterator<CORBA::PolicyType, PortableInterceptor::PolicyFactory_ptr, ACE_Null_Mutex>;
template class ACE_Map_Manager<CORBA::PolicyType, PortableInterceptor::PolicyFactory_ptr, ACE_Null_Mutex>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
#pragma instantiate ACE_Map_Entry<CORBA::PolicyType, PortableInterceptor::PolicyFactory_ptr>
#pragma instantiate ACE_Map_Iterator_Base<CORBA::PolicyType, PortableInterceptor::PolicyFactory_ptr, ACE_Null_Mutex>
#pragma instantiate ACE_Map_Iterator<CORBA::PolicyType, PortableInterceptor::PolicyFactory_ptr, ACE_Null_Mutex>
#pragma instantiate ACE_Map_Reverse_Iterator<CORBA::PolicyType, PortableInterceptor::PolicyFactory_ptr, ACE_Null_Mutex>
#pragma instantiate ACE_Map_Manager<CORBA::PolicyType, PortableInterceptor::PolicyFactory_ptr, ACE_Null_Mutex>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
|