In addition to methods, SOM objects can also have attributes. An attribute is an IDL shorthand for declaring methods, and does not necessarily indicate the presence of any particular instance data in an object of that type. Attribute methods are called "get" and "set" methods. For example, if a class "Hello" declares an attribute called "msg", then object variables of type "Hello" will support the methods _get_msg and _set_msg to access or set the value of the "msg" attribute. (Attributes that are declared as "readonly" have no "set" method, however.)
The "get" and "set" methods are invoked in the same way as other methods. For example, given class "Hello" with attribute "msg" of type string, the following code segments set and get the value of the "msg" attribute:
For C:
#include <hello.h> Hello obj; Environment *ev = somGetGlobalEnvironment(); obj = HelloNew(); __set_msg(obj, ev, "Good Morning");/*note: two leading underscores */ printf("%s\n", __get_msg(obj, ev));
For C++:
#include <hello.xh> #include <stdio.h> Hello *obj; Environment *ev = somGetGlobalEnvironment(); obj = new Hello; obj->_set_msg(ev, "Good Morning"); printf("%s\n", obj->_get_msg(ev));
Attributes available with each class, if any, are described in the documentation of the class itself in the System Object Model Programming Reference.