[3c44c66] | 1 | ################################################################################ |
---|
| 2 | #This software was developed by the University of Tennessee as part of the |
---|
| 3 | #Distributed Data Analysis of Neutron Scattering Experiments (DANSE) |
---|
| 4 | #project funded by the US National Science Foundation. |
---|
| 5 | # |
---|
| 6 | #See the license text in license.txt |
---|
| 7 | # |
---|
| 8 | #copyright 2010, University of Tennessee |
---|
| 9 | ################################################################################ |
---|
| 10 | """ |
---|
| 11 | This module manages all data loaded into the application. Data_manager makes |
---|
| 12 | available all data loaded for the current perspective. |
---|
| 13 | |
---|
| 14 | All modules creating |
---|
| 15 | fake Data posts their data to data_manager . Data_manager make these new data |
---|
| 16 | available for all other perspectives. |
---|
| 17 | """ |
---|
| 18 | |
---|
| 19 | class DataManager(object): |
---|
| 20 | """ |
---|
| 21 | Manage a list of data |
---|
| 22 | """ |
---|
| 23 | def __init__(self, parent): |
---|
| 24 | """ |
---|
[aebc4cc] | 25 | Store opened path and data object created at the loading time |
---|
[4e9583c] | 26 | """ |
---|
[aebc4cc] | 27 | self.loaded_data_list = [] |
---|
| 28 | self.created_data_list = [] |
---|
| 29 | self.list_of_data = [] |
---|
| 30 | self.message = "" |
---|
[32c0841] | 31 | self.parent = parent |
---|
[3c44c66] | 32 | |
---|
[aebc4cc] | 33 | def get_message(self): |
---|
[3c44c66] | 34 | """ |
---|
[aebc4cc] | 35 | return message |
---|
[3c44c66] | 36 | """ |
---|
[aebc4cc] | 37 | return self.message |
---|
[3c44c66] | 38 | |
---|
[32c0841] | 39 | def set_loaded_data(self, data_list=None): |
---|
[3c44c66] | 40 | """ |
---|
[aebc4cc] | 41 | save data and path |
---|
[3c44c66] | 42 | """ |
---|
[32c0841] | 43 | if data_list is None: |
---|
[aebc4cc] | 44 | return |
---|
[32c0841] | 45 | for data, path in data_list: |
---|
| 46 | if data.name not in self.list_of_data: |
---|
| 47 | self.loaded_data_list.append((data, path)) |
---|
| 48 | self.list_of_data.append(data.name) |
---|
| 49 | else: |
---|
| 50 | self.message += " %s already loaded" % str(data.name) |
---|
[3c44c66] | 51 | |
---|
[32c0841] | 52 | def set_created_data(self, data_list=None): |
---|
[3c44c66] | 53 | """ |
---|
[aebc4cc] | 54 | return |
---|
[3c44c66] | 55 | """ |
---|
[32c0841] | 56 | if data_list is None: |
---|
| 57 | return |
---|
[aebc4cc] | 58 | for data, path in data_list: |
---|
[32c0841] | 59 | for created_data, _ in self.created_data_list: |
---|
[aebc4cc] | 60 | if data.name == created_data.name: |
---|
[32c0841] | 61 | self.message += " %s already created" % str(data.name) |
---|
[aebc4cc] | 62 | else: |
---|
| 63 | self.created_data_list.append((data, path)) |
---|
| 64 | |
---|
| 65 | def get_data(self): |
---|
[3c44c66] | 66 | """ |
---|
[aebc4cc] | 67 | Send list of available data |
---|
[3c44c66] | 68 | """ |
---|
[32c0841] | 69 | return self.loaded_data_list + self.created_data_list |
---|
[3c44c66] | 70 | |
---|