go-hep.org/x/hep@v0.38.1/fwk/cmd/fwk-new-comp/svc_template.go (about)

     1  // Copyright ©2017 The go-hep Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package main
     6  
     7  const g_svc_template = `package {{.Package}}
     8  
     9  import (
    10  	"reflect"
    11  
    12  	"go-hep.org/x/hep/fwk"
    13  )
    14  
    15  type {{.Name}} struct {
    16      fwk.SvcBase
    17  }
    18  
    19  func (svc *{{.Name}}) Configure(ctx fwk.Context) error {
    20      var err error
    21  
    22  	// err = svc.DeclInPort(svc.input, reflect.TypeOf(sometype{}))
    23  	// if err != nil {
    24  	//	return err
    25  	// }
    26  
    27  	// err = svc.DeclOutPort(svc.output, reflect.TypeOf(sometype{}))
    28  	// if err != nil {
    29  	//	return err
    30  	// }
    31  
    32      return err
    33  }
    34  
    35  func (svc *{{.Name}}) StartSvc(ctx fwk.Context) error {
    36  	var err error
    37  
    38  	return err
    39  }
    40  
    41  func (svc *{{.Name}}) StopSvc(ctx fwk.Context) error {
    42  	var err error
    43  
    44  	return err
    45  }
    46  
    47  func new{{.Name}}(typ, name string, mgr fwk.App) (fwk.Component, error) {
    48  	var err error
    49  	svc := &{{.Name}}{
    50  		SvcBase: fwk.NewSvc(typ, name, mgr),
    51  		// input:    "Input",
    52  		// output:   "Output",
    53  	}
    54  
    55  	// err = svc.DeclProp("Input", &svc.input)
    56  	// if err != nil {
    57  	// 	return nil, err
    58  	// }
    59  
    60  	// err = svc.DeclProp("Output", &svc.output)
    61  	// if err != nil {
    62  	//	return nil, err
    63  	// }
    64  
    65  	return svc, err
    66  }
    67  
    68  func init() {
    69  	fwk.Register(reflect.TypeOf({{.Name}}{}), new{{.Name}})
    70  }
    71  `