コード例 #1
0
ファイル: outstream.go プロジェクト: sbinet/go-gaudi
func (self *json_outstream) Initialize() kernel.Error {
	self.MsgDebug("== initialize ==\n")
	if !self.Algorithm.Initialize().IsSuccess() {
		self.MsgError("could not initialize base-class\n")
		return kernel.StatusCode(1)
	}

	self.item_names = self.GetProperty("Items").([]string)

	fname := self.GetProperty("Output").(string)
	self.MsgInfo("output file: [%v]\n", fname)
	self.MsgInfo("items: %v\n", self.item_names)

	svcloc := kernel.GetSvcLocator()
	if svcloc == nil {
		self.MsgError("could not retrieve service locator !\n")
		return kernel.StatusCode(1)
	}
	svc := svcloc.GetService("outstreamsvc").(kernel.IOutputStreamSvc)
	if svc == nil {
		self.MsgError("could not retrieve [outstreamsvc] !\n")
		return kernel.StatusCode(1)
	}

	self.handle = svc.NewOutputStream(fname)
	if self.handle == nil {
		self.MsgError("could not retrieve json output stream [%s] !\n", fname)
		return kernel.StatusCode(1)
	}

	return kernel.StatusCode(0)
}
コード例 #2
0
ファイル: evtproc.go プロジェクト: sbinet/go-gaudi
func (self *evtproc) InitializeSvc() kernel.Error {

	sc := self.Service.InitializeSvc()
	if !sc.IsSuccess() {
		return sc
	}
	self.nworkers = self.GetProperty("NbrWorkers").(int)
	//self.nworkers = 2
	self.MsgInfo("n-workers: %v\n", self.nworkers)
	svcloc := kernel.GetSvcLocator()
	if svcloc == nil {
		self.MsgError("could not retrieve ISvcLocator !\n")
		return kernel.StatusCode(1)
	}
	appmgr := svcloc.(kernel.IComponentMgr).GetComp("app-mgr")
	if appmgr == nil {
		self.MsgError("could not retrieve 'app-mgr'\n")
	}
	propmgr := appmgr.(kernel.IProperty)
	alg_names := propmgr.GetProperty("Algs").([]string)
	self.MsgInfo("got alg-names: %v\n", len(alg_names))

	if len(alg_names) > 0 {
		comp_mgr := appmgr.(kernel.IComponentMgr)
		self.algs = make([]kernel.IAlgorithm, len(alg_names))
		for i, alg_name := range alg_names {
			ialg, isalg := comp_mgr.GetComp(alg_name).(kernel.IAlgorithm)
			if isalg {
				self.algs[i] = ialg
			}
		}
	}
	self.MsgInfo("got alg-list: %v\n", len(self.algs))

	return kernel.StatusCode(0)
}