BpInterface Class Template Reference

#include <support/Binder.h>

Inheritance diagram for BpInterface:

BpAtom SAtom List of all members.

Detailed Description

template<class INTERFACE>
class BpInterface< INTERFACE >

This is the base implementation for a remote IInterface.

You will not normally use this, instead letting pidgen generate similar code from an IDL file.


Protected Member Functions

virtual sptr< const IBinderAsBinderImpl () const
virtual sptr< IBinderAsBinderImpl ()
 BpInterface (const sptr< IBinder > &o)
virtual status_t DeleteAtom (const void *id)
 Called after last DecRefs() when the life of an atom is extended.
virtual status_t FinishAtom (const void *id)
 Objects can optionally override this function to extend the lifetime of an atom (past the last strong reference).
virtual status_t IncStrongAttempted (uint32_t flags, const void *id)
 Called during IncStrong() after an atom has been released.
virtual void InitAtom ()
 Called the first time a strong reference is acquired. All significant object initialization should go here.
virtual ~BpInterface ()


Constructor & Destructor Documentation

BpInterface const sptr< IBinder > &  o  )  [inline, protected]
 

virtual ~BpInterface  )  [inline, protected, virtual]
 


Member Function Documentation

virtual sptr<const IBinder> AsBinderImpl  )  const [inline, protected, virtual]
 

virtual sptr<IBinder> AsBinderImpl  )  [inline, protected, virtual]
 

virtual status_t DeleteAtom const void *  id  )  [inline, protected, virtual]
 

Called after last DecRefs() when the life of an atom is extended.

If you override FinishAtom() to not call into SAtom (and thus extend the life of your object), then this method will be called when its last reference goes away. The default implementation returns B_OK to have the object deleted. You can override this to return an error code so that the object is not destroyed.

This is a very, very unusual feature and requires a lot of careful and specific management of objects and reference counts to make work. You probably want to leave it as-is.

See also:
DecWeak(), FinishAtom()

Reimplemented from BpAtom.

virtual status_t FinishAtom const void *  id  )  [inline, protected, virtual]
 

Objects can optionally override this function to extend the lifetime of an atom (past the last strong reference).

If you return FINISH_ATOM_ASYNC here, your object's destructor will be called asynchronously from the current thread. This is highly recommend if you must acquire a lock in the destructor, to avoid unexpected deadlocks due to things like sptr<> going out of scope while a lock is held.

If you return an error code here, the object's destructor will not be called at this point.

The default implementation will return B_OK, allowing the SAtom destruction to proceed as normal. Don't override this method unless you want some other behavior. Like InitAtom(), you do not need to call the SAtom implementation.

See also:
DecStrong()

Reimplemented from BpAtom.

virtual status_t IncStrongAttempted uint32_t  flags,
const void *  id
[inline, protected, virtual]
 

Called during IncStrong() after an atom has been released.

The flags will be B_ATOM_FIRST_STRONG if this is the first strong reference ever acquired on the atom. The default implementation returns B_OK if B_ATOM_FIRST_STRONG is set, otherwise it returns B_NOT_ALLOWED to make the attempted IncStrong() fail.

You can override this to return B_OK when you would like an atom to continue allowing primary references. Note that this also requires overriding FinishAtom() to return an error code, extending the lifetime of the object. Like FinishAtom(), you do not need to call the SAtom implementation.

See also:
AttemptIncStrong(), FinishAtom()

Reimplemented from BpAtom.

virtual void InitAtom  )  [inline, protected, virtual]
 

Called the first time a strong reference is acquired. All significant object initialization should go here.

You can override it and do any setup you need. Note that you do not need to call the SAtom implementation. (So you can derive from two different SAtom implementations and safely call down to both of their IncStrong() methods.)

See also:
IncStrong()

Reimplemented from BpAtom.


The documentation for this class was generated from the following file: