summaryrefslogtreecommitdiff
path: root/ACE/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/resolve_init.h
diff options
context:
space:
mode:
Diffstat (limited to 'ACE/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/resolve_init.h')
-rw-r--r--ACE/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/resolve_init.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/ACE/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/resolve_init.h b/ACE/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/resolve_init.h
new file mode 100644
index 00000000000..c09ee873041
--- /dev/null
+++ b/ACE/TAO/orbsvcs/orbsvcs/FtRtEvent/Utils/resolve_init.h
@@ -0,0 +1,69 @@
+// -*- C++ -*-
+//=============================================================================
+/**
+ * @file resolve_init.h
+ *
+ * $Id$
+ *
+ * @author Huang-Ming Huang <hh1@cse.wustl.edu>
+ */
+//=============================================================================
+#ifndef RESOVLE_INIT_H
+#define RESOVLE_INIT_H
+
+#include "tao/Versioned_Namespace.h"
+
+TAO_BEGIN_VERSIONED_NAMESPACE_DECL
+
+template<class T>
+typename T::_ptr_type
+resolve_init (CORBA::ORB_ptr orb,
+ const char *id)
+{
+ typename T::_var_type ref;
+ CORBA::Object_var obj;
+ try
+ {
+ CORBA::Object_var obj;
+ obj = orb->resolve_initial_references(id);
+
+ ref = T::_narrow(obj.in());
+ }
+
+ catch (const CORBA::Exception&)
+ {
+ ACE_ERROR((
+ LM_ERROR,
+ " (%P|%t) Unable to initialize %s.\n",
+ id
+ ));
+ if (!CORBA::is_nil(obj.in()))
+ ACE_ERROR((
+ LM_ERROR,
+ " due to narrowing problem\n"
+ ));
+ throw;
+ }
+
+ return ref._retn();
+}
+
+#ifdef TAO_Naming_Export
+template<class T>
+typename T::_ptr_type
+resolve (CosNaming::NamingContext_ptr context,
+ const CosNaming::Name &id)
+{
+ CORBA::Object_var obj;
+ obj = context->resolve(id);
+
+ ACE_ASSERT(!CORBA::is_nil(obj.in()));
+
+ typename T::_var_type ref = T::_narrow(obj.in());
+ return ref._retn();
+}
+#endif
+
+TAO_END_VERSIONED_NAMESPACE_DECL
+
+#endif