A creator is a command belonging to a factory and is used to create objects of the type implemented by the factory.
Each factory contains one or more creators.
Each creator is accessed through its identifier which must be unique within the factory.
A creator can have any number of input arguments, but it must always have at least one output argument whose type is the type implemented by the factory.
Table 6.11. Creator
| Production | Syntax | Links |
|---|---|---|
creator |
| the section called “Creator” |
All properties defined for commands and their arguments also apply to creators. For more information please refer to Table 6.8, “Command properties”
In addition to the properties existing for commands, a creator has the following property:
Table 6.12. Additional creator property
| Property | Value | Required | Default value |
|---|---|---|---|
kind | one of the following:standard in_all | no | standard |
Property kind defines the kind of creator.
standard is the default value and denotes a creator for which all arguments and the script have to be defined explicitly.
in_all tells the compiler to automatically create the list of arguments and, optionally, the script. This eliminates the need for manually writing similar code again and again. If kind is in_all then:
no arguments can be explicitly defined in the source code. The compiler automatically creates:
one input argument for each attribute of kind constant or variable that is defined in the type which is implemented by the factory. The following properties of each input argument are the same as those defined for its corresponding attribute: id suffix, type, voidable, check and default.
one output argument whose id is result, whose type is the type implemented by the factory, and whose voidable property is set to no
a script can optionally be defined. If no script is defined then the compiler automatically creates a script that assigns each input argument to its corresponding attribute
Example 6.9. Creators
Suppose the following type exists:
type customer_7 attribute identifier type:positive32 end attribute name type:string default: "unknown" kind:variable end attribute city type:string voidable:yes kind:variable end attribute last_order_date type:date_time voidable:yes kind:readonly_variable end end type
Then all 3 creators in the following factory do exactly the same:
factory customer_7 type:customer_7
attribute last_order_date
get
script
// o_last_order_date = ...
end
end
end
creator create kind:in_all end
creator create_2 kind:in_all
script
o_result.a_identifier = i_identifier
o_result.a_name = i_name
o_result.a_city = i_city
end script
end creator
creator create_3
in identifier type:positive32 end
in name type:string default: "unknown" end
in city type:string voidable:yes end
out result type:customer_7 end
script
o_result.a_identifier = i_identifier
o_result.a_name = i_name
o_result.a_city = i_city
end script
end creator
end factoryFor more examples, see: