[omniORB] Proper Any for struct in python

Duncan Grisby duncan at grisby.org
Wed Feb 14 12:16:44 GMT 2018


On Tue, 2018-02-13 at 11:56 -0500, chris williams via omniORB-list
wrote:

> Hi I'm stuck on trying to figure out how to properly use any.  In
> this instance, the IDL is as follows:
> struct IdlOtnAllSettings
> {
>     // This section is common to many PPs
>     octet                   restartInhibit;
>     unsigned short          testId; 
>     octet                   reference;
>     octet                   powerUpTestAction;
>     octet                   ppPauseState;
>     octet                   settingsControl;
>     IdlErrorGen             errorGen;
> 
> }

First create an instance of that:

  settings_val = _GlobalIDL.IdlOtnAllSettings(1, 2, 3, 4, 5, 6, 7)

(With a suitable value for the IdlErrorGen type.)


Then you need to put it in an Any. An Any has a TypeCode and a value.
To get the TypeCode, the Python mapping standard says you do this:

  tc = CORBA.TypeCode(CORBA.id(_GlobalIDL.IdlOtnAllSettings))

or being omniORB specific, you can use a static one:

  tc = _GlobalIDL._tc_IdlOtnAllSettings


Then you can make your Any:

  settings_any = CORBA.Any(tc, settings_val)


Or, if you want to be very omniORB specific, you can use a helper
function that works out the TypeCode for you:

  from omniORB.any import to_any

  settings_any = to_any(settings_val)


Duncan.

-- 
 -- Duncan Grisby         --
  -- duncan at grisby.org     --
   -- http://www.grisby.org --




More information about the omniORB-list mailing list