00001 #include "tao/BiDir_GIOP/BiDir_PolicyFactory.h" 00002 #include "tao/BiDir_GIOP/BiDirGIOP.h" 00003 #include "tao/BiDir_GIOP/BiDir_Policy_i.h" 00004 00005 #include "tao/ORB_Constants.h" 00006 #include "tao/AnyTypeCode/Any.h" 00007 00008 #include "ace/CORBA_macros.h" 00009 00010 ACE_RCSID (BiDir_GIOP, 00011 BiDir_PolicyFactory, 00012 "$Id: BiDir_PolicyFactory.cpp 77409 2007-02-26 23:48:49Z ossama $") 00013 00014 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00015 00016 CORBA::Policy_ptr 00017 TAO_BiDir_PolicyFactory::create_policy ( 00018 CORBA::PolicyType type, 00019 const CORBA::Any &value) 00020 { 00021 CORBA::Policy_ptr policy = CORBA::Policy_ptr (); 00022 00023 if (type == BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE) 00024 { 00025 BiDirPolicy::BidirectionalPolicyValue val; 00026 00027 // Extract the value from the any. 00028 if ((value >>= val) == 0) 00029 { 00030 throw ::CORBA::PolicyError (CORBA::BAD_POLICY_VALUE); 00031 } 00032 00033 ACE_NEW_THROW_EX (policy, 00034 TAO_BidirectionalPolicy (val), 00035 CORBA::NO_MEMORY ( 00036 CORBA::SystemException::_tao_minor_code ( 00037 TAO::VMCID, 00038 ENOMEM), 00039 CORBA::COMPLETED_NO)); 00040 00041 return policy; 00042 } 00043 00044 throw ::CORBA::PolicyError (CORBA::BAD_POLICY_TYPE); 00045 } 00046 00047 TAO_END_VERSIONED_NAMESPACE_DECL