Package mrv :: Module interface :: Class iDuplicatable
[hide private]
[frames] | no frames]

Class iDuplicatable

source code

object --+    
         |    
 Interface --+
             |
            iDuplicatable
Known Subclasses:

Simple interface allowing any class to be properly duplicated

Note: to implement this interface, implement createInstance and copyFrom in your class

Instance Methods [hide private]
 
__copyTo(self, instance, *args, **kwargs)
Internal Method with minimal checking
source code
 
duplicate(self, *args, **kwargs)
Implements a c-style copy constructor by creating a new instance of self and applying the copyFrom methods from base to all classes implementing the copyfrom method.
source code
 
copyTo(self, instance, *args, **kwargs)
Copy the values of ourselves onto the given instance which must be an instance of our class to be compatible.
source code
 
copyToOther(self, instance, *args, **kwargs)
As copyTo, but does only require the objects to have a common base.
source code

Inherited from Interface: supports

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

    Interface
 
createInstance(self, *args, **kwargs)
Create and Initialize an instance of self.__class__( ...
source code
 
copyFrom(self, other, *args, **kwargs)
Copy the data from other into self as good as possible Only copy the data that is unique to your specific class - the data of other classes will be taken care of by them !
source code
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

createInstance(self, *args, **kwargs)

source code 
Create and Initialize an instance of self.__class__( ... ) based on your own data
Returns:
new instance of self
Notes:
  • using self.__class__ instead of an explicit class allows derived classes that do not have anything to duplicate just to use your implementeation
  • you must support args and kwargs if one of your iDuplicate bases does

copyFrom(self, other, *args, **kwargs)

source code 
Copy the data from other into self as good as possible Only copy the data that is unique to your specific class - the data of other classes will be taken care of by them !

Note: you must support args and kwargs if one of your iDuplicate bases does

duplicate(self, *args, **kwargs)

source code 
Implements a c-style copy constructor by creating a new instance of self and applying the copyFrom methods from base to all classes implementing the copyfrom method. Thus we will call the method directly on the class
Parameters:

copyTo(self, instance, *args, **kwargs)

source code 
Copy the values of ourselves onto the given instance which must be an instance of our class to be compatible. Only the common classes will be copied to instance
Returns:
altered instance

Note: instance will be altered during the process

copyToOther(self, instance, *args, **kwargs)

source code 
As copyTo, but does only require the objects to have a common base. It will match the actually compatible base classes and call copyFrom if possible. As more checking is performed, this method performs worse than copyTo