From d6038d840074ee696b6c267f82091c5a1d9dc1cc Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Oct 2019 11:35:37 +0800 Subject: [PATCH] 1 --- cpp/btmgr.cc | 31 ++++++++++++++++++++----------- cpp/btmgr.h | 4 +--- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/cpp/btmgr.cc b/cpp/btmgr.cc index 83da4cc..e3d8603 100644 --- a/cpp/btmgr.cc +++ b/cpp/btmgr.cc @@ -5,39 +5,48 @@ namespace f8 { - void BtMgr::Init() + void BtMgr::Init(const std::string& file_path) { + behaviac::Workspace::GetInstance()->SetFilePath(file_path.c_str()); behaviac::Workspace::GetInstance()->SetFileFormat(behaviac::Workspace::EFF_xml); } void BtMgr::UnInit() { - - } - - void BtMgr::SetFilePath(const std::string& file_path) - { - + behaviac::Workspace::GetInstance()->Cleanup(); } bool BtMgr::BtLoad(behaviac::Agent* agent, const char* relative_path, bool force) { - + if (!agent) { + abort(); + } + return agent->btload(relative_path, force); } void BtMgr::BtSetCurrent(behaviac::Agent* agent, const char* relative_path) { - + if (!agent) { + abort(); + } + agent->btsetcurrent(relative_path); } void BtMgr::BtExec(behaviac::Agent* agent) { - + if (!agent) { + abort(); + } + agent->btexec(); } void BtMgr::BtDestory(behaviac::Agent* agent) { - + if (!agent) { + abort(); + } + behaviac::Agent::Destroy(agent); } } + diff --git a/cpp/btmgr.h b/cpp/btmgr.h index 68c3e86..410ce88 100644 --- a/cpp/btmgr.h +++ b/cpp/btmgr.h @@ -14,11 +14,9 @@ namespace f8 friend class a8::Singleton; public: - void Init(); + void Init(const std::string& file_path); void UnInit(); - void SetFilePath(const std::string& file_path); - bool BtLoad(behaviac::Agent* agent, const char* relative_path, bool force = false); void BtSetCurrent(behaviac::Agent* agent, const char* relative_path); void BtExec(behaviac::Agent* agent);