summaryrefslogtreecommitdiff
path: root/TAO/tests/Portable_Interceptors/PolicyFactory/PolicyFactory.cpp
blob: cfb5b62333b55ea5ac6bb29b9ee4b03af568d310 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "PolicyFactory.h"
#include "Policy.h"

CORBA::Policy_ptr
PolicyFactory::create_policy (CORBA::PolicyType type,
                              const CORBA::Any & value)
{
  // Sanity check since this condition should be caught earlier by the
  // TAO_PolicyFactory_Registry.
  if (type != Test::POLICY_TYPE)
      throw CORBA::PolicyError (CORBA::BAD_POLICY_TYPE);

  CORBA::ULong val;
  if (!(value >>= val))
    throw CORBA::INTERNAL ();

  Policy * p = 0;
  ACE_NEW_THROW_EX (p,
                    Policy (val),
                    CORBA::NO_MEMORY ());

  return p;
}