The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::TreeNode::delegate Class Reference

Temporary delegate for notificaiton invokation until the implementation is working. This will then be merged with sparta::SpartaHandler. More...

#include <TreeNode.hpp>

Public Types

typedef void(* stub_type) (void *obj, const TreeNode &origin, const TreeNode *obs_pt, const void *data)
 

Public Member Functions

 delegate (const delegate &&d)
 
delegateoperator= (const delegate &d)
 
 delegate (const delegate &d)
 
template<class DataT , class T , void(T::*)(const TreeNode &, const TreeNode &, const DataT &) TMethod>
constexpr bool equals (T *obj, const TreeNode &obs_pt, const std::string &name) const
 Compares against another delegate's information based on DataT, T, TMethod, observer pointer, and the observation point in the tree.
 
template<class DataT , class T , void(T::*)(const DataT &) TMethod>
constexpr bool equals (T *obj, const TreeNode &obs_pt, const std::string &name) const
 
bool operator== (const delegate &d) const
 Compares all fields in this delegate against another delegate.
 
bool observes (const TreeNode &obs_pt, const std::string *name) const
 Compares against another delegate based on the observation point and name ignoring delegate callback signature (assumes it alreay matches).
 
template<typename DataT >
void operator() (const TreeNode &origin, const DataT &data) const
 Invokes the delegate.
 
const std::string * getNameID () const
 
const TreeNodegetObservationPoint () const
 
bool revealsOrigin () const
 

Static Public Member Functions

template<class DataT , class T , void(T::*)(const TreeNode &, const TreeNode &, const DataT &) TMethod>
static delegate from_method (T *obj, const TreeNode &obs_pt, const std::string &name)
 Creates delegate with given properties.
 
template<class DataT , class T , void(T::*)(const DataT &) TMethod>
static delegate from_method (T *obj, const TreeNode &obs_pt, const std::string &name)
 

Detailed Description

Temporary delegate for notificaiton invokation until the implementation is working. This will then be merged with sparta::SpartaHandler.

Note
This class must be mostly inlined (constructors, queries, comparisons, and calls) for performance

Definition at line 2761 of file TreeNode.hpp.

Member Typedef Documentation

◆ stub_type

typedef void(* sparta::TreeNode::delegate::stub_type) (void *obj, const TreeNode &origin, const TreeNode *obs_pt, const void *data)

Definition at line 2765 of file TreeNode.hpp.

Constructor & Destructor Documentation

◆ delegate() [1/3]

sparta::TreeNode::delegate::delegate ( )
inline

Definition at line 2770 of file TreeNode.hpp.

◆ delegate() [2/3]

sparta::TreeNode::delegate::delegate ( const delegate &&  d)
inline

Definition at line 2778 of file TreeNode.hpp.

◆ delegate() [3/3]

sparta::TreeNode::delegate::delegate ( const delegate d)
inline

Definition at line 2799 of file TreeNode.hpp.

Member Function Documentation

◆ equals() [1/2]

template<class DataT , class T , void(T::*)(const TreeNode &, const TreeNode &, const DataT &) TMethod>
constexpr bool sparta::TreeNode::delegate::equals ( T *  obj,
const TreeNode obs_pt,
const std::string &  name 
) const
inlineconstexpr

Compares against another delegate's information based on DataT, T, TMethod, observer pointer, and the observation point in the tree.

Note
It is critical to compare observer point to ensure that observers of a particular event type can be registered on multiple nodes.

Definition at line 2819 of file TreeNode.hpp.

◆ equals() [2/2]

template<class DataT , class T , void(T::*)(const DataT &) TMethod>
constexpr bool sparta::TreeNode::delegate::equals ( T *  obj,
const TreeNode obs_pt,
const std::string &  name 
) const
inlineconstexpr

Definition at line 2830 of file TreeNode.hpp.

◆ from_method() [1/2]

template<class DataT , class T , void(T::*)(const TreeNode &, const TreeNode &, const DataT &) TMethod>
static delegate sparta::TreeNode::delegate::from_method ( T *  obj,
const TreeNode obs_pt,
const std::string &  name 
)
inlinestatic

Creates delegate with given properties.

Parameters
nameName of notifications to observe. Passing empty string observes all notifications with payload type DataT

Definition at line 2888 of file TreeNode.hpp.

Here is the call graph for this function:

◆ from_method() [2/2]

template<class DataT , class T , void(T::*)(const DataT &) TMethod>
static delegate sparta::TreeNode::delegate::from_method ( T *  obj,
const TreeNode obs_pt,
const std::string &  name 
)
inlinestatic

Definition at line 2901 of file TreeNode.hpp.

◆ getNameID()

const std::string * sparta::TreeNode::delegate::getNameID ( ) const
inline

Definition at line 2924 of file TreeNode.hpp.

◆ getObservationPoint()

const TreeNode * sparta::TreeNode::delegate::getObservationPoint ( ) const
inline

Definition at line 2928 of file TreeNode.hpp.

◆ observes()

bool sparta::TreeNode::delegate::observes ( const TreeNode obs_pt,
const std::string *  name 
) const
inline

Compares against another delegate based on the observation point and name ignoring delegate callback signature (assumes it alreay matches).

Parameters
obs_ptObservation point to compare against this delegate. Just checks to see if they match.
nameString name of notification in question. This string must be interned in StringManager. This delegate's name will be compared to the name argument by address unless the delegate has a name pointer of StringManager::EMPTY (implying it observes all notification names of a given data type)
Returns
true if both:
  • This delegate has the same observation point as obs_pt
  • This delegate has either a name matching the name argument or the delegate name StringManager::EMPTY (empty string) (this implies that the delegate observes all notification names for the given data type)

Definition at line 2873 of file TreeNode.hpp.

Here is the call graph for this function:

◆ operator()()

template<typename DataT >
void sparta::TreeNode::delegate::operator() ( const TreeNode origin,
const DataT &  data 
) const
inline

Invokes the delegate.

Definition at line 2918 of file TreeNode.hpp.

◆ operator=()

delegate & sparta::TreeNode::delegate::operator= ( const delegate d)
inline
Note
This is required for placing delegates in a vector (for fast iteration during broadcast) despite also having a move constructor.

Definition at line 2789 of file TreeNode.hpp.

◆ operator==()

bool sparta::TreeNode::delegate::operator== ( const delegate d) const
inline

Compares all fields in this delegate against another delegate.

Returns
true if all fields are equal (e.g. same stub pointer, same observation point, observer object, and observation name)
See also
equals

Definition at line 2848 of file TreeNode.hpp.

◆ revealsOrigin()

bool sparta::TreeNode::delegate::revealsOrigin ( ) const
inline

Definition at line 2932 of file TreeNode.hpp.


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