18 typedef std::shared_ptr<TreeNode> TreeNodePtr;
27 typedef std::map<std::string, TreeNodePtr> TreeMap;
31 inline void resetError() {
39 _aiFactory(aiFactory) {
53 inline const IAIFactory& getAIFactory()
const {
60 void getTrees(std::vector<std::string>& trees)
const {
62 trees.reserve(_treeMap.size());
63 for (TreeMap::const_iterator it = _treeMap.begin(); it != _treeMap.end(); ++it) {
64 trees.push_back(it->first);
77 bool addTree(
const std::string& name,
const TreeNodePtr& root) {
83 TreeMap::const_iterator i = _treeMap.find(name);
84 if (i != _treeMap.end()) {
90 _treeMap.insert(std::make_pair(name, root));
98 TreeNodePtr
load(
const std::string &name) {
100 TreeMap::const_iterator i = _treeMap.find(name);
101 if (i != _treeMap.end())
103 return TreeNodePtr();
106 void setError(
const char* msg, ...) __attribute__((format(printf, 2, 3)));
116 inline void ITreeLoader::setError(
const char* msg, ...) {
120 std::vsnprintf(buf,
sizeof(buf), msg, args);
122 if (buf[0] !=
'\0') {
125 ScopedWriteLock scopedLock(_lock);
void std::string getError() const
Gives access to the last error state of the ITreeLoader.
Definition: ITreeLoader.h:111
bool addTree(const std::string &name, const TreeNodePtr &root)
Register a new TreeNode as behaviour tree with the specified name.
Definition: ITreeLoader.h:77
#define ai_log_debug(...)
Logging macro to provide your own loggers.
Definition: Types.h:37
Definition: IAIFactory.h:39
This class must be extended to load behaviour trees. The contract here is that the parsing only happe...
Definition: ITreeLoader.h:24
void getTrees(std::vector< std::string > &trees) const
Fill the given vector with the loaded behaviour tree names.
Definition: ITreeLoader.h:60
TreeNodePtr load(const std::string &name)
Loads on particular behaviour tree.
Definition: ITreeLoader.h:98