instrumentation: add next-share/
[cs-p2p-next.git] / instrumentation / next-share / BaseLib / Core / Statistics / Status / __init__.py
1 # Written by Njaal Borch
2 # see LICENSE.txt for license information
3
4 """
5 Status gathering module with some simple reporting functionality
6
7 Usage example:
8
9 status = Status.get_status_holder("somename") # Get status object
10 reporter = MyReporter("MyReporter")           # Create the reporter
11 status.add_reporter(reporter)                 # Add the reporter to the status object
12
13 # Create new element
14 elem = status.create_status_element("ElementName",
15                                     "Description",
16                                     initial_value=None)
17 elem.set_value(somevalue)
18
19 # The element will now be reported by the reporter.
20
21 A reporter can be created easily like this:
22
23 # Print name=value when the element is changed
24 class MyOnChangeStatusReporter(Status.OnChangeStatusReporter):
25
26     def report(self, element):
27         print element.name,"=",element.value
28
29
30 # Print name=value for all elements when the periodic reporter runs
31 class MyPeriodicStatusReporter(Status.PeriodicStatusReporter):
32     def report(self):
33         for elems in self.elements[:]:
34             print element.name,"=",element.value
35
36
37 See the StatusTest.py class for more examples
38
39 """
40
41 from Status import *
42 from LivingLabReporter import LivingLabPeriodicReporter