Evo C++ Library v0.5.1
Static Public Member Functions | List of all members
CortexModuleAsBase< T > Struct Template Reference

#include <evo/cortex.h>

Detailed Description

template<class T>
struct evo::CortexModuleAsBase< T >

Helper for getting a concrete module from a CortexModulePtr (or similar pointer).

Template Parameters
TConcrete type to use, must inherit CortexModuleBase

Static Public Member Functions

template<class U >
static T & get (U &ptr)
 Get module reference from stored pointer, create if needed. More...
 
template<class U >
static T * getptr (U &ptr)
 Get module pointer from stored pointer. More...
 

Member Function Documentation

◆ get()

static T& get ( U &  ptr)
inlinestatic

Get module reference from stored pointer, create if needed.

  • This uses dynamic_cast to cast the base type to the requested type
    • This has some runtime overhead, and throws std::bad_cast if the cast fails
    • To use static_cast instead define EVO_CORTEX_DYNAMIC_CAST 0 (before including this)
  • Caution: Results are undefined if the concrete type (ItemT) doesn't match the current object for key
Template Parameters
USmart pointer type – inferred from argument
Parameters
ptrSmart pointer type holding the object, if null then a new object is created and stored here
Returns
Reference to value from ptr

◆ getptr()

static T* getptr ( U &  ptr)
inlinestatic

Get module pointer from stored pointer.

  • This uses dynamic_cast to cast the base type to the requested type
    • This has some runtime overhead, and throws std::bad_cast if the cast fails
    • To use static_cast instead define EVO_CORTEX_DYNAMIC_CAST 0 (before including this)
  • Caution: Results are undefined if the concrete type (ItemT) doesn't match the current object for key
Template Parameters
USmart pointer type – inferred from argument
Parameters
ptrPointer type holding the object
Returns
Pointer to value from ptr, NULL if none

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