|
|
|
|
|
Use the Attribute tab to define the attributes for your part. an Attribute represents a property of a part. an Attribute encapsulates access to attribute data. It is up to you whether data for the attribute is stored in a data member, calculated, or acquired from some other location.
The Attribute tab lists all attributes defined by a part. This tab does not list attributes that are inherited from the base part. This tab also does not list promoted attributes that are defined by embedded parts. Promoted attributes are listed on the Promote tab.
an Attribute provides access to attribute data. A get member function retrieves the value of an attribute. A set member function set the attribute value. Attribute event identification allows a part to notify other parts that the attribute value has been changed.
To use an attribute, make a connection to its name. When you generate code, the get member function is used to retrieve the attribute value for a connection, and the set member function is used to set the attribute. The attribute event identification is used to report value changes for attribute-to-attribute connections.
Use the following fields to specify an attribute:
Connections
Adding Attribute
Features
Push Buttons -- Part Interface
Editor
Part Interface Editor
Visual Composition Messages
Use the Attribute name field to specify a descriptive name for an attribute. This name appears on the connection menu when you make connections to or from the attribute in the Composition Editor.
The attribute name can contain only single-byte alphanumeric characters and blanks. Each attribute name within a part must be unique.
You cannot change the attribute name directly. To rename an attribute, do the following:
Use the Attribute type field to specify the data type of an attribute. Enter or select the type of data that the attribute represents. Either select a loaded data type from the drop-down list or specify any type in the entry field.
The initial default type for a new attribute is int. If you select another type, such as IString, the new data type becomes the default for any new attributes you create until you change it again or until you close the Part Interface Editor window. When you open the Part Interface Editor window again, the default data type for any new attributes you create reverts to int until you change it by creating another attribute or modifying an existing one.
When VisualAge generates code, attribute data members are private. To provide access to attribute data, define accessor member functions. These member functions are used by connections to get and set data.
Use the Get member function field to specify a member function that retrieves the value of an attribute. If you want a get member function, specify the member function signature in this field. The get member function name cannot contain DBCS characters. Typically, a get member function returns the value of a data member. However, it could perform some other function, such as return a computed value.
You do not have to specify a get member function. For example, you might want to omit the get member function for an attribute that contains sensitive data, such as a password, so that no other parts can retrieve its value.
If you select the Defaults push button, a default member function signature is placed in the Get member function field. The get member function name is derived from the attribute name.
VisualAge generates default code for the get and set member functions if you select File, then Save and generate, then Feature source. Using this choice also generates event notification.
If you want to write your own get member function, use your favorite editor to write the needed code. Enter the names of the header and code files in the Code generation fields on the Generation Options tab of the Class Editor.
Use the Set member function field to specify a member function that sets the value of an attribute. If you want a set member function, specify the member function signature in this field. The set member function name cannot contain DBCS characters. Typically, a set member function sets the value of a data member. However, it could perform some other function, such as adding the value to a database.
You do not have to specify a set member function. However, another part cannot set or change the value of the attribute without a set member function. You can omit a set member function if you want to enable other parts to retrieve but not set an attribute. For example, you might not want other parts to set the current date.
If you select the Defaults push button, a default member function signature is placed in the Set member function field. The set member function name is derived from the attribute name, with set added at the beginning.
VisualAge generates default code for the get and set member functions if you select File, then Save and generate, then Feature source. Using this choice also generates event notification.
Use the Event identification field to specify an identifier for the attribute. When the attribute is used as the source of a connection, the identifier informs the connection target when this attribute changed.
You do not have to specify a value in the Event identification field. If you do not specify a name, other parts are not notified when the attribute is updated and consequently have an old value for that attribute. For example, if an entry field is connected to a street attribute and the street is updated in a corresponding database, the entry field is not notified, and contains an old address.
If you select the Defaults push button, a default identifier is placed in the Event identification field. The identifier is derived from the attribute name, with Id added at the end.
If you generate a set member function for your attribute, the default code that VisualAge generates signals the change event if the value of the attribute changes.
The Description field enables you to provide a brief feature description. Either enter a text description in the entry field, or select the Edit push button to specify a resource ID for the description.
Settings in the Constraints group determine how the feature can be used in the Composition Editor.
To prevent definition of an item on certain platforms, select the appropriate check boxes in this group. In the Class Editor, these settings apply to the entire class. In the Part Interface Editor, these settings apply to the feature being defined.
