VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "c_NmContext"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'Generated by IDL2VB v120. Copyright (c) 1999 Martin.Both
'Source File Name: ../naming/CosNaming.idl
'Target File Name: c_NmContext.cls

Option Explicit

Implements cOrbAbstractBase
Implements cOrbObject

'interface ::CosNaming::NamingContext
Const sTypeId As String = "IDL:omg.org/CosNaming/NamingContext:1.0"
Private oObjRef As cOrbObjRef

'Helper to get different COM interface
Friend Function thisOrbAbstractBase() As cOrbAbstractBase
    Set thisOrbAbstractBase = Me
End Function

'Helper
Private Function cOrbAbstractBase_isObjRef() As Boolean
    cOrbAbstractBase_isObjRef = True
End Function

'Helper to get different COM interface
Friend Function thisOrbObject() As cOrbObject
    Set thisOrbObject = Me
End Function

'Helper
Private Function cOrbObject_setObjRef(ByVal ObjRef As cOrbObjRef, _
    ByVal Check As Boolean) As Boolean
    On Error GoTo ErrHandler
    If ObjRef Is Nothing Then
        cOrbObject_setObjRef = True
    Else
        cOrbObject_setObjRef = False
        Call ObjRef.narrow(sTypeId, Check, False)
    End If
    Set oObjRef = ObjRef
    Exit Function
ErrHandler:
    Call VBOrb.ErrReraise(Err, "setObjRef")
End Function

'Helper
Private Function cOrbObject_getObjRef() As cOrbObjRef
    Set cOrbObject_getObjRef = oObjRef
End Function

'Helper
Private Function cOrbObject_getId() As String
    cOrbObject_getId = sTypeId
End Function

'bind() raises(c_NmNotFoundEx, c_NmCannotProceedEx, c_NmInvalidNameEx, _
    c_NmAlreadyBoundEx)
Public Sub bind(ByVal n As c_NmNameComponentSeq, ByVal obj As cOrbObject)
    On Error GoTo ErrHandler
    Dim oRequest As cOrbRequest
    Set oRequest = oObjRef.request("bind", False)
    Dim oOut As cOrbStream
    Set oOut = oRequest.InArg
    Call n.writeMe(oOut, 0)
    Call oOut.writeObject(obj)
    Dim oIn As cOrbStream
    If oRequest.invokeReqst(True) Then
        Set oIn = oRequest.OutRes
        Dim sTypeId As String
        sTypeId = oIn.readString()
        Dim oUserEx As VBOrb.cOrbException
        Select Case sTypeId
        Case "IDL:omg.org/CosNaming/NamingContext/NotFound:1.0"
            Set oUserEx = New c_NmNotFoundEx
            Call oUserEx.initByRead(oIn)
        Case "IDL:omg.org/CosNaming/NamingContext/CannotProceed:1.0"
            Set oUserEx = New c_NmCannotProceedEx
            Call oUserEx.initByRead(oIn)
        Case "IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0"
            Set oUserEx = New c_NmInvalidNameEx
            Call oUserEx.initByRead(oIn)
        Case "IDL:omg.org/CosNaming/NamingContext/AlreadyBound:1.0"
            Set oUserEx = New c_NmAlreadyBoundEx
            Call oUserEx.initByRead(oIn)
        Case Else
            Call VBOrb.raiseUNKNOWN(1, VBOrb.CompletedMAYBE, _
                "Undefined CORBA User Exception: [" & sTypeId & "]")
        End Select
        Call VBOrb.raiseUserEx(oUserEx)
    End If
    Exit Sub
ErrHandler:
    Call VBOrb.ErrReraise(Err, "bind")
End Sub

