Exemplo n.º 1
0
// --- factory function ---
func New(t, n string) kernel.IComponent {
	switch t {
	case "alg1":
		self := &alg1{}
		_ = kernel.NewAlg(&self.Algorithm, t, n)
		kernel.RegisterComp(self)
		return self
	case "alg2":
		self := &alg2{}
		_ = kernel.NewAlg(&self.Algorithm, t, n)
		kernel.RegisterComp(self)
		return self
	case "svc1":
		self := &svc1{}
		_ = kernel.NewSvc(&self.Service, t, n)
		kernel.RegisterComp(self)
		return self
	case "tool1":
		self := &tool1{}
		_ = kernel.NewTool(&self.AlgTool, t, n, nil)
		kernel.RegisterComp(self)
		return self
	default:
		err := "no such type [" + t + "]"
		panic(err)
	}
	return nil
}
Exemplo n.º 2
0
// --- factory function ---
func New(t, n string) kernel.IComponent {
	switch t {
	case "alg1":
		self := &alg1{}
		_ = kernel.NewAlg(&self.Algorithm, t, n)
		kernel.RegisterComp(self)
		return self
	case "svc2":
		self := &svc2{}
		_ = kernel.NewSvc(&self.Service, t, n)
		kernel.RegisterComp(self)
		return self
	case "alg_adder":
		self := &alg_adder{}
		_ = kernel.NewAlg(&self.Algorithm, t, n)
		kernel.RegisterComp(self)

		self.DeclareProperty("Val", -99.)
		self.DeclareProperty("SimpleCounter", "cnt")
		return self

	case "alg_dumper":
		self := &alg_dumper{}
		_ = kernel.NewAlg(&self.Algorithm, t, n)
		kernel.RegisterComp(self)

		self.DeclareProperty("SimpleCounter", "cnt")
		self.DeclareProperty("ExpectedValue", -1)
		self.DeclareProperty("NbrJets", "njets")
		self.DeclareProperty("PtJets", "ptjets")
		return self

	default:
		err := "no such type [" + t + "]"
		panic(err)
	}
	return nil
}
Exemplo n.º 3
0
// --- factory ---
func New(t, n string) kernel.IComponent {
	switch t {
	case "gob_outstream":
		self := &gob_outstream{}
		kernel.NewAlg(&self.Algorithm, t, n)
		kernel.RegisterComp(self)

		// properties
		self.DeclareProperty("Output", "foo.gob")
		self.DeclareProperty("Items", g_keys)
		return self

	case "json_outstream":
		self := &json_outstream{}
		kernel.NewAlg(&self.Algorithm, t, n)
		kernel.RegisterComp(self)

		// properties
		self.DeclareProperty("Output", "foo.json")
		self.DeclareProperty("Items", g_keys)
		return self

	case "json_outstream_svc":
		self := &json_outstream_svc{}
		kernel.NewSvc(&self.Service, t, n)
		kernel.RegisterComp(self)

		self.streams = make(map[string]kernel.IOutputStream)
		// properties

		return self

	default:
		err := "no such type [" + t + "]"
		panic(err)
	}
	return nil
}