Autowiring  1.0.3
A C++ Inversion of Control Framework
ContextMember Class Reference

A class that must be inherited in order to be a member of a context heriarchy More...

#include <ContextMember.h>

Inheritance diagram for ContextMember:
AutoPacketFactory BasicThread CoreThread

Public Member Functions

std::shared_ptr< CoreContextGetContext (void) const
 Retrieves the context associated with this object. More...
 
template<class T >
std::shared_ptr< const T > GetSelf (void) const
 Returns a shared pointer that refers to ourselves More...
 
template<class T >
std::shared_ptr< T > GetSelf (void)
 Returns a shared pointer that refers to ourselves More...
 
virtual void NotifyContextTeardown (void)
 Invoked by the parent context when the parent context is about to be destroyed More...
 

Detailed Description

A class that must be inherited in order to be a member of a context heriarchy

Examples:
AutoNetExample.cpp.

Member Function Documentation

std::shared_ptr<CoreContext> ContextMember::GetContext ( void  ) const
inline

Retrieves the context associated with this object.

By default, the context will be whatever the current context was in the thread where this object was constructed at the time of the object's construction.

Note that, if the context is in the process of tearing down, this return value could be null.

template<class T >
std::shared_ptr<const T> ContextMember::GetSelf ( void  ) const
inline

Returns a shared pointer that refers to ourselves

template<class T >
std::shared_ptr<T> ContextMember::GetSelf ( void  )
inline

Returns a shared pointer that refers to ourselves

virtual void ContextMember::NotifyContextTeardown ( void  )
inlinevirtual

Invoked by the parent context when the parent context is about to be destroyed

A context may be destroyed if and only if none of its members are running and none of them may enter a runnable state. This happens when the last pointer to ContextMember is lost. Resource cleanup must be started at this point. Context members are deemed to be unable to enter a running state if they were not signalled to enter this state before the last shared pointer to their outer CoreContext is released.

For contexts containing strictly heirarchial objects, implementors of this method do not need to do anything. If, however, there are circular references anywhere in the context, callers should invoke reset() on each autowired member they control.

TODO: Eventually, we MUST eliminate this method and simply keep track of all Autowired instances in a single context. This can be done safely by using the Autowired's internal m_tracker member, which can serve to notify listeners when the instance is destroyed. Alternatively, the Autowired instance could attach and detach itself from a linked list in a lock-free way in order to support chain detachment.


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