//Execute(Agent* pAgent)method hava be change to Execute(Agent* pAgent, EBTStatus childStatus) EBTStatus Action::Execute(const Agent* pAgent, EBTStatus childStatus) { EBTStatus result = BT_SUCCESS; if (this->m_method) { //#if BEHAVIAC_ENABLE_PROFILING // BEHAVIAC_PROFILE("Node"); //#endif uint32_t nodeId = this->GetId(); uint32_t slot = SetNodeId(nodeId); BEHAVIAC_ASSERT(slot != (uint32_t)-1, "no empty slot found!"); const Agent* pParent = this->m_method->GetParentAgent(pAgent); this->m_method->run(pParent, pAgent); if (this->m_resultOption != BT_INVALID) { result = this->m_resultOption; } else if (this->m_resultFunctor) { const Agent* pParentCheckResult = this->m_resultFunctor->GetParentAgent(pAgent); result = (EBTStatus)this->m_method->CheckReturn(pParent, pParentCheckResult, this->m_resultFunctor); } else { this->m_method->CheckReturn(pParent, result); } ClearNodeId(slot); } else { //#if BEHAVIAC_ENABLE_PROFILING // BEHAVIAC_PROFILE("ActionGenerated"); //#endif result = this->update_impl((Agent*)pAgent, childStatus); } return result; }
void Init( it_pz_handle_t aPZ_Hdl, int aNodeId, skv_pds_id_t* aPdsId ) { SetNodeId( aNodeId ); mPdsId = *aPdsId; mCachedKeysCount = 0; mCurrentCachedKeyIdx = 0; mCurrentCachedKey = & mCachedKeys[ 0 ]; it_mem_priv_t privs = (it_mem_priv_t) ( IT_PRIV_LOCAL | IT_PRIV_REMOTE ); it_lmr_flag_t lmr_flags = IT_LMR_FLAG_NON_SHAREABLE; int SizeOfKeyDataBuffer = sizeof( char ) * SKV_CACHED_KEYS_BUFFER_SIZE; it_status_t status = it_lmr_create( aPZ_Hdl, & mCachedKeys[ 0 ], NULL, SizeOfKeyDataBuffer, IT_ADDR_MODE_ABSOLUTE, privs, lmr_flags, 0, & mKeysDataLMRHdl, & mKeysDataRMRHdl ); BegLogLine( SKV_CLIENT_CURSOR_LOG ) << "skv_client_cursor_control_block_t::Init():: Leaving..." << " & mCachedKeys[ 0 ]: " << (void *) & mCachedKeys[ 0 ] << " mKeysDataLMRHdl: " << (void *) mKeysDataLMRHdl << "mKeysDataRMRHdl=" << (void *) mKeysDataRMRHdl << EndLogLine; StrongAssertLogLine( status == IT_SUCCESS ) << "skv_client_cursor_control_block_t::Init():: ERROR:: " << " status: " << status << EndLogLine; }
EBTStatus State::Execute(Agent* pAgent) { EBTStatus result = BT_RUNNING; if (this->m_method) { uint32_t nodeId = this->GetId(); uint32_t slot = SetNodeId(nodeId); BEHAVIAC_ASSERT(slot != (uint32_t)-1, "no empty slot found!"); const Agent* pParent = this->m_method->GetParentAgent(pAgent); this->m_method->run(pParent, pAgent); ClearNodeId(slot); } else { result = this->update_impl((Agent*)pAgent, BT_RUNNING); } return result; }
EBTStatus ActionTask::update(Agent* pAgent, EBTStatus childStatus) { BEHAVIAC_UNUSED_VAR(pAgent); BEHAVIAC_UNUSED_VAR(childStatus); BEHAVIAC_ASSERT(Action::DynamicCast(this->GetNode())); Action* pActionNode = (Action*)(this->GetNode()); if (!this->CheckPredicates(pAgent)) { return pActionNode->m_resultPreconditionFail; } EBTStatus result = BT_SUCCESS; if (pActionNode->m_method) { //#if BEHAVIAC_ENABLE_PROFILING // BEHAVIAC_PROFILE("Node"); //#endif ParentType pt = pActionNode->m_method->GetParentType(); Agent* pParent = pAgent; if (pt == PT_INSTANCE) { pParent = Agent::GetInstance(pActionNode->m_method->GetInstanceNameString(), pParent->GetContextId()); BEHAVIAC_ASSERT(pParent); } int nodeId = this->GetId(); int slot = SetNodeId(nodeId); BEHAVIAC_ASSERT(slot != -1, "no empty slot found!"); pActionNode->m_method->run(pParent, pAgent); if (pActionNode->m_resultOption != BT_INVALID) { result = pActionNode->m_resultOption; } else if (pActionNode->m_resultFunctor) { ParentType pt = pActionNode->m_resultFunctor->GetParentType(); Agent* pParentCheckResult = pAgent; if (pt == PT_INSTANCE) { pParentCheckResult = Agent::GetInstance(pActionNode->m_resultFunctor->GetInstanceNameString(), pParentCheckResult->GetContextId()); BEHAVIAC_ASSERT(pParentCheckResult); } result = (EBTStatus)pActionNode->m_method->CheckReturn(pParent, pParentCheckResult, pActionNode->m_resultFunctor); } else { pActionNode->m_method->CheckReturn(pParent, result); } ClearNodeId(slot); } else { //#if BEHAVIAC_ENABLE_PROFILING // BEHAVIAC_PROFILE("ActionGenerated"); //#endif result = pActionNode->update_impl(pAgent, childStatus); } return result; }