8 2 ATTRIBUTE

LANSA Technical

8.2 ATTRIBUTE

A new RDMLX command called ATTRIBUTE enables the assignment of declarative attributes to the features of a component class.

The ATTRIBUTE command can be coded immediately after the following commands:

  • BEGIN_COM
  • DEFINE_COM
  • DEFINE_PTY
  • DEFINE_EVT
  • MTHROUTINE
  • DEFINE_MAP

Visual LANSA is primarily an imperative language, but like all imperative languages it does have some declarative elements. For example, the FUNCTION command enables declarative attributes to be assigned to a function or component that are later processed by the LANSA build and runtime environments.

Through its support for attributes, Visual LANSA generalizes this capability, so that programmers can invent new kinds of declarative information, attach this declarative information to various program entities, and retrieve this declarative information at run-time. Components specify this additional declarative information by defining and using attributes.

For instance, Visual LANSA might define a WinHelpAttribute attribute that can be placed on program elements such as visual member variables, enabling developers to show Window's help for their application when the F1 key is pressed.

It also means that the declarative information is stored (and consequently copied) with the RDMLX source code to which they are directly related.

Attribute classes will play a significant role in maintaining the type library information for those component classes enabled for ActiveX integration.

Whilst it is possible manually declare Attribute statements in component source it is strongly recommended that the automated ActiveX tool is used to specify ActiveX attribute details.

Attribute classes

A component class that directly or indirectly inherits from the abstract class #PRIM_ATTR is an attribute class. The only supported attribute classes will be supplied by LANSA.

Attribute usage

The AttributeUsage attribute of an attribute class describes how an attribute can be used.

The constructor of the AttributeUsage attribute has a positional parameter that enables an attribute class to specify the kinds of declarations on which the attribute can be used.

The constructor of an AttributeUsage attribute also includes an optional parameter that indicates whether the attribute can be specified more than once for a given declaration.

Instance Constructors

The instance constructors of an attribute class define the required and optional parameters needed to complete the definition of an attribute.

Reflection

The component classes that support access to Visual LANSA Types, Methods, Events, Properties and their properties will provide properties that support access to the attributes assigned to the feature.

Also See

8.2.1 ATTRIBUTE Parameters

8.2.2 ATTRIBUTE Examples

 

                                                           Required      

                                                                         

   ATTRIBUTE -----CLASS -------Class Name ------------------------>      

                                                                         

   -------------------------------------------------------------------   

                                                                         

                                                           Optional      

                                                                         

              >-- DESC ------- Short Description of event -------->

                                                                         

              >-- HELP ------- Long description of the Attribute -->