IDL Complex Type | |
interface |
TBD Properties inside an interface are represented by set-accessors and get-accessors.
|
// CORBA IDL |
module demo { module hello { interface GoodDay { string hello_simple(); wstring hello_wide( in wstring msg ); }; }; }; |
e.g. GoodDay GoodDayOperations GoodDayHelper _GoodDayStub GoodDayPOA GoodDayPOATie |
// C# public interface GoodDay : GoodDayOperations, Org.Omg.CORBA.Object, Org.Omg.CORBA.Portable.IDLEntity { } public interface GoodDayOperations { /** * Operation hello_simple */ string Hello_Simple(); /** * Operation hello_wide */ string Hello_Wide(string msg); } public class GoodDayHelper { /// /// Insert GoodDay into an any /// @param a an any /// @param t GoodDay value /// public static void Insert(Org.Omg.CORBA.Any a, demo.hello.GoodDay t ) { a.Insert_Object(t , Type()); } /// /// Extract GoodDay from an any /// @param a an any /// @return the extracted GoodDay value /// public static demo.hello.GoodDay Extract(Org.Omg.CORBA.Any a) { if (!a.Type().Equal(Type())) throw new Org.Omg.CORBA.MARSHAL(); try { return demo.hello.GoodDayHelper.Narrow(a.Extract_Object()); } catch ( Org.Omg.CORBA.BAD_PARAM e) { throw new Org.Omg.CORBA.MARSHAL(e.Message); } } /// /// Internal TypeCode value /// private static Org.Omg.CORBA.TypeCode _tc = null; /// /// Return the GoodDay TypeCode /// @return a TypeCode /// public static Org.Omg.CORBA.TypeCode Type() { if (_tc == null) { Org.Omg.CORBA.ORB orb = Org.Omg.CORBA.ORB.Init(); _tc = orb.Create_Interface_TC(Id(),"GoodDay"); } return _tc; } /// /// Return the GoodDay IDL ID /// @return an ID /// public static string Id() { return _id; } private static string _id = "IDL:demo/hello/GoodDay:1.0"; /// /// Read GoodDay from a marshalled stream /// @param istream the input stream /// @return the readed GoodDay value /// public static demo.hello.GoodDay Read(Org.Omg.CORBA.Portable.InputStream istream) { return(demo.hello.GoodDay)istream.Read_Object(typeof(demo.hello._GoodDayStub)); } /// /// Write GoodDay into a marshalled stream /// @param ostream the output stream /// @param value GoodDay value /// public static void Write(Org.Omg.CORBA.Portable.OutputStream ostream, demo.hello.GoodDay value) { ostream.Write_Object((Org.Omg.CORBA.Portable.ObjectImpl)value); } /// /// Narrow CORBA::Object to GoodDay /// @param obj the CORBA Object /// @return GoodDay Object /// public static GoodDay Narrow(Org.Omg.CORBA.Object obj) { if (obj == null) return null; if (obj is GoodDay) return (GoodDay)obj; if (obj._Is_A(Id())) { _GoodDayStub stub = new _GoodDayStub(); stub._Set_Delegate(((Org.Omg.CORBA.Portable.ObjectImpl)obj)._Get_Delegate()); return stub; } throw new Org.Omg.CORBA.BAD_PARAM(); } /// /// Unchecked Narrow CORBA::Object to GoodDay /// @param obj the CORBA Object /// @return GoodDay Object /// public static GoodDay Unchecked_Narrow(Org.Omg.CORBA.Object obj) { if (obj == null) return null; if (obj is GoodDay) return (GoodDay)obj; _GoodDayStub stub = new _GoodDayStub(); stub._Set_Delegate(((Org.Omg.CORBA.Portable.ObjectImpl)obj)._Get_Delegate()); return stub; } } [Serializable] public class _GoodDayStub : Org.Omg.CORBA.Portable.ObjectImpl, GoodDay { static string[] _ids_list = { "IDL:demo/hello/GoodDay:1.0" }; public override string[] _Ids() { return _ids_list; } private static System.Type _opsType = typeof(demo.hello.GoodDayOperations); /** * Operation hello_simple */ public string Hello_Simple() { while(true) { if (!this._Is_Local()) { Org.Omg.CORBA.Portable.InputStream _input = null; try { Org.Omg.CORBA.Portable.OutputStream _output = this._Request( "hello_simple",true); _input = this._Invoke(_output); string _arg_ret = _input.Read_String(); return _arg_ret; } catch(Org.Omg.CORBA.Portable.RemarshalException _exception) { continue; } catch(Org.Omg.CORBA.Portable.ApplicationException _exception) { string _exception_id = _exception.GetId(); throw new Org.Omg.CORBA.UNKNOWN("Unexpected User Exception: "+ _exception_id); } finally { this._ReleaseReply(_input); } } else { Org.Omg.CORBA.Portable.ServantObject _so = _Servant_PreInvoke( "hello_simple",_opsType); if (_so == null) continue; demo.hello.GoodDayOperations _self = (demo.hello.GoodDayOperations) _so.servant; try { return _self.Hello_Simple(); } finally { _Servant_PostInvoke(_so); } } } } /** * Operation hello_wide */ public string Hello_Wide(string msg) { while(true) { if (!this._Is_Local()) { Org.Omg.CORBA.Portable.InputStream _input = null; try { Org.Omg.CORBA.Portable.OutputStream _output = this._Request("hello_wide",true); _output.Write_WString(msg); _input = this._Invoke(_output); string _arg_ret = _input.Read_WString(); return _arg_ret; } catch(Org.Omg.CORBA.Portable.RemarshalException _exception) { continue; } catch(Org.Omg.CORBA.Portable.ApplicationException _exception) { string _exception_id = _exception.GetId(); throw new Org.Omg.CORBA.UNKNOWN("Unexpected User Exception: "+ _exception_id); } finally { this._ReleaseReply(_input); } } else { Org.Omg.CORBA.Portable.ServantObject _so = _Servant_PreInvoke( "hello_wide",_opsType); if (_so == null) continue; demo.hello.GoodDayOperations _self = (demo.hello.GoodDayOperations) _so.servant; try { return _self.Hello_Wide( msg); } finally { _Servant_PostInvoke(_so); } } } } } [Serializable] public abstract class GoodDayPOA : Org.Omg.PortableServer.Servant, GoodDayOperations, Org.Omg.CORBA.Portable.InvokeHandler { public virtual GoodDay _This() { return GoodDayHelper.Narrow(_This_Object()); } public virtual GoodDay _This(Org.Omg.CORBA.ORB orb) { return GoodDayHelper.Narrow(_This_Object(orb)); } private static string [] _ids_list = { "IDL:demo/hello/GoodDay:1.0" }; public override string[] _All_Interfaces(Org.Omg.PortableServer.POA poa, byte [] objectId) { return _ids_list; } public Org.Omg.CORBA.Portable.OutputStream _Invoke( string opName, Org.Omg.CORBA.Portable.InputStream _is, Org.Omg.CORBA.Portable.ResponseHandler handler) { if (opName.Equals("hello_simple")) { return _Invoke_Hello_Simple(_is, handler); } else if (opName.Equals("hello_wide")) { return _Invoke_Hello_Wide(_is, handler); } else { throw new Org.Omg.CORBA.BAD_OPERATION(opName); } } /** * Abstract Operation Hello_Simple */ public abstract string Hello_Simple(); /** * Abstract Operation Hello_Wide */ public abstract string Hello_Wide(string msg); // helper methods private Org.Omg.CORBA.Portable.OutputStream _Invoke_Hello_Simple( Org.Omg.CORBA.Portable.InputStream _is, Org.Omg.CORBA.Portable.ResponseHandler handler) { Org.Omg.CORBA.Portable.OutputStream _output; string _arg_result = Hello_Simple(); _output = handler.CreateReply(); _output.Write_String(_arg_result); return _output; } private Org.Omg.CORBA.Portable.OutputStream _Invoke_Hello_Wide( Org.Omg.CORBA.Portable.InputStream _is, Org.Omg.CORBA.Portable.ResponseHandler handler) { Org.Omg.CORBA.Portable.OutputStream _output; string arg0_in = _is.Read_WString(); string _arg_result = Hello_Wide(arg0_in); _output = handler.CreateReply(); _output.Write_WString(_arg_result); return _output; } } [Serializable] public class GoodDayPOATie : GoodDayPOA { // // Private reference to implementation object // private GoodDayOperations _tie; // // Private reference to POA // private Org.Omg.PortableServer.POA _poa; /** * Constructor */ public GoodDayPOATie(GoodDayOperations tieObject) { _tie = tieObject; } /** * Constructor */ public GoodDayPOATie(GoodDayOperations tieObject, Org.Omg.PortableServer.POA poa) { _tie = tieObject; _poa = poa; } public override GoodDay _This() { return GoodDayHelper.Narrow( _This_Object()); } public override GoodDay _This(Org.Omg.CORBA.ORB orb) { return GoodDayHelper.Narrow( _This_Object(orb)); } public GoodDayOperations _delegate { get { return _tie; } set { _tie = value; } } /** * _default_POA method */ public override Org.Omg.PortableServer.POA _Default_POA() { if (_poa != null) return _poa; else return base._Default_POA(); } /** * Operation Hello_Simple */ public override string Hello_Simple() { return _tie.Hello_Simple(); } /** * Operation Hello_Wide */ public override string Hello_Wide(string msg) { return _tie.Hello_Wide( msg); } } |