Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

IDL attributes in C++

Attributes of an IDL interface are mapped as two methods of the C++ class: a Get and a Set method. If the attribute is readonly, only the Get method is generated. The return value for these methods is always int.

For example:

interface IFoo
{
  attribute long Sum;
};

is mapped as:

struct IFoo
{
  virtual int GetSum(int* Sum) = 0;
  virtual int SetSum(int Sum) = 0;
};

The Get method is generated with the attribute declarator as a rout parameter. The name of the method starts with Get followed by the name of the declarator. The name of the argument to the method is the name of the declarator. The argument type is mapped as usual for rout parameters.

The Set method is generated with the attribute declarator as an in parameter. The name of the method starts with Set followed by the name of the declarator. The name of the argument to the method is the name of the declarator. The argument type is mapped as usual for in parameters.

In other words, the following two fragments of IDL are equivalent, in terms of their C++ mapping, for any type T and declarator dcl:

/* Option 1 */
interface IFoo
{
  attribute T dcl;
};

/* Option 2 */
interface IFoo
{
   long Getdcl(rout T dcl);
   long Setdcl(in T dcl);
};

The above equivalence rule implies that when the type of an attribute is a string, wstring, or a sequence, the attribute methods may have multiple parameters in C++.

See Broken Link and Broken Link for details on the mapping of sequences, and string and wstring types.