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

A special class designed to make it easier to detect when our context is the global context. More...

#include <GlobalCoreContext.h>

Inheritance diagram for GlobalCoreContext:
CoreContextT< GlobalCoreContext > CoreContext

Static Public Member Functions

static std::shared_ptr< GlobalCoreContextGet (void)
 Obtains the global core context, or initializes it if necessary More...
 
static std::shared_ptr< GlobalCoreContextRelease (void)
 Releases the global context, allowing reinitialization More...
 
- Static Public Member Functions inherited from CoreContext
static std::shared_ptr< CoreContextCurrentContext (void)
 Identical to CurrentContextOrNull, except returns the global context instead of a null pointer More...
 
static const std::shared_ptr< CoreContext > & CurrentContextOrNull (void)
 The shared pointer to the current context. More...
 
static void EvictCurrent (void)
 Makes no context current. More...
 
static std::shared_ptr< CoreContextGetGlobal (void)
 Returns a shared reference to the global context. More...
 
template<typename T >
static void InjectCurrent (void)
 Injects a type into the current context. More...
 
static std::shared_ptr< CoreContextSetCurrent (const std::shared_ptr< CoreContext > &ctxt)
 Static version of SetCurrent, may be invoked with nullptr More...
 
static std::shared_ptr< CoreContextSetCurrent (std::shared_ptr< CoreContext > &&ctxt)
 Move-optimized version of SetCurrent More...
 

Additional Inherited Members

- Public Member Functions inherited from CoreContext
template<typename T >
void Add (const std::shared_ptr< T > &ptr)
 Introduces the specified pointer to this context explicitly More...
 
void AddSnooper (const autowiring::CoreObjectDescriptor &traits)
 Runtime version of AddSnooper More...
 
template<class T >
void AddSnooper (const std::shared_ptr< T > &pSnooper)
 Registers the specified event receiver to receive messages from this context More...
 
template<class T >
void AddSnooper (const Autowired< T > &snooper)
 Resolution overload More...
 
template<typename T >
const std::shared_ptr< T > & Await (void)
 Similar to Inject, except will block until the specified type is available in the context More...
 
template<typename T >
std::shared_ptr< T > Await (std::chrono::nanoseconds timeout)
 Timed version of Await More...
 
const AnySharedPointer & Await (auto_id id)
 Runtime Await variant More...
 
AnySharedPointer Await (auto_id id, std::chrono::nanoseconds timeout)
 Runtime Await variant More...
 
template<class T , class... Sigils>
void BoltTo (void)
 Injects the specified type T into all subcontexts created with one of the matching sigil types. More...
 
std::vector< const autowiring::CoreObjectDescriptor * > BuildObjectState (void) const
 Gets a snapshot of all of the objects currently in the context More...
 
std::vector< std::shared_ptr< BasicThread > > CopyBasicThreadList (void) const
 A copy of the current list of child CoreRunnables of this context. More...
 
template<class T >
std::shared_ptr< CoreContextT< T > > Create (void)
 Creates a child context of this context. More...
 
bool DelayUntilInitiated (void)
 Waits until the context is initiated or, if never initiated, until it starts shutting down. More...
 
void Dump (std::ostream &os) const
 Utility debug method for writing a snapshot of this context to the specified output stream More...
 
template<class T >
void Enable (void)
 Allows a specifically named class to be "bolted" to this context or one of its subcontexts. More...
 
void FilterException (void)
 Filters std::current_exception using any registered exception filters, or rethrows. More...
 
void FilterFiringException (const JunctionBoxBase *pProxy, CoreObject *pRecipient)
 Filters a std::current_exception thrown by an EventSenderBase during a Fire More...
 
std::shared_ptr< CoreContextFirstChild (void) const
 The first child in the set of this context's children. More...
 
auto_id GetAutoTypeId (const AnySharedPointer &ptr) const
 Gets the type information for the instance referenced by the specified shared pointer. More...
 
t_childList::iterator GetBackReference (void) const
 The Context iterator for the parent context's children, pointing to this context.
 
size_t GetChildCount (void) const
 The number of child contexts of this context.
 
size_t GetMemberCount (void) const
 The number of Autowired members in this context.
 
const std::shared_ptr< CoreContext > & GetParentContext (void) const
 A shared reference to the parent context of this context.
 
