1 #include "tao/ZIOP/ZIOP_PolicyFactory.h"
2 #include "tao/ZIOP/ZIOP.h"
3 #include "tao/ZIOP/ZIOP_Policy_i.h"
5 #include "tao/ORB_Constants.h"
6 #include "tao/AnyTypeCode/Any.h"
8 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
11 TAO_ZIOP_PolicyFactory::create_policy (
12 CORBA::PolicyType type
,
13 const CORBA::Any
&value
)
15 CORBA::Policy_ptr policy
= CORBA::Policy::_nil ();
19 case ZIOP::COMPRESSION_ENABLING_POLICY_ID
:
23 // Extract the value from the any.
24 if (!(value
>>= CORBA::Any::to_boolean (val
)))
26 throw CORBA::PolicyError (CORBA::BAD_POLICY_VALUE
);
29 ACE_NEW_THROW_EX (policy
,
30 TAO::CompressionEnablingPolicy (val
),
32 CORBA::SystemException::_tao_minor_code (
35 CORBA::COMPLETED_NO
));
39 case ZIOP::COMPRESSOR_ID_LEVEL_LIST_POLICY_ID
:
41 const ::Compression::CompressorIdLevelList
* val
= 0;
43 // Extract the value from the any.
46 throw CORBA::PolicyError (CORBA::BAD_POLICY_VALUE
);
49 ACE_NEW_THROW_EX (policy
,
50 TAO::CompressorIdLevelListPolicy (*val
),
52 CORBA::SystemException::_tao_minor_code (
55 CORBA::COMPLETED_NO
));
59 case ZIOP::COMPRESSION_LOW_VALUE_POLICY_ID
:
63 // Extract the value from the any.
66 throw CORBA::PolicyError (CORBA::BAD_POLICY_VALUE
);
69 ACE_NEW_THROW_EX (policy
,
70 TAO::CompressionLowValuePolicy (val
),
72 CORBA::SystemException::_tao_minor_code (
75 CORBA::COMPLETED_NO
));
79 case ZIOP::COMPRESSION_MIN_RATIO_POLICY_ID
:
81 ::Compression::CompressionRatio val
;
83 // Extract the value from the any.
86 throw CORBA::PolicyError (CORBA::BAD_POLICY_VALUE
);
89 ACE_NEW_THROW_EX (policy
,
90 TAO::CompressionMinRatioPolicy (val
),
92 CORBA::SystemException::_tao_minor_code (
95 CORBA::COMPLETED_NO
));
101 throw CORBA::PolicyError (CORBA::BAD_POLICY_TYPE
);
105 TAO_ZIOP_PolicyFactory::_create_policy (CORBA::PolicyType type
)
107 CORBA::Policy_ptr policy
= CORBA::Policy_ptr ();
111 case ZIOP::COMPRESSION_ENABLING_POLICY_ID
:
113 ACE_NEW_THROW_EX (policy
,
114 TAO::CompressionEnablingPolicy
,
116 CORBA::SystemException::_tao_minor_code (
119 CORBA::COMPLETED_NO
));
123 case ZIOP::COMPRESSOR_ID_LEVEL_LIST_POLICY_ID
:
125 ACE_NEW_THROW_EX (policy
,
126 TAO::CompressorIdLevelListPolicy
,
128 CORBA::SystemException::_tao_minor_code (
131 CORBA::COMPLETED_NO
));
136 throw ::CORBA::PolicyError (CORBA::BAD_POLICY_TYPE
);
140 TAO_END_VERSIONED_NAMESPACE_DECL