DecoratorWeight::~DecoratorWeight() { BEHAVIAC_DELETE(m_weight_var); }
DecoratorIterator::~DecoratorIterator() { BEHAVIAC_DELETE(m_opr_m); }
Event::~Event() { BEHAVIAC_DELETE(m_event); }
WaitFrames::~WaitFrames() { BEHAVIAC_DELETE(this->m_frames_method); }
bool Workspace::Load(const char* relativePath, bool bForce) { bool bOk = this->TryInit(); if (!bOk) { //not init correctly return false; } //BEHAVIAC_ASSERT(behaviac::StringUtils::FindExtension(relativePath) == 0, "no extention to specify"); BEHAVIAC_ASSERT(IsValidPath(relativePath)); BehaviorTree* pBT = 0; BehaviorTrees_t::iterator it = m_behaviortrees.find(relativePath); if (it != m_behaviortrees.end()) { if (!bForce) { return true; } pBT = it->second; } behaviac::string fullPath = StringUtils::CombineDir(this->GetFilePath(), relativePath); Workspace::EFileFormat f = this->GetFileFormat(); switch (f) { case EFF_default: { // try to load the behavior in xml behaviac::string path = fullPath + ".xml"; if (behaviac::CFileManager::GetInstance()->FileExists(path.c_str())) { f = EFF_xml; fullPath = path; } else { // try to load the behavior in bson path = fullPath + ".bson.bytes"; if (behaviac::CFileManager::GetInstance()->FileExists(path.c_str())) { f = EFF_bson; fullPath = path; } // try to load the behavior in cpp else { f = EFF_cpp; } } } break; case EFF_xml: fullPath += ".xml"; break; case EFF_bson: fullPath += ".bson.bytes"; break; case EFF_cpp: break; default: BEHAVIAC_ASSERT(0); break; } bool bLoadResult = false; bool bNewly = false; if (!pBT) { //in case of circular referencebehavior bNewly = true; pBT = BEHAVIAC_NEW BehaviorTree(); m_behaviortrees[relativePath] = pBT; } BEHAVIAC_ASSERT(pBT); bool bCleared = false; if (f == EFF_xml || f == EFF_bson) { uint32_t bufferSize = 0; char* pBuffer = this->ReadFileToBuffer(fullPath.c_str(), bufferSize); if (pBuffer) { //if forced to reload if (!bNewly) { bCleared = true; pBT->Clear(); } if (f == EFF_xml) { bLoadResult = pBT->load_xml(pBuffer); } else { bLoadResult = pBT->load_bson(pBuffer); } this->PopFileFromBuffer(pBuffer, bufferSize); } else { BEHAVIAC_LOGERROR("'%s' doesn't exist!, Please check the file name or override Workspace and its GetFilePath()\n", fullPath.c_str()); BEHAVIAC_ASSERT(false); } } else if (f == EFF_cpp) { if (!bNewly) { bCleared = true; pBT->Clear(); } if (m_behaviortreeCreators && m_behaviortreeCreators->find(relativePath) != m_behaviortreeCreators->end()) { BehaviorTreeCreator_t btCreator = (*m_behaviortreeCreators)[relativePath]; bLoadResult = (*btCreator)(pBT); } else { BEHAVIAC_ASSERT(0); BEHAVIAC_LOGWARNING("The behaviac_generated/behaviors/generated_behaviors.h should be included by one of your apps."); } } else { BEHAVIAC_ASSERT(0); } if (bLoadResult) { BEHAVIAC_ASSERT(pBT->GetName() == relativePath); if (!bNewly) { BEHAVIAC_ASSERT(m_behaviortrees[pBT->GetName()] == pBT); } } else { if (bNewly) { //if it is forced to reload m_behaviortrees.erase(relativePath); BEHAVIAC_DELETE(pBT); } else if (bCleared) { //it has been cleared but failed to load, to remove it m_behaviortrees.erase(relativePath); } BEHAVIAC_LOGWARNING("'%s' is not loaded!\n", fullPath.c_str()); } return bLoadResult; }
Action::~Action() { BEHAVIAC_DELETE(m_method); BEHAVIAC_DELETE(m_resultFunctor); }
void ConnectorInterface::Close() { AtomicInc(m_terminating); AtomicDec(m_isConnectedFinished); AtomicInc(m_isDisconnected); if (s_tracerThread) { if (!thread::IsThreadTerminated(s_tracerThread)) { while (IsConnected() && !thread::IsThreadTerminated(s_tracerThread)) { behaviac::Thread::Sleep(1); } } { ScopedLock lock(m_packetBuffersLock); for (int i = 0; i < this->m_maxTracedThreads; ++i) { BEHAVIAC_DELETE(m_packetBuffers[i]); } BEHAVIAC_G_DELETE_ARRAY(m_packetBuffers); m_packetBuffers = 0; } if (!thread::IsThreadTerminated(s_tracerThread)) { thread::StopThread(s_tracerThread); } s_tracerThread = 0; } if (m_packetCollection) { m_packetCollection->Close(); BEHAVIAC_DELETE(m_packetCollection); m_packetCollection = 0; } BEHAVIAC_DELETE(m_packetPool); m_packetPool = 0; #if BEHAVIAC_COMPILER_MSVC if (t_packetBufferIndex != TLS_OUT_OF_INDEXES) { TlsFree(t_packetBufferIndex); t_packetBufferIndex = TLS_OUT_OF_INDEXES; } #else t_packetBufferIndex = 0; #endif behaviac::Socket::ShutdownSockets(); AtomicDec(m_isInited); }
WaitFramesState::~WaitFramesState() { BEHAVIAC_DELETE(this->m_frames_method); }
Compute::~Compute() { BEHAVIAC_DELETE(m_opl); BEHAVIAC_DELETE(m_opr1); BEHAVIAC_DELETE(m_opr2); }
Assignment::~Assignment() { BEHAVIAC_DELETE(m_opl); BEHAVIAC_DELETE(m_opr); BEHAVIAC_DELETE(m_opr_m); }
CompositeStochastic::~CompositeStochastic() { BEHAVIAC_DELETE(m_method); }