summaryrefslogtreecommitdiff
path: root/TAO/tao/Utils/RIR_Narrow.cpp
blob: ebc014d499e3b1ef4c8eb1adb478533477e4ec45 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// $Id$

#ifndef TAO_UTILS_RIR_NARROW_CPP
#define TAO_UTILS_RIR_NARROW_CPP

#include "tao/Utils/RIR_Narrow.h"
#include "tao/SystemException.h"
#include <stdexcept>

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

template<class T> typename TAO::Utils::RIR_Narrow<T>::_ptr_type
TAO::Utils::RIR_Narrow<T>::narrow (CORBA::ORB_ptr orb, char const * id)
{
  CORBA::Object_var object =
    orb->resolve_initial_references (id);

  return RIR_Narrow<T>::narrow_object (object.in ());
}

template<class T> typename TAO::Utils::RIR_Narrow<T>::_ptr_type
TAO::Utils::RIR_Narrow<T>::narrow (PortableInterceptor::ORBInitInfo_ptr info,
                                   char const * id)
{
  CORBA::Object_var object = info->resolve_initial_references (id);

  return RIR_Narrow<T>::narrow_object (object.in ());
}

template<class T> typename TAO::Utils::RIR_Narrow<T>::_ptr_type
TAO::Utils::RIR_Narrow<T>::narrow_object (CORBA::Object_ptr object)
{
  _var_type narrowed_object = T::_narrow (object);

  if (CORBA::is_nil (narrowed_object.in ()))
  {
    throw ::CORBA::INV_OBJREF ();
  }
  return narrowed_object._retn ();
}

TAO_END_VERSIONED_NAMESPACE_DECL

#endif /*TAO_UTILS_RIR_NARROW_CPP*/