Ejemplo n.º 1
0
    def getEffect(cls, context=''):
##        if __dev__:
##            if base.cr.hasToggledEffects():
##                # if there are any specific effects toggled on/off
##                # extract module name and see if we should show this effect type
##                match = re.split('\.',cls.__module__)
##                moduleName = match[len(match)-1]
##                if (not base.cr.queryShowEffect(moduleName+context)):
##                    return None
##            elif not base.cr.wantSpecialEffects:
##                # global effects config is off
##                return None

        # If we already have a free one, return it
        if cls.pool is None:
            # Create a pool on the derived class object
            cls.pool = Pool.Pool()
        if cls.pool.hasFree():
            return cls.pool.checkout()
        else:
            # Otherwise if we are not at our limit, make a new
            # one and return that one.
            free, used = cls.pool.getNumItems()
            if free + used < cls.poolLimit:
                # Since cls is the derived effect class, just call
                # it to create a new effect object.
                cls.pool.add(cls())
                return cls.pool.checkout()
            else:
                # If we are at our limit return None
                # Make sure your calling code can handle that!
                return None
Ejemplo n.º 2
0
 def getEffect(cls, context=''):
     if cls.pool is None:
         cls.pool = Pool.Pool()
     if cls.pool.hasFree():
         return cls.pool.checkout()
     free, used = cls.pool.getNumItems()
     if free + used < cls.poolLimit:
         cls.pool.add(cls())
         return cls.pool.checkout()
     return
     return
Ejemplo n.º 3
0
 def getEffect(cls, unlimited=False, context=''):
     if cls.pool is None:
         cls.pool = Pool.Pool()
     if unlimited or PooledEffect.GlobalCount < PooledEffect.GlobalLimit:
         if cls.pool.hasFree():
             PooledEffect.GlobalCount += 1
             return cls.pool.checkout()
         else:
             free, used = cls.pool.getNumItems()
             if free + used < cls.poolLimit:
                 PooledEffect.GlobalCount += 1
                 cls.pool.add(cls())
                 return cls.pool.checkout()
     return