00001 # Copyright (C) 2008-2009 Mark Hanegraaff 00002 # 00003 # This program is free software: you can redistribute it and/or modify 00004 # it under the terms of the GNU General Public License as published by 00005 # the Free Software Foundation, either version 3 of the License, or 00006 # (at your option) any later version. 00007 # 00008 # This program is distributed in the hope that it will be useful, 00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 # GNU General Public License for more details. 00012 # 00013 # You should have received a copy of the GNU General Public License 00014 # along with this program. If not, see <http://www.gnu.org/licenses/>. 00015 00016 00017 import copy 00018 00019 00020 00021 ## The subjectInterface class follows a generic observer/subject pattern 00022 # In reality the networkMonitor class acts as the observer, delivering a copy of all 00023 # packets to various listeners. These listeners include the "storageManage" and the "entityManager" 00024 00025 class subjectInterface: 00026 def __init__(self): 00027 self._observers = [] 00028 00029 ## Add a new observer to the list. The observer is notifies by calling the 00030 # update method 00031 # @param observer Observer object 00032 def attach(self, observer): 00033 if not observer in self._observers: 00034 self._observers.append(observer) 00035 00036 ## removed an observer from the list. 00037 def detach(self, observer): 00038 try: 00039 self._observers.remove(observer) 00040 except ValueError: 00041 pass 00042 00043 00044 # Notifies all Observers 00045 # @param header Raw DataLink header 00046 # @param data Raw DataLink frame 00047 def notifyAll(self, header, data): 00048 for observer in self._observers: 00049 observer.update(header, data) 00050
1.5.8