'rebind() raises(c_NmNotFoundEx, c_NmCannotProceedEx, c_NmInvalidNameEx)
Public Sub rebind(ByVal n As c_NmNameComponentSeq, ByVal obj As cOrbObject)
    On Error GoTo ErrHandler
    Dim oRequest As cOrbRequest
    Set oRequest = oObjRef.request("rebind", False)
    Dim oOut As cOrbStream
    Set oOut = oRequest.InArg
    Call n.writeMe(oOut, 0)
    Call oOut.writeObject(obj)
    Dim oIn As cOrbStream
    If oRequest.invokeReqst(True) Then
        Set oIn = oRequest.OutRes
        Dim sTypeId As String
        sTypeId = oIn.readString()
        Dim oUserEx As VBOrb.cOrbException
        Select Case sTypeId
        Case "IDL:omg.org/CosNaming/NamingContext/NotFound:1.0"
            Set oUserEx = New c_NmNotFoundEx
            Call oUserEx.initByRead(oIn)
        Case "IDL:omg.org/CosNaming/NamingContext/CannotProceed:1.0"
            Set oUserEx = New c_NmCannotProceedEx
            Call oUserEx.initByRead(oIn)
        Case "IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0"
            Set oUserEx = New c_NmInvalidNameEx
            Call oUserEx.initByRead(oIn)
        Case Else
            Call VBOrb.raiseUNKNOWN(1, VBOrb.CompletedMAYBE, _
                "Undefined CORBA User Exception: [" & sTypeId & "]")
        End Select
        Call VBOrb.raiseUserEx(oUserEx)
    End If
    Exit Sub
ErrHandler:
    Call VBOrb.ErrReraise(Err, "rebind")
End Sub

'bind_context() raises(c_NmNotFoundEx, c_NmCannotProceedEx, c_NmInvalidNameEx, _
    c_NmAlreadyBoundEx)
Public Sub bindContext(ByVal n As c_NmNameComponentSeq, ByVal nc As c_NmContext)
    On Error GoTo ErrHandler
    Dim oRequest As cOrbRequest
    Set oRequest = oObjRef.request("bind_context", False)
    Dim oOut As cOrbStream
    Set oOut = oRequest.InArg
    Call n.writeMe(oOut, 0)
    Call oOut.writeObject(nc)
    Dim oIn As cOrbStream
    If oRequest.invokeReqst(True) Then
        Set oIn = oRequest.OutRes
        Dim sTypeId As String
        sTypeId = oIn.readString()
        Dim oUserEx As VBOrb.cOrbException
        Select Case sTypeId
        Case "IDL:omg.org/CosNaming/NamingContext/NotFound:1.0"
            Set oUserEx = New c_NmNotFoundEx
            Call oUserEx.initByRead(oIn)
        Case "IDL:omg.org/CosNaming/NamingContext/CannotProceed:1.0"
            Set oUserEx = New c_NmCannotProceedEx
            Call oUserEx.initByRead(oIn)
        Case "IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0"
            Set oUserEx = New c_NmInvalidNameEx
            Call oUserEx.initByRead(oIn)
        Case "IDL:omg.org/CosNaming/NamingContext/AlreadyBound:1.0"
            Set oUserEx = New c_NmAlreadyBoundEx
            Call oUserEx.initByRead(oIn)
        Case Else
            Call VBOrb.raiseUNKNOWN(1, VBOrb.CompletedMAYBE, _
                "Undefined CORBA User Exception: [" & sTypeId & "]")
        End Select
        Call VBOrb.raiseUserEx(oUserEx)
    End If
    Exit Sub
ErrHandler:
    Call VBOrb.ErrReraise(Err, "bindContext")
End Sub

'rebind_context() raises(c_NmNotFoundEx, c_NmCannotProceedEx, c_NmInvalidNameEx)
Public Sub rebindContext(ByVal n As c_NmNameComponentSeq, _
    ByVal nc As c_NmContext)
    On Error GoTo ErrHandler
    Dim oRequest As cOrbRequest
    Set oRequest = oObjRef.request("rebind_context", False)
    Dim oOut As cOrbStream
    Set oOut = oRequest.InArg
    Call n.writeMe(oOut, 0)
    Call oOut.writeObject(nc)
    Dim oIn As cOrbStream
    If oRequest.invokeReqst(True) Then
        Set oIn = oRequest.OutRes
        Dim sTypeId As String
        sTypeId = oIn.readString()
        Dim oUserEx As VBOrb.cOrbException
        Select Case sTypeId
        Case "IDL:omg.org/CosNaming/NamingContext/NotFound:1.0"
            Set oUserEx = New c_NmNotFoundEx
            Call oUserEx.initByRead(oIn)
        Case "IDL:omg.org/CosNaming/NamingContext/CannotProceed:1.0"
            Set oUserEx = New c_NmCannotProceedEx
            Call oUserEx.initByRead(oIn)
        Case "IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0"
            Set oUserEx = New c_NmInvalidNameEx
            Call oUserEx.initByRead(oIn)
        Case Else
            Call VBOrb.raiseUNKNOWN(1, VBOrb.CompletedMAYBE, _
                "Undefined CORBA User Exception: [" & sTypeId & "]")
        End Select
        Call VBOrb.raiseUserEx(oUserEx)
    End If
    Exit Sub
ErrHandler:
    Call VBOrb.ErrReraise(Err, "rebindContext")
End Sub

'resolve() raises(c_NmNotFoundEx, c_NmCannotProceedEx, c_NmInvalidNameEx)
Public Function resolve(ByVal n As c_NmNameComponentSeq) As cOrbObject
    On Error GoTo ErrHandler
    Dim oRequest As cOrbRequest
    Set oRequest = oObjRef.request("resolve", False)
    Dim oOut As cOrbStream
    Set oOut = oRequest.InArg
    Call n.writeMe(oOut, 0)
    Dim oIn As cOrbStream
    If oRequest.invokeReqst(True) Then
        Set oIn = oRequest.OutRes
        Dim sTypeId As String
        sTypeId = oIn.readString()
        Dim oUserEx As VBOrb.cOrbException
        Select Case sTypeId
        Case "IDL:omg.org/CosNaming/NamingContext/NotFound:1.0"
            Set oUserEx = New c_NmNotFoundEx
            Call oUserEx.initByRead(oIn)
        Case "IDL:omg.org/CosNaming/NamingContext/CannotProceed:1.0"
            Set oUserEx = New c_NmCannotProceedEx
            Call oUserEx.initByRead(oIn)
        Case "IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0"
            Set oUserEx = New c_NmInvalidNameEx
            Call oUserEx.initByRead(oIn)
        Case Else
            Call VBOrb.raiseUNKNOWN(1, VBOrb.CompletedMAYBE, _
                "Undefined CORBA User Exception: [" & sTypeId & "]")
        End Select
        Call VBOrb.raiseUserEx(oUserEx)
    Else
        Set oIn = oRequest.OutRes
        Set resolve = oIn.readObject()
    End If
    Exit Function
ErrHandler:
    Set resolve = Nothing
    Call VBOrb.ErrReraise(Err, "resolve")
End Function

'unbind() raises(c_NmNotFoundEx, c_NmCannotProceedEx, c_NmInvalidNameEx)
Public Sub unbind(ByVal n As c_NmNameComponentSeq)
    On Error GoTo ErrHandler
    Dim oRequest As cOrbRequest
    Set oRequest = oObjRef.request("unbind", False)
    Dim oOut As cOrbStream
    Set oOut = oRequest.InArg
    Call n.writeMe(oOut, 0)
    Dim oIn As cOrbStream
    If oRequest.invokeReqst(True) Then
        Set oIn = oRequest.OutRes
        Dim sTypeId As String
        sTypeId = oIn.readString()
        Dim oUserEx As VBOrb.cOrbException
        Select Case sTypeId
        Case "IDL:omg.org/CosNaming/NamingContext/NotFound:1.0"
            Set oUserEx = New c_NmNotFoundEx
            Call oUserEx.initByRead(oIn)
        Case "IDL:omg.org/CosNaming/NamingContext/CannotProceed:1.0"
            Set oUserEx = New c_NmCannotProceedEx
            Call oUserEx.initByRead(oIn)
        Case "IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0"
            Set oUserEx = New c_NmInvalidNameEx
            Call oUserEx.initByRead(oIn)
        Case Else
            Call VBOrb.raiseUNKNOWN(1, VBOrb.CompletedMAYBE, _
                "Undefined CORBA User Exception: [" & sTypeId & "]")
        End Select
        Call VBOrb.raiseUserEx(oUserEx)
    End If
    Exit Sub
ErrHandler:
    Call VBOrb.ErrReraise(Err, "unbind")
End Sub

'new_context()
Public Function newContext() As c_NmContext
    On Error GoTo ErrHandler
    Dim oRequest As cOrbRequest
    Set oRequest = oObjRef.request("new_context", False)
    Dim oIn As cOrbStream
    Call oRequest.invokeReqst(False)
    Set oIn = oRequest.OutRes
    Set newContext = m_NmContext.narrow(oIn.readObject())
    Exit Function
