Changeset 160

Show
Ignore:
Timestamp:
05/17/02 17:39:46 (6 years ago)
Author:
sholloway
Message:

Added a category to the StateMachine?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/RBJabber/RBJabber/SubjectObserver/StateMachine.py

    r159 r160  
    3535#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    3636 
    37 from Subject import Subject 
     37from CategorySubject import CategorySubject  
    3838from operator import and_, or_ 
    3939 
     
    6868#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    6969 
    70 class State(Subject): 
     70class State(CategorySubject): 
    7171    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    7272    #~ Constants / Variables / Etc.  
     
    8383    def __init__(self, InfluxsClass=AndStateList, **kw): 
    8484        self.__dict__.update(kw) 
    85         Subject.__init__(self) 
     85        CategorySubject.__init__(self) 
    8686        self._Influxs = InfluxsClass() 
    87         self.StateSubject = Subject() 
    8887 
    8988    def __int__(self):  
     
    9493    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    9594 
     95    def AddObserver(self, callable, category='', **kw): 
     96        category = category or 'precondition' 
     97        return apply(CategorySubject.AddObserver, (self, category, callable), kw) 
     98 
    9699    def SetState(self, value =1): 
    97100        if value != self.value: 
     
    99102            if self.value and not self._Influxs: 
    100103                self.UpdateObservers(precondition=self.value) 
    101             self.StateSubject.UpdateObservers(state=self) 
     104            self.UpdateObservers(state=self) 
    102105            if self._handled > 0:  
    103106                self._handled = 0 
     
    111114            precondition = int(self._Influxs) 
    112115            if precondition: 
    113                 lock = self.StateSubject.Lock() 
     116                lock = self.Lock() 
    114117                self.UpdateObservers(precondition=precondition) 
    115118                self._Influxs.SetHandled() 
     
    118121    def AddInflux(self, Influx): 
    119122        self._Influxs.append(Influx) 
    120         Influx.StateSubject.AddObserver(self.CheckInfluxs, priority=-1) 
     123        Influx.AddObserver(self.CheckInfluxs, 'state', priority=-1) 
    121124 
    122125    def AddOutflux(self, Outflux):