void BehaviorTask::load(ISerializableNode* node) { CSerializationID attrId("status"); behaviac::string attrStr; if (node->getAttr(attrId, attrStr)) { behaviac::StringUtils::FromString(attrStr.c_str(), this->m_status); } #if !BEHAVIAC_RELEASE if (this->m_status != BT_INVALID) { CSerializationID classId("class"); node->getAttr(classId, attrStr); BEHAVIAC_ASSERT(attrStr == this->GetClassNameString()); CSerializationID idId("id"); node->getAttr(idId, attrStr); int id = -1; StringUtils::FromString(attrStr.c_str(), id); BEHAVIAC_ASSERT(id == this->GetId()); } #endif }
XmlNodeRef State_t::SaveToXmlNode(Agent* pAgent) const { XmlNodeRef xmlInfo = CreateXmlNode("AgentState"); CTextNode node(xmlInfo); CSerializationID attrId("agentType"); node.setAttr(attrId, this->m_agentType); if (pAgent) { CSerializationID membersId("members"); ISerializableNode* membersNode = node.newChild(membersId); pAgent->Save(membersNode); } this->m_vars.Save(&node); if (this->m_bt) { this->m_bt->Save(&node); } return xmlInfo; }
void CompositeTask::load(ISerializableNode* node) { super::load(node); if (this->m_status != BT_INVALID) { CSerializationID attrId("activeChildIndex"); behaviac::string attrStr; node->getAttr(attrId, attrStr); StringUtils::FromString(attrStr.c_str(), this->m_activeChildIndex); //#if !BEHAVIAC_RELEASE // if (this->m_activeChildIndex != uint32_t(-1)) // { // BEHAVIAC_ASSERT(this->m_currentTask == this->m_children[this->m_activeChildIndex]); // } // else // { // BEHAVIAC_ASSERT(this->m_currentTask == 0); // } //#endif BehaviorTasks_t::size_type count = this->m_children.size(); BEHAVIAC_ASSERT(count == (BehaviorTasks_t::size_type)node->getChildCount()); for (BehaviorTasks_t::size_type i = 0; i < count; ++i) { BehaviorTask* childTask = this->m_children[i]; //CSerializationID nodeId("node"); ISerializableNode* chidlNode = node->getChild(i); childTask->load(chidlNode); } } }
void CBuilderAdapterVisitor::VisitAttributeL(CSdpAttr &aAttribute) { if(!iBuilder) return; TBuf8<2> attrId(2); BigEndian::Put16(&attrId[0], aAttribute.AttributeID()); iBuilder = iBuilder->BuildUintL(attrId); }
// --------------------------------------------------------------------------- // TPresCondIdentityMany::RemoveIdentityFromManyExceptL() // --------------------------------------------------------------------------- // EXPORT_C TInt TPresCondIdentityMany::RemoveIdentityFromManyExceptL( const TDesC& aRuleID, const TDesC& aId, const TDesC& aDomain) { OPENG_DP(D_OPENG_LIT( "TPresCondIdentityMany::RemoveIdentityFromManyExceptL()" ) ); OPENG_DP(D_OPENG_LIT( " aRuleID:%S,aDomain:%S,aId:%S"), &aRuleID, &aDomain, &aId); __ASSERT_ALWAYS(iPresXDM, User::Leave(KErrNotReady)); TInt ret(KErrNotFound); RPointerArray<CXdmDocumentNode> nodes; CXdmNodeAttribute* attrId(NULL); CXdmDocumentNode* manyNode = GetManyNodeL(aRuleID, EFalse, aDomain); if(manyNode!=NULL) { TInt err = manyNode->Find(KXdmExcept, nodes); TInt exceptNodeCount = nodes.Count(); //go through all except nodes for (TInt i=0; i<exceptNodeCount; i++) { attrId = (nodes[i])->Attribute(KXdmId); // for now we are supposing that except has only 1 id if(attrId!=NULL) { if (aId==(attrId->AttributeValue())) { OPENG_DP(D_OPENG_LIT( " RemoveFromModelL: i=%d" ),i); iPresXDM->RemoveFromModelL(attrId); //if except node is empty after this if( (nodes[i])->AttributeCount() == 0) { // remove except node also iPresXDM->RemoveFromModelL(nodes[i]); } ret = KErrNone; break; } } attrId = NULL; } } OPENG_DP(D_OPENG_LIT( " return: %d"),ret); nodes.Close(); return ret; }
void BranchTask::save(ISerializableNode* node) const { super::save(node); if (this->m_status != BT_INVALID) { int id = -1; if (this->m_currentTask) { id = this->m_currentTask->GetId(); } CSerializationID attrId("current"); node->setAttr(attrId, id); } }
void BranchTask::load(ISerializableNode* node) { super::load(node); if (this->m_status != BT_INVALID) { CSerializationID attrId("current"); behaviac::string attrStr; if (node->getAttr(attrId, attrStr)) { int currentNodeId = -1; StringUtils::FromString(attrStr.c_str(), currentNodeId); if (currentNodeId != -1) { this->m_currentTask = (BehaviorTask*)this->GetTaskById(currentNodeId); } } } }
void CompositeTask::save(ISerializableNode* node) const { super::save(node); if (this->m_status != BT_INVALID) { CSerializationID attrId("activeChildIndex"); node->setAttr(attrId, this->m_activeChildIndex); BehaviorTasks_t::size_type count = this->m_children.size(); for (BehaviorTasks_t::size_type i = 0; i < count; ++i) { BehaviorTask* childTask = this->m_children[i]; CSerializationID nodeId("node"); ISerializableNode* chidlNode = node->newChild(nodeId); childTask->save(chidlNode); } } }
// --------------------------------------------------------------------------- // TPresCondIdentityMany::IsIdentityExistsInManyExceptL() // --------------------------------------------------------------------------- // EXPORT_C TBool TPresCondIdentityMany::IsIdentityExistsInManyExceptL(const TDesC& aRuleID, const TDesC& aId, const TDesC& aDomain) { OPENG_DP(D_OPENG_LIT( "TPresCondIdentityMany::IsIdentityExistsInManyExcept()" ) ); OPENG_DP(D_OPENG_LIT( " aRuleID:%S,aDomain:%S,aId:%S"), &aRuleID, &aDomain, &aId); TBool ret(EFalse); RPointerArray<CXdmDocumentNode> nodes; CXdmNodeAttribute* attrId(NULL); CXdmDocumentNode* manyNode = GetManyNodeL(aRuleID, EFalse, aDomain); if(manyNode!=NULL) { TInt err = manyNode->Find(KXdmExcept, nodes); TInt exceptNodeCount = nodes.Count(); //go through all except nodes for (TInt i=0; i<exceptNodeCount; i++) { attrId = (nodes[i])->Attribute(KXdmId); // for now we are supposing that except has only 1 id if(attrId!=NULL) { if (aId==(attrId->AttributeValue())) { OPENG_DP(D_OPENG_LIT( " Found: i=%d" ),i); ret = ETrue; break; } } attrId = NULL; } } nodes.Close(); return ret; }
// --------------------------------------------------------------------------- // TPresCondIdentityMany::GetIdentitiesFromManyExceptL() // --------------------------------------------------------------------------- // EXPORT_C TInt TPresCondIdentityMany::GetIdentitiesFromManyExceptL(const TDesC& aRuleID, CDesCArray& aIds, const TDesC& aDomain) { OPENG_DP(D_OPENG_LIT( "TPresCondIdentityMany::GetIdentitiesFromManyExceptL()" ) ); OPENG_DP(D_OPENG_LIT( " aRuleID:%S,aDomain:%S"),&aRuleID, &aDomain); TInt ret(KErrNotFound); RPointerArray<CXdmDocumentNode> nodes; CXdmNodeAttribute* attrId(NULL); CXdmDocumentNode* manyNode = GetManyNodeL(aRuleID, EFalse, aDomain); if(manyNode!=NULL) { TInt err = manyNode->Find(KXdmExcept, nodes); TInt exceptNodeCount = nodes.Count(); // go through all 'except' nodes for(TInt i=0; i<exceptNodeCount; i++) { attrId = (nodes[i])->Attribute(KXdmId); // for now we are supposing that except has only 1 id if(attrId!=NULL) { aIds.AppendL(attrId->AttributeValue()); } attrId = NULL; } ret = KErrNone; } OPENG_DP(D_OPENG_LIT( " return: %d"),ret); nodes.Close(); return ret; }