std::vector< CoreRunnable * > GetRunnables (void) const
 Returns a copy of the list of runnables More...
 
auto_id GetSigilType (void) const
 The type used as a sigil when creating this class, if any.
 
template<class T >
bool Has (void) const
 True, if an instance of the specified type exists and dependencies of that type can be autowired in this context. More...
 
void Initiate (void)
 Starts all registered threads and enables events and the flow of filter graph packets. More...
 
template<typename T , typename... Args>
std::shared_ptr< T > Inject (Args &&...args)
 Injects the specified types into this context. More...
 
template<class Sigil >
bool Is (void) const
 True if the sigil type of this CoreContext matches the specified sigil type.
 
bool IsAncestorOf (const CoreContext *child) const
 Reports whether the specified context is an ancestor of this context. More...
 
bool IsAnonymousContext (void) const
 True if and only if this is an anonymous context.
 
bool IsGlobalContext (void) const
 True if and only if this is the global context.
 
bool IsInitiated (void) const
 True, if the context has been initiated. More...
 
bool IsQuiescent (void) const
 Retrieves the system's current quiescence status More...
 
bool IsRunning (void) const
 True, if the context is presently running. More...
 
bool IsShutdown (void) const
 
std::shared_ptr< CoreContextNextSibling (void) const
 The next context sharing the same parent, or null if this is the last entry in the list More...
 
template<class T , class Fn >
void NotifyWhenAutowired (Fn &&listener)
 Adds a post-attachment listener in this context for a particular autowired member. There is no guarantee for the context in which the listener will be called. More...
 
void Quiescent (void) const
 Identical to Wait, except blocks only until the threads in this and all descendant contexts have stopped More...
 
bool Quiescent (std::chrono::nanoseconds duration) const
 Timed version of Quiescent More...
 
void RemoveSnooper (const autowiring::CoreObjectDescriptor &traits)
 Runtime version of RemoveSnooper More...
 
template<class T >
void RemoveSnooper (const std::shared_ptr< T > &pSnooper)
 Unregisters a snooper previously registered to receive snooped events More...
 
template<class T >
void RemoveSnooper (const Autowired< T > &snooper)
 Resolution overload of RemoveSnooper More...
 
std::shared_ptr< CoreContextSetCurrent (void)
 Makes this context the current context. More...
 
void SetUnlinkOnTeardown (bool unlinkOnTeardown)
 Sets the context's teardown unlink behavior More...
 
void SignalShutdown (bool wait=false, ShutdownMode shutdownMode=ShutdownMode::Graceful)
 Begins shutdown of this context, optionally waiting for child contexts and threads to also shut down before returning. More...
 
void SignalTerminate (bool wait=true)
 Shuts down the context with the Immediate shutdown mode. More...
 
void Wait (void)
 Waits until the context begins shutting down (IsShutdown is true) and all threads and child threads have terminated. More...
 
bool Wait (const std::chrono::nanoseconds duration)
 Waits for the specified number of nanoseconds. More...
 
bool WasStarted (void) const
 Alias of the IsInitiated method More...
 
- Protected Member Functions inherited from CoreContext
template<class Fn >
void RegisterFactoryFn (Fn &&fn)
 Registers a factory function, a lambda which is capable of constructing decltype(fn()) More...
 

Detailed Description

A special class designed to make it easier to detect when our context is the global context.

Member Function Documentation

static std::shared_ptr<GlobalCoreContext> GlobalCoreContext::Get ( void  )
static

Obtains the global core context, or initializes it if necessary

static std::shared_ptr<GlobalCoreContext> GlobalCoreContext::Release ( void  )
static

Releases the global context, allowing reinitialization

Returns
A reference to the global context. The caller may test std::shared_ptr::unique to determine whether the pointer is the last outstanding reference to the global context.

In addition to releasing the global core context, all initializer operations are dumped. Note that releasing the context is not synonymous with destroying the global context–if there are shared_ptr references to the global context, those references will keep the global context resident. Here are some places which may maintain shared_ptr references to the global contexts:

  • Held references via SetCurrent
  • Child contexts of the global context

This method should only be used with great caution. Note that, if the calling thread holds a reference to the current global context via SetCurrent, it is the caller's responsibility to manually release that reference via EvictCurrent.


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