// ***************************************************************************
void CInterfaceConfig::dataBaseToStream (NLMISC::IStream &f)
{
	if (f.isReading())
	{
		nlwarning("stream is not in writing mode");
		return;
	}

	CInterfaceManager *pIM = CInterfaceManager::getInstance();

	// Save branch of the database
	SDBLeaf leafTmp;
	CCDBNodeBranch *pDB = pIM->getDbBranch ("UI:SAVE");
	if (pDB != NULL)
	{
		// Number of leaf to save
		uint32 nbLeaves = pDB->countLeaves();
		f.serial(nbLeaves);

		for (uint32 i = 0; i < nbLeaves; ++i)
		{
			uint count = i;
			CCDBNodeLeaf *pNL = pDB->findLeafAtCount(count);
			leafTmp.setFrom(pNL);
			f.serial(leafTmp);
		}
	}
}
示例#2
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());
	}