summaryrefslogtreecommitdiff
path: root/tests/Portable_Interceptors/PolicyFactory/PolicyFactory.cpp
blob: 4e90c443045a954069afff1dbb957ad514f25f9c (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
26
27
28
29
30
// $Id$

#include "PolicyFactory.h"
#include "Policy.h"

ACE_RCSID (PolicyFactory,
           PolicyFactory,
           "$Id$")


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