Understanding the FlexPro Object Hierarchy

23.08.2021

As opposed to most Automation object models such as that of Microsoft Office, FlexPro objects are structured hierarchically. This means that properties and methods that apply to several objects are combined to form a base object. Structuring is multi-layered, ranging from general to specific. The object hierarchy of FlexPro applies a powerful principle of object-oriented programming, called inheritance. The following illustration shows the object hierarchy of the FlexPro 2D diagram.

Inheritance offers a number of advantages with regard to both implementation of FlexPro and use of the FlexPro object model. For the implementation of FlexPro, inheritance means that the implementation of a base object can be re-used in all objects that are based on this base object. The software is therefore more compact and easier to maintain. In the above, example, the CursorObject is the base object for the 2D diagram (Diagram2D, the 3D diagram (Diagram3D), the worksheet (Worksheet) and the document (Document). One implementation is being used for four different objects. The further up you move in the object hierarchy, the greater this so-called "code re-use". For example, all objects that can be stored in the FlexPro database are derived from FpObject.

In addition, during the development of automation applications that access the FlexPro object model, the FlexPro object hierarchy represents a major advantage. For example, a program that only uses the properties and methods of the CursorObject interface will run with all FlexPro CursorObjects (2D diagram, 3D diagram, etc.) without requiring changes even if later versions of FlexPro contain additional objects derived from CursorObject. The compiler (Basic, C++, Java ...) used for the implementation of the application can generate very fast code because all methods and properties of CursorObject are known at compile time. Thus, calls can be directly converted to addresses, which considerably accelerates the subsequent processing of the program. In Basic you can benefit from this by choosing the CursorObject type for the object variable. You therefore tell the compiler which set of properties and methods will be available at the time the program is compiled.

If FlexPro did not have an object hierarchy, an object variable that is to have any object that supports cursors would have to be declared an unspecified Object type. Such a program could also work with new objects supporting cursors without requiring changes. The processing speed, however, would be much lower. Since the compiler does not know the properties and methods of the actual object held by the object variable during compiling of the program, the address, such as that of a method, cannot be established until the program is executed. Using the name of the method, its index in the interface is identified. The method is then called using the generic Invoke function. All arguments have to be packed in what are called variants, since their data types are not known at the time of compilation. Another serious disadvantage of this procedure is that many errors, such as "wrong method name," "wrong number of arguments" or "wrong argument data type," will not be identified until the program is executed.

Share article or send as email:

You might be interested in these articles