Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / PI_Server / PortableServer_PolicyFactory.cpp
blob9318c7f01935bb26ea2d9aebbd11e21bd9ce545f
1 // -*- C++ -*-
2 #include "tao/PI_Server/PortableServer_PolicyFactory.h"
3 #include "tao/PortableServer/ThreadPolicy.h"
4 #include "tao/PortableServer/LifespanPolicy.h"
5 #include "tao/PortableServer/IdAssignmentPolicy.h"
6 #include "tao/PortableServer/IdUniquenessPolicy.h"
7 #include "tao/PortableServer/ImplicitActivationPolicy.h"
8 #include "tao/PortableServer/RequestProcessingPolicy.h"
9 #include "tao/PortableServer/ServantRetentionPolicy.h"
10 #include "tao/PortableServer/PortableServer.h"
11 #include "tao/PI_Server/Policy_Creator_T.h"
13 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
15 CORBA::Policy_ptr
16 TAO_PortableServer_PolicyFactory::create_policy (
17 CORBA::PolicyType type,
18 const CORBA::Any &value)
20 #if !defined (CORBA_E_MICRO)
21 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT)
23 if (type == ::PortableServer::THREAD_POLICY_ID)
25 TAO::Portable_Server::ThreadPolicy *thread_policy = 0;
26 PortableServer::ThreadPolicyValue thr_value;
28 TAO::Portable_Server::create_policy (thread_policy, thr_value, value);
30 return thread_policy;
33 #endif /* TAO_HAS_MINIMUM_POA == 0 */
34 if (type == PortableServer::LIFESPAN_POLICY_ID)
36 TAO::Portable_Server::LifespanPolicy *lifespan_policy = 0;
37 PortableServer::LifespanPolicyValue lifespan_value;
39 TAO::Portable_Server::create_policy (lifespan_policy, lifespan_value, value);
41 return lifespan_policy;
44 if (type == PortableServer::ID_UNIQUENESS_POLICY_ID)
46 TAO::Portable_Server::IdUniquenessPolicy *id_uniqueness_policy = 0;
47 PortableServer::IdUniquenessPolicyValue id_uniqueness_value;
49 TAO::Portable_Server::create_policy (id_uniqueness_policy, id_uniqueness_value, value);
51 return id_uniqueness_policy;
54 if (type == PortableServer::ID_ASSIGNMENT_POLICY_ID)
56 TAO::Portable_Server::IdAssignmentPolicy *id_assignment_policy = 0;
57 PortableServer::IdAssignmentPolicyValue id_assignment_value;
59 TAO::Portable_Server::create_policy (id_assignment_policy, id_assignment_value, value);
61 return id_assignment_policy;
64 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT)
66 if (type == PortableServer::IMPLICIT_ACTIVATION_POLICY_ID)
68 TAO::Portable_Server::ImplicitActivationPolicy *implicit_activatation_policy = 0;
69 PortableServer::ImplicitActivationPolicyValue implicit_activation_value;
71 TAO::Portable_Server::create_policy (implicit_activatation_policy, implicit_activation_value, value);
73 return implicit_activatation_policy;
76 if (type == PortableServer::SERVANT_RETENTION_POLICY_ID)
78 TAO::Portable_Server::ServantRetentionPolicy *servant_retention_policy = 0;
79 PortableServer::ServantRetentionPolicyValue servant_retention_value;
81 TAO::Portable_Server::create_policy (servant_retention_policy, servant_retention_value, value);
83 return servant_retention_policy;
86 if (type == PortableServer::REQUEST_PROCESSING_POLICY_ID)
88 TAO::Portable_Server::RequestProcessingPolicy *request_processing_policy = 0;
89 PortableServer::RequestProcessingPolicyValue request_processing_value;
91 TAO::Portable_Server::create_policy (request_processing_policy, request_processing_value, value);
93 return request_processing_policy;
96 #endif /* TAO_HAS_MINIMUM_POA == 0 */
98 throw ::CORBA::PolicyError (CORBA::BAD_POLICY_TYPE);
99 #else
100 ACE_UNUSED_ARG (value);
101 ACE_UNUSED_ARG (type);
103 throw ::CORBA::PolicyError (CORBA::BAD_POLICY_TYPE);
104 #endif
107 TAO_END_VERSIONED_NAMESPACE_DECL