Access to a Part's Properties

Attributes provide access to the properties of a part. A property can be any of the following:

You can use an attribute to return the value of a property, to set the value of a property, and to notify other parts when the value of a property changes. You are not required to make public a complete attribute interface for a property. For example, a property might be read-only, in which case the part's attribute interface would not support the ability to set the property's value.

The attribute interface is represented as follows:

  aType aQueryMember();
  aSetMember(aType aValue);
  static INotificationId const anEventId;

aQueryMember is the public member function to get the current value of the property; aSetMember is the publicmember function to set the value of the property to aValue; aType is the type of aValue; anEventId is the notification ID for the property change event.

Themember function that sets the value of the property can use the following expression to notify dependent parts that the value of its property has changed:

  notifyObservers(INotificationEvent(anEventId, *this, true,
(void*)aValue));

notifyObservers is the member function that signals the event; anEventId is the notification ID for the property change event; *this is the notifier object; true indicates that the value of the attribute has changed; aValue is the event data. (For more information about events, see Notification of Changes to Parts.)

The following simpler call can be made if no event parameters are to be passed:

  notifyObservers(INotificationEvent(anEventId, *this));

The member function that sets a property's value usually signals the value change, but any member function that is aware of the change can signal the event.

While a property is often represented as a data member of a part, it need not be; the property could be a computed value. What is important is that whenever the value of the property changes, the change takes place using the set member function for the property. Changes made in any other way might not cause the event to be signaled.


Related concepts
Access to a Part's Behavior
Notification of Changes to Parts