TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
QueryCallback< Result, ParamType, chain > Class Template Reference

#include <Callback.h>

Public Member Functions

 QueryCallback ()
 
void SetFutureResult (std::future< Result > value)
 The parameter of this function should be a resultset returned from either .AsyncQuery or .AsyncPQuery. More...
 
std::future< Result > & GetFutureResult ()
 
bool IsReady ()
 
void GetResult (Result &res)
 
void FreeResult ()
 
void SetParam (ParamType value)
 
ParamType GetParam ()
 
void ResetStage ()
 Resets the stage of the callback chain. More...
 
void NextStage ()
 Advances the callback chain to the next stage, so upper level code can act on its results accordingly. More...
 
uint8 GetStage ()
 Returns the callback stage (or CALLBACK_STAGE_INVALID if invalid) More...
 
void Reset ()
 Resets all underlying variables (param, result and stage) More...
 

Private Member Functions

 QueryCallback (QueryCallback const &right)=delete
 
QueryCallbackoperator= (QueryCallback const &right)=delete
 

Private Attributes

std::future< Result > _result
 
ParamType _param
 
uint8 _stage
 

Constructor & Destructor Documentation

template<typename Result, typename ParamType, bool chain = false>
QueryCallback< Result, ParamType, chain >::QueryCallback ( )
inline
35 : _param(), _stage(chain ? 0 : CALLBACK_STAGE_INVALID) { }
uint8 _stage
Definition: Callback.h:108
ParamType _param
Definition: Callback.h:107
#define CALLBACK_STAGE_INVALID
Definition: Callback.h:29
template<typename Result, typename ParamType, bool chain = false>
QueryCallback< Result, ParamType, chain >::QueryCallback ( QueryCallback< Result, ParamType, chain > const right)
privatedelete

Member Function Documentation

template<typename Result, typename ParamType, bool chain = false>
void QueryCallback< Result, ParamType, chain >::FreeResult ( )
inline
59  {
60  // Nothing to do here, the constructor of std::future will take care of the cleanup
61  }

+ Here is the caller graph for this function:

template<typename Result, typename ParamType, bool chain = false>
std::future<Result>& QueryCallback< Result, ParamType, chain >::GetFutureResult ( )
inline
44  {
45  return _result;
46  }
std::future< Result > _result
Definition: Callback.h:106
template<typename Result, typename ParamType, bool chain = false>
ParamType QueryCallback< Result, ParamType, chain >::GetParam ( )
inline
69  {
70  return _param;
71  }
ParamType _param
Definition: Callback.h:107

+ Here is the caller graph for this function:

template<typename Result, typename ParamType, bool chain = false>
void QueryCallback< Result, ParamType, chain >::GetResult ( Result &  res)
inline
54  {
55  res = _result.get();
56  }
std::future< Result > _result
Definition: Callback.h:106

+ Here is the caller graph for this function:

template<typename Result, typename ParamType, bool chain = false>
uint8 QueryCallback< Result, ParamType, chain >::GetStage ( )
inline

Returns the callback stage (or CALLBACK_STAGE_INVALID if invalid)

93  {
94  return _stage;
95  }
uint8 _stage
Definition: Callback.h:108

+ Here is the caller graph for this function:

template<typename Result, typename ParamType, bool chain = false>
bool QueryCallback< Result, ParamType, chain >::IsReady ( )
inline
49  {
50  return _result.valid() && _result.wait_for(std::chrono::seconds(0)) == std::future_status::ready;
51  }
float seconds()
Definition: units.h:97
std::future< Result > _result
Definition: Callback.h:106

+ Here is the caller graph for this function:

template<typename Result, typename ParamType, bool chain = false>
void QueryCallback< Result, ParamType, chain >::NextStage ( )
inline

Advances the callback chain to the next stage, so upper level code can act on its results accordingly.

84  {
85  if (!chain)
86  return;
87 
88  ++_stage;
89  }
uint8 _stage
Definition: Callback.h:108

+ Here is the caller graph for this function:

template<typename Result, typename ParamType, bool chain = false>
QueryCallback& QueryCallback< Result, ParamType, chain >::operator= ( QueryCallback< Result, ParamType, chain > const right)
privatedelete
template<typename Result, typename ParamType, bool chain = false>
void QueryCallback< Result, ParamType, chain >::Reset ( )
inline

Resets all underlying variables (param, result and stage)

99  {
100  SetParam(ParamType());
101  FreeResult();
102  ResetStage();
103  }
void SetParam(ParamType value)
Definition: Callback.h:63
void ResetStage()
Resets the stage of the callback chain.
Definition: Callback.h:74
void FreeResult()
Definition: Callback.h:58

+ Here is the caller graph for this function:

template<typename Result, typename ParamType, bool chain = false>
void QueryCallback< Result, ParamType, chain >::ResetStage ( )
inline

Resets the stage of the callback chain.

75  {
76  if (!chain)
77  return;
78 
79  _stage = 0;
80  }
uint8 _stage
Definition: Callback.h:108

+ Here is the caller graph for this function:

template<typename Result, typename ParamType, bool chain = false>
void QueryCallback< Result, ParamType, chain >::SetFutureResult ( std::future< Result >  value)
inline

The parameter of this function should be a resultset returned from either .AsyncQuery or .AsyncPQuery.

39  {
40  _result = std::move(value);
41  }
const FieldDescriptor value
Definition: descriptor.h:1522
std::future< Result > _result
Definition: Callback.h:106

+ Here is the caller graph for this function:

template<typename Result, typename ParamType, bool chain = false>
void QueryCallback< Result, ParamType, chain >::SetParam ( ParamType  value)
inline
64  {
65  _param = value;
66  }
ParamType _param
Definition: Callback.h:107
const FieldDescriptor value
Definition: descriptor.h:1522

+ Here is the caller graph for this function:

Member Data Documentation

template<typename Result, typename ParamType, bool chain = false>
ParamType QueryCallback< Result, ParamType, chain >::_param
private
template<typename Result, typename ParamType, bool chain = false>
std::future<Result> QueryCallback< Result, ParamType, chain >::_result
private
template<typename Result, typename ParamType, bool chain = false>
uint8 QueryCallback< Result, ParamType, chain >::_stage
private

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