Declaring an attribute as part of an interface is equivalent to declaring two accessor methods: one to retrieve the value of the attribute (a "get" method, named "_get_<attributeName>") and one to set the value of the attribute (a "set" method, named "_set_<attributeName>").
Attributes are declared as follows:
[ readonly ] attribute type-spec declarators ;
where "type-spec" specifies any valid IDL type and "declarators" is a list of identifiers or pointer declarators, delimited by commas. (An array declarator cannot be used directly when declaring an attribute, but the type of an attribute can be a user-defined type that is an array.) The optional readonly keyword specifies that the value of the attribute can be accessed but not modified by client programs. (In other words, a readonly attribute has no "set" method.) Below are examples of attribute declarations, which are specified within the body of an interface statement for a class:
interface Goodbye: Hello, SOMObject { void sayBye(); attribute short xpos; attribute char c1, c2; readonly attribute float xyz; };
The preceding attribute declarations are equivalent to defining the following methods:
short _get_xpos(); void _set_xpos(in short xpos); char _get_c1(); void _set_c1(in char c1); char _get_c2(); void _set_c2(in char c2); float _get_xyz();
Note: Although the preceding attribute declarations are equivalent to the explicit method declarations above, these method declarations are not legal IDL, because the method names begin with an '_'. All IDL identifiers must begin with an alphabetic character, not including '_'.
Attributes are inherited from ancestor classes (indirect base classes). An inherited attribute name cannot be redefined to be a different type.