IDL Complex Type
stateful valuetype

The CORBA valuetype indicates that the method returns nothing.  It maps to VB's class type.

Stateful valuetype is passed by value as arguments or result of remote methods.  Each stateful valuetype must be inherited from  Org.Omg.CORBA.Portable.StreamableValue and is marked with attribute Serializable.  The Serializable attribute is used for .Net streaming only, but not for Corba marshalling. 

Inheriated From Base Class:

Inherited From Interfaces:

Methods:

 

Constructors:

 

Fields:

 

Properties:

 

Repository ID:

 

// CORBA IDL
valuetype Account
{
   private string name; 
   public string address;
   private float balance; 
   
   void debit(in float amount );
	
   void credit( in float amount);
   factory init( in string name, in string address, 
                 in float balance); 
};
 
// VB 

Imports System

Namespace demo.obv.valuetype
   '
   ' Value Type definition : Account
   ' 
   ' @author TomORB VB Native Compiler 1.0rc1
   '
   <Serializable()> _
   Public MustInherit Class Account
      Implements Org.Omg.CORBA.Portable.StreamableValue
      ' 
      ' Private member : name
      ' 
      Protected name As String
      
      ' 
      ' Public member : address
      ' 
      Public address As String
		
      ' 
      ' Private member : balance
      ' 
      Protected balance As Single
		
      ' 
      '  Abstract Operation Debit
      ' 
      Public MustOverride Sub Debit(amount As Single)

      ' 
      '  Abstract Operation Credit
      ' 
      Public MustOverride Sub Credit(amount As Single)

      '
      ' Return the truncatable ids
      '
      Shared _ids_list As String() = New String() {"IDL:demo/obv/valuetype/Account:1.0"}

      Public Overridable Function _Truncatable_Ids() As String() 
                         Implements Org.Omg.CORBA.Portable.ValueBase._Truncatable_Ids
                         
         Return _ids_list
      End Function

      '
      ' Unmarshal the value into an InputStream
      '
      Public Overridable Sub _Read(_is As Org.Omg.CORBA.Portable.InputStream) 
                         Implements Org.Omg.CORBA.Portable.StreamableValue._Read
                         
         name = _is.Read_String()
         address = _is.Read_String()
         balance = _is.Read_Float()
      End Sub

      '
      ' Marshal the value into an OutputStream
      '
      Public Overridable Sub _Write(os As Org.Omg.CORBA.Portable.OutputStream) 
                         Implements Org.Omg.CORBA.Portable.StreamableValue._Write
                         
         os.Write_String(name)
         os.Write_String(address)
         os.Write_Float(balance)
      End Sub

      '
      ' Return the value TypeCode
      '
      Public Overridable Function _Type() As Org.Omg.CORBA.TypeCode 
                         Implements Org.Omg.CORBA.Portable.StreamableValue._Type
                         
          Return demo.obv.valuetype.AccountHelper.Type()
      End Function

   End Class

End Namespace

Namespace demo.obv.valuetype
   ' 
   ' Helper class for : Account
   '  
   ' @author TomORB VB Native Compiler 1.0rc1
   ' 
   Public Class AccountHelper
      '
      ' Insert Account into an any
      ' param name="a" an any
      ' param name="t" Account value
      '
      Public Shared Sub Insert(a As Org.Omg.CORBA.Any, t As demo.obv.valuetype.Account)
         a.Insert_Value(t, Type())
      End Sub

      '
      ' Extract Account from an any
      ' @param a an any
      ' @return the extracted Account value
      '
      Public Shared Function Extract(a As Org.Omg.CORBA.Any) As demo.obv.valuetype.Account
         If Not(a.Type().Equal(Type())) Then
            Throw New Org.Omg.CORBA.MARSHAL()
         End If
         Try
            Return CType(a.Extract_Value(),demo.obv.valuetype.Account)
         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 Account 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(2){}

               _members(0) = New Org.Omg.CORBA.ValueMember()
               _members(0).name = "name"
               _members(0).type = orb.Get_Primitive_TC(Org.Omg.CORBA.TCKind.tk_string)
               _members(0).access = Org.Omg.CORBA.PRIVATE_MEMBER.value
               _members(1) = New Org.Omg.CORBA.ValueMember()
               _members(1).name = "address"
               _members(1).type = orb.Get_Primitive_TC(Org.Omg.CORBA.TCKind.tk_string)
               _members(1).access = Org.Omg.CORBA.PUBLIC_MEMBER.value
               _members(2) = New Org.Omg.CORBA.ValueMember()
               _members(2).name = "balance"
               _members(2).type = orb.Get_Primitive_TC(Org.Omg.CORBA.TCKind.tk_float)
               _members(2).access = Org.Omg.CORBA.PRIVATE_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(),"Account",
                                Org.Omg.CORBA.VM_NONE.value,_concrete_tc,_members)
               _working = False
            End SyncLock
         End If
         Return _tc
      End Function

      '
      ' Return the Account IDL ID
      ' @return an ID
      '
      Public Shared Function Id() As String
         Return _id
      End Function

      Private Shared _id As String = "IDL:demo/obv/valuetype/Account:1.0"

      '
      ' Read Account from a marshalled stream
      ' @param istream the input stream
      ' @return the readed Account value
      '
      Public Shared Function Read(istream As Org.Omg.CORBA.Portable.InputStream) 
                             As demo.obv.valuetype.Account
         Return CType(CType(istream, Org.Omg.CORBA_2_3.Portable.InputStream).Read_Value(_id),
                       demo.obv.valuetype.Account)
      End Function

      '
      ' Write Account into a marshalled stream
      ' @param ostream the output stream
      ' @param value Account value
      '
      Public Shared Sub Write(ostream As Org.Omg.CORBA.Portable.OutputStream, 
                              value As demo.obv.valuetype.Account)
                              
         CType(ostream, Org.Omg.CORBA_2_3.Portable.OutputStream).Write_Value(value, _id)
      End Sub

      '  
      ' Create a value type (using factory method)
      '
      Public Shared Function Init(orb As Org.Omg.CORBA.ORB, name As String, 
                                  address As String, balance As Single) As Account
         Dim _factory As Org.Omg.CORBA.Portable.ValueFactory = 
                              CType(orb,Org.Omg.CORBA_2_3.ORB).Lookup_Value_Factory(Id())
         If _factory Is Nothing Then
            Throw New Org.Omg.CORBA.BAD_INV_ORDER()
         End If
         Return CType(_factory,demo.obv.valuetype.AccountValueFactory).Init( 
                      name,  address,  balance)
      End Function

   End Class

End Namespace

Namespace demo.obv.valuetype
   '
   ' Factory definition : init
   ' 
   ' @author TomORB VB Native Compiler 1.0rc1
   '
   Public Interface AccountValueFactory
      Inherits Org.Omg.CORBA.Portable.ValueFactory
      '
      ' Return the value type
      '
      Function Init(name As String, address As String, balance As Single) 
                    As demo.obv.valuetype.Account
   
   End Interface

End Namespace