BehaviorTree
Core Library to create and execute Behavior Trees
Loading...
Searching...
No Matches
BT::Blackboard Class Reference

The Blackboard is the mechanism used by BehaviorTrees to exchange typed data. More...

#include <blackboard.h>

Classes

struct  Entry
 

Public Types

using Ptr = std::shared_ptr< Blackboard >
 

Public Member Functions

 Blackboard (const Blackboard &)=delete
 
Blackboardoperator= (const Blackboard &)=delete
 
 Blackboard (Blackboard &&)=delete
 
Blackboardoperator= (Blackboard &&)=delete
 
void enableAutoRemapping (bool remapping)
 
const std::shared_ptr< EntrygetEntry (const std::string &key) const
 
std::shared_ptr< Blackboard::EntrygetEntry (const std::string &key)
 
AnyPtrLocked getAnyLocked (const std::string &key)
 
AnyPtrLocked getAnyLocked (const std::string &key) const
 
const AnygetAny (const std::string &key) const
 
AnygetAny (const std::string &key)
 
template<typename T >
bool get (const std::string &key, T &value) const
 
template<typename T >
Expected< TimestampgetStamped (const std::string &key, T &value) const
 
template<typename T >
get (const std::string &key) const
 
template<typename T >
Expected< StampedValue< T > > getStamped (const std::string &key) const
 
template<typename T >
void set (const std::string &key, const T &value)
 Update the entry with the given key.
 
void unset (const std::string &key)
 
const TypeInfoentryInfo (const std::string &key)
 
void addSubtreeRemapping (StringView internal, StringView external)
 
void debugMessage () const
 
std::vector< StringView > getKeys () const
 
void clear ()
 
void createEntry (const std::string &key, const TypeInfo &info)
 
void cloneInto (Blackboard &dst) const
 cloneInto copies the values of the entries into another blackboard. Known limitations:
 
Blackboard::Ptr parent ()
 
BlackboardrootBlackboard ()
 
const BlackboardrootBlackboard () const
 
void setPolymorphicCastRegistry (std::shared_ptr< PolymorphicCastRegistry > registry)
 Set the polymorphic cast registry for this blackboard.
 
const PolymorphicCastRegistrypolymorphicCastRegistry () const
 Get the polymorphic cast registry (may be null).
 
template<typename T >
Expected< T > tryCastWithPolymorphicFallback (const Any *any) const
 Cast Any value with polymorphic fallback for shared_ptr types.
 

Static Public Member Functions

static Blackboard::Ptr create (Blackboard::Ptr parent={})
 

Protected Member Functions

 Blackboard (Blackboard::Ptr parent)
 

Detailed Description

The Blackboard is the mechanism used by BehaviorTrees to exchange typed data.

Member Function Documentation

◆ cloneInto()

void BT::Blackboard::cloneInto ( Blackboard dst) const

cloneInto copies the values of the entries into another blackboard. Known limitations:

  • it doesn't update the remapping in dst
  • it doesn't change the parent blackboard os dst
Parameters
dstdestination, i.e. blackboard to be updated

◆ create()

static Blackboard::Ptr BT::Blackboard::create ( Blackboard::Ptr  parent = {})
inlinestatic

Use this static method to create an instance of the BlackBoard to share among all your NodeTrees.

◆ get() [1/2]

template<typename T >
T BT::Blackboard::get ( const std::string &  key) const
inline

Version of get() that throws if it fails.

◆ get() [2/2]

template<typename T >
bool BT::Blackboard::get ( const std::string &  key,
T &  value 
) const
inline

Return true if the entry with the given key was found. Note that this method may throw an exception if the cast to T failed.

◆ setPolymorphicCastRegistry()

void BT::Blackboard::setPolymorphicCastRegistry ( std::shared_ptr< PolymorphicCastRegistry registry)
inline

Set the polymorphic cast registry for this blackboard.

The registry enables polymorphic shared_ptr conversions during get(). This is typically set automatically when creating trees via BehaviorTreeFactory.

◆ tryCastWithPolymorphicFallback()

template<typename T >
Expected< T > BT::Blackboard::tryCastWithPolymorphicFallback ( const Any any) const
inline

Cast Any value with polymorphic fallback for shared_ptr types.

First attempts a direct cast. If that fails and T is a shared_ptr type, tries a polymorphic cast via the registry. Returns Expected with error on failure.


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