Beispiel #1
0
	virtual void execute (CCtrlBase * /* pCaller */, const string &Params)
	{
		CInterfaceManager *pIM = CInterfaceManager::getInstance();
		string dbdst = getParam (Params, "dbdst");
		string dbsrc = getParam (Params, "dbsrc");
		CCDBNodeBranch *pNBdst = pIM->getDbBranch(dbdst);
		CCDBNodeBranch *pNBsrc = pIM->getDbBranch(dbsrc);

		// Branch copy

		if ((pNBdst != NULL) && (pNBsrc != NULL))
		{
			//nlinfo("copying from %s to %s",pNBsrc->getName()->c_str(), pNBdst->getName()->c_str());

			// Parse all children of the src branch
			uint nbLeaves = pNBsrc->countLeaves();
			for (uint i = 0; i < nbLeaves; ++i)
			{
				uint count = i;
				CCDBNodeLeaf *pNLsrc = pNBsrc->findLeafAtCount(count);
				// Find its access name
				string sTmp = *pNLsrc->getName();
				CCDBNodeBranch *pParent = pNLsrc->getParent();
				while (pParent != pNBsrc)
				{
					sTmp = *pParent->getName() + ":" + sTmp;
					pParent = pParent->getParent();
				}
				// Find the correspondant node in the dst branch
				CCDBNodeLeaf *pNLdst = dynamic_cast<CCDBNodeLeaf*>(pNBdst->getNode(ICDBNode::CTextId(sTmp)));
				if (pNLdst == NULL)
				{
					nlwarning ("cannot find destination leaf %s",sTmp.c_str());
				}
				else
				{
					pNLdst->setValue64(pNLsrc->getValue64());

					//sint32 nVal = pNLsrc->getValue64();
					//nlinfo("set value %d for node %s", nVal, sTmp.c_str());
				}
			}
			return;
		}

		// Not branch copy so leaf copy

		CInterfaceProperty ipsrc;
		CInterfaceProperty ipdst;
		if (!ipsrc.link (dbsrc.c_str()))
		{
			nlwarning("cannot find leaf %s",dbsrc.c_str());
			return;
		}
		if (!ipdst.link (dbdst.c_str()))
		{
			nlwarning("cannot find leaf %s",dbdst.c_str());
			return;
		}
		// copy
		ipdst.setSInt64 (ipsrc.getSInt64());
	}