Grail (C++)  1.4.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< BlackboardEntry(const std::string &, const BlackboardEntry &, const BlackboardEntry &)> 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 >
const 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 SerializeToMap (std::map< std::string, std::string > &outMap) const
 SerializeToMap - converts the data stored in the blackboard to a map<key, value as string> More...
 

Static Public Member Functions

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

BlackboardEntry grail::Blackboard::OursStrategy ( const std::string &  ,
const BlackboardEntry ours,
const BlackboardEntry 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

◆ SerializeToMap()

void grail::Blackboard::SerializeToMap ( std::map< std::string, std::string > &  outMap) const

SerializeToMap - converts the data stored in the blackboard to a map<key, value as string>

Parameters
outMap- map that will be populated by serialized key-values from the blackboard.

◆ 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()

BlackboardEntry grail::Blackboard::TheirsStrategy ( const std::string &  ,
const BlackboardEntry ours,
const BlackboardEntry 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< BlackboardEntry(const std::string &, const BlackboardEntry &, const BlackboardEntry &)>  firstStrategy = OursStrategy,
std::function< BlackboardEntry(const std::string &, const BlackboardEntry &, const BlackboardEntry &)>  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: