Package mrv :: Package maya :: Module util :: Class CallbackEventBase
[hide private]
[frames] | no frames]

Class CallbackEventBase

source code

object --+    
         |    
util.Event --+
             |
            CallbackEventBase

Allows the mapping of MMessage callbacks to mrv's event sender system. This event will register a new message once the first event receiver registers itself. Once the last event receiver deregisters, the message will be deregistered in maya as well.

Derived types have to implement the _getRegisterFunction


Note: Its important that you care about deregistering your event to make sure the maya event can be deregistered. Its worth knowing that the eventSender in question is strongly bound to his callback event, so it cannot be deleted while the event is active.

Nested Classes [hide private]
    Utility Classes
  CBStorageFunction
Instance Methods [hide private]
 
__init__(self, eventId, **kwargs)
Initialize our instance with the callbackID we are to represent.
source code
 
send(self, inst, *args, **kwargs)
Sets our instance prior to calling the super class
source code
 
__set__(self, inst, eventfunc)
Set a new event to our object
source code
 
remove(self, eventfunc)
Also removes our callback if the last receiver is gone
source code

Inherited from util.Event: __call__, __get__, duplicate

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

    Subclass Implementation Needed
 
_getRegisterFunction(self, eventID)
Returns: MMessage::register* compatible callback function which can be used to register the given eventID
source code
    CallbackID handling
 
_storeCallbackID(self, inst, callbackID)
Store the given callbackID in the event sender instance.
source code
 
_getCallbackIDStorage(self, inst, create=False)
Returns: Callback storage function if it exists or None
source code
 
_getCallbackID(self, inst)
Returns: stored callback ID or None
source code
Class Variables [hide private]

Inherited from util.Event: remove_on_error, sender_as_argument, use_weakref

Inherited from util.Event (private): _curSender, _inst_event_attr

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, eventId, **kwargs)
(Constructor)

source code 
Initialize our instance with the callbackID we are to represent.
Parameters:
  • kwargs -
    • weak: if True, default class configuration use_weakref, weak

      references will be created for event handlers, if False it will be strong references

    • remove_failed: if True, defailt False, failed callback handlers

      will be removed silently

    • sender_as_argument - see class member

Overrides: object.__init__

_getRegisterFunction(self, eventID)

source code 
Returns:
MMessage::register* compatible callback function which can be used to register the given eventID

_storeCallbackID(self, inst, callbackID)

source code 
Store the given callbackID in the event sender instance. We do that by registering it as function for the given instance which
Returns:
the callback ID on call

_getCallbackIDStorage(self, inst, create=False)

source code 
Parameters:
  • create - if True, the storage will be created if needed, hence you will always receive a valid storage
Returns:
Callback storage function if it exists or None

_getCallbackID(self, inst)

source code 
Returns:
stored callback ID or None

send(self, inst, *args, **kwargs)

source code 
Sets our instance prior to calling the super class
Returns:
False if at least one event call threw an exception, true otherwise
Overrides: util.Event.send

Note: must not be called manually

__set__(self, inst, eventfunc)

source code 
Set a new event to our object
Overrides: util.Event.__set__
(inherited documentation)

remove(self, eventfunc)

source code 
Also removes our callback if the last receiver is gone
Overrides: util.Event.remove