(C++)  1.1.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
grail::Blackboard Class Reference

The Blackboard class - grail's universal data container. More...

#include <Blackboard.hh>

Public Member Functions

 Blackboard (const Blackboard &other)
 
 Blackboard (Blackboard &&other)=delete
 
Blackboardoperator= (const Blackboard &other)
 
Blackboardoperator= (Blackboard &&other)=delete
 
void Merge (const Blackboard &other, std::function< const std::any &(const std::any &, const std::any &)> mergeStrategy=OursStrategy)
 Merge - Merges data from other blackboard into this one. All conflicts are solved in favor of other blackboard. More...
 
void RemoveEntry (const std::string &key)
 RemoveValue - Deletes value keyed with given name from this blackboard. More...
 
bool ContainsKey (const std::string &key) const
 ContainsKey - Checks whether this blackboard contains given key. More...
 
size_t Size () const
 Size. More...
 
template<typename T >
void SetValue (const std::string &key, const T &value)
 SetValue - Inserts value keyed with name into this blackboard. If key already exists new value is assigned. More...
 
template<typename T , std::enable_if_t<!std::is_reference< T >::value > * = nullptr>
void SetValue (const std::string &key, T &&value)
 SetValue - Inserts value keyed with name into this blackboard. If key already exists new value is assigned. More...
 
template<typename T >
void SetDefaultValue (const std::string &key)
 SetDefaultValue - Inserts default value of given type keyed with name into this blackboard. If key already exists new value is assigned. More...
 
template<typename T >
const T & GetValue (const std::string &key) const
 GetValue - Returns value keyed with name. This method assumes that this blackboard contains given key! More...
 
template<typename T >
T & GetOrAddValue (const std::string &key)
 GetOrAddValue - Returns value keyed with name. If blackboard does not contain key, new entry is created. More...
 
template<typename T >
bool TryGetValue (const std::string &key, T &outValue) const
 TryGetValue - Checks whether blackboard contains given key. If it does, assigns keyed value to reference parameter outValue. More...
 
void AddDataToNameMap (std::map< std::string, std::string > &outMap) const
 

Static Public Member Functions

static void TwoWayMerge (Blackboard &first, Blackboard &second, std::function< const std::any &(const std::any &, const std::any &)> firstStrategy=OursStrategy, std::function< const std::any &(const std::any &, const std::any &)> secondStrategy=OursStrategy)
 TwoWayMerge - merges second blackboard into first and first into second, uses provided merge strategies. More...
 
static const std::any & OursStrategy (const std::any &ours, const std::any &theirs)
 OursStrategy. More...
 
static const std::any & TheirsStrategy (const std::any &ours, const std::any &theirs)
 TheirsStrategy. More...
 

Detailed Description

The Blackboard class - grail's universal data container.

Member Function Documentation

◆ ContainsKey()

bool grail::Blackboard::ContainsKey ( const std::string &  key) const

ContainsKey - Checks whether this blackboard contains given key.

Parameters
key
Returns
true if key exists, false if not

◆ GetOrAddValue()

template<typename T >
T& grail::Blackboard::GetOrAddValue ( const std::string &  key)
inline

GetOrAddValue - Returns value keyed with name. If blackboard does not contain key, new entry is created.

Parameters
name
Returns
value paired with given key

◆ GetValue()

template<typename T >
const T& grail::Blackboard::GetValue ( const std::string &  key) const
inline

GetValue - Returns value keyed with name. This method assumes that this blackboard contains given key!

Parameters
name
Returns
value paired with given key

◆ Merge()

void grail::Blackboard::Merge ( const Blackboard other,
std::function< const std::any &(const std::any &, const std::any &)>  mergeStrategy = OursStrategy 
)

Merge - Merges data from other blackboard into this one. All conflicts are solved in favor of other blackboard.

Parameters
other
mergeStrategy- determines how conflicts will be resolved

◆ OursStrategy()

const std::any & grail::Blackboard::OursStrategy ( const std::any &  ours,
const std::any &  theirs 
)
static

OursStrategy.

Parameters
ours
theirs
Returns
ours

◆ RemoveEntry()

void grail::Blackboard::RemoveEntry ( const std::string &  key)

RemoveValue - Deletes value keyed with given name from this blackboard.

Parameters
name

◆ SetDefaultValue()

template<typename T >
void grail::Blackboard::SetDefaultValue ( const std::string &  key)
inline

SetDefaultValue - Inserts default value of given type keyed with name into this blackboard. If key already exists new value is assigned.

Parameters
name

◆ SetValue() [1/2]

template<typename T >
void grail::Blackboard::SetValue ( const std::string &  key,
const T &  value 
)
inline

SetValue - Inserts value keyed with name into this blackboard. If key already exists new value is assigned.

Parameters
name
value

◆ SetValue() [2/2]

template<typename T , std::enable_if_t<!std::is_reference< T >::value > * = nullptr>
void grail::Blackboard::SetValue ( const std::string &  key,
T &&  value 
)
inline

SetValue - Inserts value keyed with name into this blackboard. If key already exists new value is assigned.

Parameters
name
value

◆ Size()

size_t grail::Blackboard::Size ( ) const

Size.

Returns
blackboard's data size

◆ TheirsStrategy()

const std::any & grail::Blackboard::TheirsStrategy ( const std::any &  ours,
const std::any &  theirs 
)
static

TheirsStrategy.

Parameters
ours
theirs
Returns
theirs

◆ TryGetValue()

template<typename T >
bool grail::Blackboard::TryGetValue ( const std::string &  key,
T &  outValue 
) const
inline

TryGetValue - Checks whether blackboard contains given key. If it does, assigns keyed value to reference parameter outValue.

Parameters
name
outValue
Returns
true if key exists, false if it does not

◆ TwoWayMerge()

void grail::Blackboard::TwoWayMerge ( Blackboard first,
Blackboard second,
std::function< const std::any &(const std::any &, const std::any &)>  firstStrategy = OursStrategy,
std::function< const std::any &(const std::any &, const std::any &)>  secondStrategy = OursStrategy 
)
static

TwoWayMerge - merges second blackboard into first and first into second, uses provided merge strategies.

Parameters
first
second
firstStrategy
secondStrategy

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