Package Ganga :: Package Core :: Package GangaThread :: Package MTRunner :: Module Algorithm'
[hide private]
[frames] | no frames]

Source Code for Module Ganga.Core.GangaThread.MTRunner.Algorithm'

 1  #!/usr/bin/env python 
2 -class AlgorithmError(Exception):
3 """ 4 Class for Algorithm errors. 5 """ 6
7 - def __init__(self, message):
8 self.message = message
9 10
11 -class Algorithm:
12 """ 13 Class to define user algorithm. 14 """ 15 16 _attributes = ('results') 17
18 - def __init__(self):
19 self.results = {} 20 pass
21
22 - def __appendResult__(self, item, result):
23 self.results[item] = result
24
25 - def process(self, item):
26 """ 27 implements how to deal with the given data item. The output of the process can be 28 appended to the self.results dictionary by calling self.__appendResult__(item, result). 29 30 @since: 0.0.1 31 @author: Hurng-Chun Lee 32 @contact: hurngchunlee@gmail.com 33 34 @param item is the sigle item from the data collection 35 @return True if the item is properly processed; otherwise False 36 """ 37 raise NotImplementedError('algorithm needs to be implemented to deal with the data item')
38
39 - def getResults(self):
40 """ 41 returns the up-to-date results from what has been processed by this algorithm object. 42 """ 43 return self.results
44