![]() |
Grail (C++)
1.3.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
|
The Blackboard class - grail's universal data container. More...
#include <Blackboard.hh>
Public Member Functions | |
Blackboard (const Blackboard &other) | |
Blackboard (Blackboard &&other)=delete | |
Blackboard & | operator= (const Blackboard &other) |
Blackboard & | operator= (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... | |
The Blackboard class - grail's universal data container.
bool grail::Blackboard::ContainsKey | ( | const std::string & | key | ) | const |
ContainsKey - Checks whether this blackboard contains given key.
key |
|
inline |
GetOrAddValue - Returns value keyed with name. If blackboard does not contain key, new entry is created.
name |
|
inline |
GetValue - Returns value keyed with name. This method assumes that this blackboard contains given key!
name |
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.
other | |
mergeStrategy | - determines how conflicts will be resolved |
|
static |
OursStrategy.
ours | |
theirs |
void grail::Blackboard::RemoveEntry | ( | const std::string & | key | ) |
RemoveValue - Deletes value keyed with given name from this blackboard.
name |
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>
outMap | - map that will be populated by serialized key-values from the blackboard. |
|
inline |
SetDefaultValue - Inserts default value of given type keyed with name into this blackboard. If key already exists new value is assigned.
name |
|
inline |
SetValue - Inserts value keyed with name into this blackboard. If key already exists new value is assigned.
name | |
value |
|
inline |
SetValue - Inserts value keyed with name into this blackboard. If key already exists new value is assigned.
name | |
value |
size_t grail::Blackboard::Size | ( | ) | const |
Size.
|
static |
TheirsStrategy.
ours | |
theirs |
|
inline |
TryGetValue - Checks whether blackboard contains given key. If it does, assigns keyed value to reference parameter outValue.
name | |
outValue |
|
static |
TwoWayMerge - merges second blackboard into first and first into second, uses provided merge strategies.
first | |
second | |
firstStrategy | |
secondStrategy |