| custom valuetype |
The CORBA custom valuetype (TBD) ..... It maps to VB's class type. |
// CORBA IDL |
custom valuetype valueExample
{
private long number_state;
public string name_state;
void print();
};
|
// VB
Imports System
Namespace demo.obv.custom
'
' Value Type definition : valueExample
'
' @author TomORB VB Native Compiler 1.0rc1
'
<Serializable()> _
Public MustInherit Class valueExample
Implements demo.obv.custom.aValueBase, Org.Omg.CORBA.Portable.CustomValue
'
' Private member : number_state
'
Protected number_state As Integer
'
' Public member : name_state
'
Public name_state As String
'
' Abstract Read accessor for number attribute
' @return the attribute value
'
Public MustOverride ReadOnly Property number As Integer
'
' Abstract Operation Print
'
Public MustOverride Sub Print()
' inherited abstract operations in the last abstract valuetypes
'
'
' Abstract Read accessor for number0 attribute
' @return the attribute value
'
Public MustOverride ReadOnly Property number0 As Integer Implements demo.obv.custom.aValueBase.number0
'
' Abstract Operation Print_Base
'
Public MustOverride Sub Print_Base() Implements demo.obv.custom.aValueBase.Print_Base
Public MustOverride Sub Unmarshal(_is As Org.Omg.CORBA.DataInputStream) Implements Org.Omg.CORBA.CustomMarshal.Unmarshal
Public MustOverride Sub Marshal(_os As Org.Omg.CORBA.DataOutputStream) Implements Org.Omg.CORBA.CustomMarshal.Marshal
'
' Return the truncatable ids
'
Shared _ids_list As String() = New String() {"IDL:demo/obv/custom/valueExample:1.0"}
Public Overridable Function _Truncatable_Ids() As String() Implements Org.Omg.CORBA.Portable.ValueBase._Truncatable_Ids
Return _ids_list
End Function
End Class
End Namespace
Namespace demo.obv.custom
'
' Helper class for : valueExample
'
' @author TomORB VB Native Compiler 1.0rc1
'
Public Class valueExampleHelper
'
' Insert valueExample into an any
' param name="a" an any
' param name="t" valueExample value
'
Public Shared Sub Insert(a As Org.Omg.CORBA.Any, t As demo.obv.custom.valueExample)
a.Insert_Value(t, Type())
End Sub
'
' Extract valueExample from an any
' @param a an any
' @return the extracted valueExample value
'
Public Shared Function Extract(a As Org.Omg.CORBA.Any) As demo.obv.custom.valueExample
If Not(a.Type().Equal(Type())) Then
Throw New Org.Omg.CORBA.MARSHAL()
End If
Try
Return CType(a.Extract_Value(),demo.obv.custom.valueExample)
Catch e As System.InvalidCastException
Throw New Org.Omg.CORBA.MARSHAL(e.Message)
End Try
End Function
'
' Internal TypeCode value
'
Private Shared _tc As Org.Omg.CORBA.TypeCode = Nothing
Private Shared _working As Boolean = false
'
' Return the valueExample TypeCode
' @return a TypeCode
'
Public Shared Function Type() As Org.Omg.CORBA.TypeCode
If _tc Is Nothing Then
SyncLock (GetType(Org.Omg.CORBA.TypeCode))
If Not(_tc Is Nothing) Then
Return _tc
End If
If _working Then
Return Org.Omg.CORBA.ORB.Init().Create_Recursive_TC(Id())
End If
_working = True
Dim orb As Org.Omg.CORBA.ORB = Org.Omg.CORBA.ORB.Init()
Dim _members() As Org.Omg.CORBA.ValueMember = New Org.Omg.CORBA.ValueMember(1){}
_members(0) = New Org.Omg.CORBA.ValueMember()
_members(0).name = "number_state"
_members(0).type = orb.Get_Primitive_TC(Org.Omg.CORBA.TCKind.tk_long)
_members(0).access = Org.Omg.CORBA.PRIVATE_MEMBER.value
_members(1) = New Org.Omg.CORBA.ValueMember()
_members(1).name = "name_state"
_members(1).type = orb.Get_Primitive_TC(Org.Omg.CORBA.TCKind.tk_string)
_members(1).access = Org.Omg.CORBA.PUBLIC_MEMBER.value
Dim _concrete_tc As Org.Omg.CORBA.TypeCode = orb.Get_Primitive_TC(Org.Omg.CORBA.TCKind.tk_null)
_tc = orb.Create_Value_TC(Id(),"valueExample",Org.Omg.CORBA.VM_CUSTOM.value,_concrete_tc,_members)
_working = False
End SyncLock
End If
Return _tc
End Function
'
' Return the valueExample IDL ID
' @return an ID
'
Public Shared Function Id() As String
Return _id
End Function
Private Shared _id As String = "IDL:demo/obv/custom/valueExample:1.0"
'
' Read valueExample from a marshalled stream
' @param istream the input stream
' @return the readed valueExample value
'
Public Shared Function Read(istream As Org.Omg.CORBA.Portable.InputStream) As demo.obv.custom.valueExample
Return CType(CType(istream, Org.Omg.CORBA_2_3.Portable.InputStream).Read_Value(_id),demo.obv.custom.valueExample)
End Function
'
' Write valueExample into a marshalled stream
' @param ostream the output stream
' @param value valueExample value
'
Public Shared Sub Write(ostream As Org.Omg.CORBA.Portable.OutputStream, value As demo.obv.custom.valueExample)
CType(ostream, Org.Omg.CORBA_2_3.Portable.OutputStream).Write_Value(value, _id)
End Sub
End Class
End Namespace
|
|