2005/5/10

     
 

Mapping of ACDK

artefaktur

ACDK provides its own mapping to CORBA types, which follows quite close to the Java definition.



Content of this chapter:

   Basic Value
     Numbers
     string
     Enum
   Constructed Values
     Arrays
     Sequence
     structs
     Union
   Object Reference
   Value Types
   Attributes
   Argument specifier
     in / out / inout
       IN
       OUT and INOUT



 Basic Value

 Numbers

For the basic types the same type mapping will be used as Java.
Not supported are:
  • Fixed
  • Wchar
  • Wstring
  • Enum
  • Any

 string

IDL type string will be translated to ::acdk::lang::RString

 Enum

The type Enum is currently not supported.
Use the int representative instead.

 Constructed Values

 Arrays

Arrays are not supported. Use sequence instead.

 Sequence

Sequences are encoded as ACDK arrays (typeArray).

For the basic value types you can use the corresponding array classes (RintArray, RdoubleArray, RboolArray, etc.)
For string and constructed values you can also use the array classes (RStringArrray, etc.)


//IDL
  void foo(in sequence<string> vals, out sequence<long> indice);

will be in ACDK:


//ACDK
  void foo(RStringArray vals, OUT(RintArray) indice);
  


 structs


//IDL
  struct BunchOfValues
  {
    string label;
    int index;
  };
  void foo(in BunchOfValues vals);
  
Structs will implemented as normal classes, which should be transfered by value:


// ACDK
  class BunchOfValues
  : extends ::acdk::lang::Object,
    implements ::acdk::io::Serializable
  {
  ACDK_WITH_METAINFO(BunchOfValues) // needed for serialisation
  public:
    /**
      needed for create a new instance.
      alternativally create_instance() should be defined.
    */
    BunchOfValues()  
    : Object()
    {
    }
    
    string label;
    int index;
  };
  
  void foo(in BunchOfValues vals);
  

 Union

Are not supported yet.

 Object Reference


Object References are implemented in org::omg::CORBA::Object

 Value Types


Value types are supported using ACDK's standard serialization feature. Value types (including the mapped struct) should be derived from the ::acdk::io::Serializable interface.

 Attributes


To support attributes, accessor methods should be implemented:


interface Foo
{
  attribute int ivalue;
  readonly attribute string svalue;
};

will be mapped in ACDK:


class Foo
: implements ::org::omg::CORBA::portable::InvokeHandler
{
private:
  int _ivalue;
  RString _svalue;
public:
  int _get_ivalue() { return _ivalue; }
  void _set_ivalue(int ival) { _ivalue = ival; }
  RString _get_svalue() { return _svalue; }
  // no setter for svalue because readonly
};



 Argument specifier

 in / out / inout




// IDL
  int foo(in int ini, out int outi, inout int inouti);
// acdk
  int foo(IN(int) ini, OUT(int) outi, INOUT(int) inouti);


If no IN/OUT/INOUT is given automatically an in value will be asumed.

 IN

IN - values are passed by value, normally basic types or RObject's.

 OUT and INOUT

OUT and INOUT values are passed by reference.

void foo(IN(RString) istr, OUT(RString) ostr)
{
  istr = "modified"; // has no effect for the caller
  ostr = "modified";// has effect for the caller
}