Attribute declarations

Attributes allow you to associate a value with an interface. IDL attributes are similar in concept to structure fields in languages such as C. However, when mapped to a programming language, attribute values can typically be accessed only by generated functions that allow you to set and retrieve the attribute’s value.

Attributes are declared as shown below:

[ readonly ] attribute TypeSpec name;

where

In C++ and Java, a read-only attribute maps to a method with the same name that returns the attribute type. A writable attribute maps to a pair of overloaded methods with the same name as the attribute. For example, consider the following IDL declarations:

readonly attribute long days; // readonly
attribute long months;        // writable

In a C++ or Java implementation of the interface, these methods must be declared:

long days();
long months();
void months(long new_months);