summaryrefslogtreecommitdiff
path: root/tests/Portable_Interceptors/PolicyFactory/PolicyFactory.cpp
blob: 1d60d5a2e41ce73dec4e39fdb32955387812219e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// $Id$

#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;
}