ErrHandler:
    Set newContext = Nothing
    Call VBOrb.ErrReraise(Err, "newContext")
End Function

'bind_new_context() raises(c_NmNotFoundEx, c_NmAlreadyBoundEx, _
    c_NmCannotProceedEx, c_NmInvalidNameEx)
Public Function bindNewContext(ByVal n As c_NmNameComponentSeq) As c_NmContext
    On Error GoTo ErrHandler
    Dim oRequest As cOrbRequest
    Set oRequest = oObjRef.request("bind_new_context", False)
    Dim oOut As cOrbStream
    Set oOut = oRequest.InArg
    Call n.writeMe(oOut, 0)
    Dim oIn As cOrbStream
    If oRequest.invokeReqst(True) Then
        Set oIn = oRequest.OutRes
        Dim sTypeId As String
        sTypeId = oIn.readString()
        Dim oUserEx As VBOrb.cOrbException
        Select Case sTypeId
        Case "IDL:omg.org/CosNaming/NamingContext/NotFound:1.0"
            Set oUserEx = New c_NmNotFoundEx
            Call oUserEx.initByRead(oIn)
        Case "IDL:omg.org/CosNaming/NamingContext/AlreadyBound:1.0"
            Set oUserEx = New c_NmAlreadyBoundEx
            Call oUserEx.initByRead(oIn)
        Case "IDL:omg.org/CosNaming/NamingContext/CannotProceed:1.0"
            Set oUserEx = New c_NmCannotProceedEx
            Call oUserEx.initByRead(oIn)
        Case "IDL:omg.org/CosNaming/NamingContext/InvalidName:1.0"
            Set oUserEx = New c_NmInvalidNameEx
            Call oUserEx.initByRead(oIn)
        Case Else
            Call VBOrb.raiseUNKNOWN(1, VBOrb.CompletedMAYBE, _
                "Undefined CORBA User Exception: [" & sTypeId & "]")
        End Select
        Call VBOrb.raiseUserEx(oUserEx)
    Else
        Set oIn = oRequest.OutRes
        Set bindNewContext = m_NmContext.narrow(oIn.readObject())
    End If
    Exit Function
ErrHandler:
    Set bindNewContext = Nothing
    Call VBOrb.ErrReraise(Err, "bindNewContext")
End Function

'destroy() raises(c_NmNotEmptyEx)
Public Sub destroy()
    On Error GoTo ErrHandler
    Dim oRequest As cOrbRequest
    Set oRequest = oObjRef.request("destroy", False)
    Dim oIn As cOrbStream
    If oRequest.invokeReqst(True) Then
        Set oIn = oRequest.OutRes
        Dim sTypeId As String
        sTypeId = oIn.readString()
        Dim oUserEx As VBOrb.cOrbException
        Select Case sTypeId
        Case "IDL:omg.org/CosNaming/NamingContext/NotEmpty:1.0"
            Set oUserEx = New c_NmNotEmptyEx
            Call oUserEx.initByRead(oIn)
        Case Else
            Call VBOrb.raiseUNKNOWN(1, VBOrb.CompletedMAYBE, _
                "Undefined CORBA User Exception: [" & sTypeId & "]")
        End Select
        Call VBOrb.raiseUserEx(oUserEx)
    End If
    Exit Sub
ErrHandler:
    Call VBOrb.ErrReraise(Err, "destroy")
End Sub

'list()
Public Sub list(ByVal how_many As Long, ByRef bl As c_NmBindingSeq, _
    ByRef bi As c_NmBindingIterator)
    On Error GoTo ErrHandler
    Dim oRequest As cOrbRequest
    Set oRequest = oObjRef.request("list", False)
    Dim oOut As cOrbStream
    Set oOut = oRequest.InArg
    Call oOut.writeUlong(how_many)
    Dim oIn As cOrbStream
    Call oRequest.invokeReqst(False)
    Set oIn = oRequest.OutRes
    Set bl = New c_NmBindingSeq
    Call bl.initByRead(oIn, 0)
    Set bi = m_NmBindingIterator.narrow(oIn.readObject())
    Exit Sub
ErrHandler:
    Call VBOrb.ErrReraise(Err, "list")
End Sub
