Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tao / BiDir_GIOP / BiDir_PolicyFactory.cpp
blob76a18ff09f0a4604d1049ea99828480bc6e9c359
1 // -*- C++ -*-
2 #include "tao/BiDir_GIOP/BiDir_PolicyFactory.h"
3 #include "tao/BiDir_GIOP/BiDirGIOP.h"
4 #include "tao/BiDir_GIOP/BiDir_Policy_i.h"
5 #include "tao/ORB_Constants.h"
6 #include "tao/AnyTypeCode/Any.h"
7 #include "ace/CORBA_macros.h"
9 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
11 CORBA::Policy_ptr
12 TAO_BiDir_PolicyFactory::create_policy (
13 CORBA::PolicyType type,
14 const CORBA::Any &value)
16 CORBA::Policy_ptr policy = CORBA::Policy_ptr ();
18 if (type == BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE)
20 BiDirPolicy::BidirectionalPolicyValue val;
22 // Extract the value from the any.
23 if ((value >>= val) == 0)
25 throw ::CORBA::PolicyError (CORBA::BAD_POLICY_VALUE);
28 ACE_NEW_THROW_EX (policy,
29 TAO_BidirectionalPolicy (val),
30 CORBA::NO_MEMORY (
31 CORBA::SystemException::_tao_minor_code (
32 TAO::VMCID,
33 ENOMEM),
34 CORBA::COMPLETED_NO));
36 return policy;
39 throw ::CORBA::PolicyError (CORBA::BAD_POLICY_TYPE);
42 TAO_END_VERSIONED_NAMESPACE_DECL