#
# Generate construct methods for factory that have GroupID, ListID, and
# PrivateID args.
#
optgen ifactory test.opt
[Scalar]
define FuncCall {
    Name Expr
    Args ExprList
    Def  FuncDef
}

# Union is a union operator.
[Relational]
define Union {
    Left   Expr
    Right  Expr
    ColMap ColMap
}

# This shouldn't be added to the factory.
[Enforcer]
define Sort {
    Input Expr
}
----
----
// Code generated by optgen; [omitted]

package opt

type Factory interface {
	// Metadata returns the query-specific metadata, which includes information
	// about the columns and tables used in this particular query.
	Metadata() *Metadata

	// InternList adds the given list of group IDs to memo storage and returns
	// an ID that can be used for later lookup. If the same list was added
	// previously, this method is a no-op and returns the ID of the previous
	// value.
	InternList(items []GroupID) ListID

	// InternPrivate adds the given private value to the memo and returns an ID
	// that can be used for later lookup. If the same value was added before,
	// then this method is a no-op and returns the ID of the previous value.
	InternPrivate(private interface{}) PrivateID

	// DynamicConstruct dynamically constructs an operator with the given type
	// and operands. It is equivalent to a switch statement that calls the
	// ConstructXXX method that corresponds to the given operator.
	DynamicConstruct(op Operator, children []GroupID, private PrivateID) GroupID

	// ------------------------------------------------------------
	// Scalar Operators
	// ------------------------------------------------------------

	// ConstructFuncCall constructs an expression for the FuncCall operator.
	ConstructFuncCall(name GroupID, args ListID, def PrivateID) GroupID

	// ------------------------------------------------------------
	// Relational Operators
	// ------------------------------------------------------------

	// ConstructUnion constructs an expression for the Union operator.
	// Union is a union operator.
	ConstructUnion(left GroupID, right GroupID, colMap PrivateID) GroupID
}
----
----
