Creator

Description

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.

Syntax

Table 6.11. Creator

ProductionSyntaxLinks
creator

"creator" ( "id" ":" ) ? command_id command_properties
   input_argument *
   in_check ?
   output_argument *
   out_check ?
   script
"end" "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

PropertyValueRequiredDefault value
kindone of the following:
standard
in_all
nostandard

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:

Examples

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 factory

For more examples, see:

See also