当前位置: 首页>>代码示例>>C++>>正文


C++ DataObjectRef::getMetadata方法代码示例

本文整理汇总了C++中DataObjectRef::getMetadata方法的典型用法代码示例。如果您正苦于以下问题:C++ DataObjectRef::getMetadata方法的具体用法?C++ DataObjectRef::getMetadata怎么用?C++ DataObjectRef::getMetadata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataObjectRef的用法示例。


在下文中一共展示了DataObjectRef::getMetadata方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onSendDataObject

/*
	On send events, the security manager 
 
 */
void SecurityManager::onSendDataObject(Event *e)
{
	if (!e || !e->hasData())
		return;

	DataObjectRef dObj = e->getDataObject();
	
	if (dObj->isThisNodeDescription()) {
		// This is our node description. Piggy-back our certificate.
		if (myCert) {
			Metadata *m;

			m = dObj->getMetadata()->getMetadata("Security");
			
			if (m) {
				HAGGLE_ERR("Node description already has a Security tag!\n");
			} else {
				m = dObj->getMetadata()->addMetadata("Security");
				
				if (m) {
					m->addMetadata(myCert->toMetadata());
				}
			}
		}
	}
	
	// In most cases the data object is already signed here (e.g., if it is generated by a local
	// application, or was received from another node). The only reason to check if we should
	// sign the data object here, is if a data object was generated internally by Haggle -- in
	// which case the data object might not have a signature (e.g., the data object is a node
	// description).
	InterfaceRef iface = dObj->getRemoteInterface();
	
	if (dObj->shouldSign() && !(iface && iface->getType() == Interface::TYPE_APPLICATION_PORT)) {
		// FIXME: data objects should really be signed in the SecurityHelper thread since
		// it is a potentially CPU intensive operation. But it is currently not possible
		// to ensure that the signing operation has finished in the helper thread before
		// the data object is actually sent on the wire by the protocol manager.
		// To handle this situation, we probably need to add a new public event for 
		// security related operations, after which the security manager generates the
		// real send event.
		
		if (helper->signDataObject(dObj, privKey)) {
			HAGGLE_DBG("Successfully signed data object %s\n", dObj->getIdStr());
		} else {
			HAGGLE_DBG("Signing of data object %s failed!\n", dObj->getIdStr());
		}
	}	
}
开发者ID:dmonakhov,项目名称:haggle,代码行数:53,代码来源:SecurityManager.cpp

示例2: createRoutingInformationDataObject

DataObjectRef Forwarder::createRoutingInformationDataObject()
{
	// No need to have a reference in this function because it won't be 
	// visible outside until this function is done with it.
	DataObjectRef dObj = DataObject::create();
	
	if (!dObj)
		return NULL;

	HAGGLE_DBG2("Creating routing info data object\n");

	dObj->setPersistent(false);
	dObj->addAttribute("Forwarding", getName());
	
	// Add the metric data to the forwarding section:
	Metadata *md = dObj->getMetadata()->addMetadata(getManager()->getName());
	
	md = md->addMetadata(getName());
	md->setParameter("node_id", getKernel()->getThisNode()->getIdStr());
	
	if (!addRoutingInformation(dObj, md)) {
        // SW: ERR->DBG, this is not fatal, we return false when we don't want
        // to add routing data.
	        // HAGGLE_DBG("Could not add routing information\n");
		return NULL;
	}

	return dObj;
}
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:29,代码来源:Forwarder.cpp

示例3:

// CBMEN, HL, Begin
int
ReplicationOptimizer::getCost(DataObjectRef dObj, string node_id)
{
    int dataLen = 0;
    {
        dataLen = (int) dObj->getDataLen();
        // include metadata size
        Metadata *m = dObj->getMetadata();
        if (!m) {
            errorCount++;
            HAGGLE_ERR("Missing metadata.\n");
            return 0;
        }
        dataLen += m->getContent().size();
    }

    {
        node_map_t::iterator it = node_map.find(node_id);
        if (it == node_map.end()) {
            errorCount++;
            HAGGLE_ERR("Missing node: %s\n", node_id.c_str());
            return 0;
        }
    }

    return dataLen;
}
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:28,代码来源:ReplicationOptimizer.cpp

示例4: hasRoutingInformation

bool Forwarder::hasRoutingInformation(const DataObjectRef& dObj)
{
	if (!dObj)
		return false;
	
	const Metadata *m = dObj->getMetadata()->getMetadata(getManager()->getName());
	
	if (m == NULL)
		return false;
		
	if (!m->getMetadata(getName()))
		return false;
	    
	return true;
}
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:15,代码来源:Forwarder.cpp

示例5: _onConfig

void Manager::_onConfig(Event *e)
{
	DataObjectRefList& dObjs = e->getDataObjectList();

	while (dObjs.size()) {
                DataObjectRef dObj = dObjs.pop();

		// Get the metadata matching the manager
		Metadata *m = dObj->getMetadata()->getMetadata(this->getName());

		if (m) {
			onConfig(m);
		}
	}
}
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:15,代码来源:Manager.cpp

示例6: getNodeIdFromRoutingInformation

const string Forwarder::getNodeIdFromRoutingInformation(const DataObjectRef& dObj) const
{
	if (!dObj)
		return (char *)NULL;
	
	const Metadata *m = dObj->getMetadata()->getMetadata(getManager()->getName());
	
	if (!m)
		return (char *)NULL;
	
	m = m->getMetadata(getName());
	
	if (!m)
		return (char *)NULL;
	
	return m->getParameter("node_id");
}
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:17,代码来源:Forwarder.cpp

示例7: onIncomingDataObject

/*
	Check incoming data objects for two reasons:
	1) whether they have an embedded certificate, in which case we verify 
	it and add it to our store in case it is not already there.
	2) sign any data objects that were generated by local applications.
 */
void SecurityManager::onIncomingDataObject(Event *e)
{
	DataObjectRef dObj;
	
	if (!e || !e->hasData())
		return;
	
	dObj = e->getDataObject();
	
	if (dObj->isDuplicate())
		return;

	Metadata *m = dObj->getMetadata()->getMetadata("Security");
	
	// Check if there is a certificate embedded that we do not already have stored
	if (m && m->getMetadata("Certificate")) {
		HAGGLE_DBG("Data object has embedded certificate, trying to verify it!\n");
		helper->addTask(new SecurityTask(SECURITY_TASK_VERIFY_CERTIFICATE, dObj));
	}
			
	InterfaceRef iface = dObj->getRemoteInterface();

	// Check if this data object came from an application, in that case we sign it.
	// In the future, the signing should potentially be handled by the application
	// itself. But this requires some major rethinking of how to manage certificates 
	// and keys, etc.
	if (iface && iface->getType() == Interface::TYPE_APPLICATION_PORT && dObj->shouldSign()) {
		HAGGLE_DBG("Data object should be signed\n");

		// FIXME: data objects should really be signed in the SecurityHelper thread since
		// it is a potentially CPU intensive operation. But it is currently not possible
		// to ensure that the signing operation has finished in the helper thread before
		// the data object is added to the data store.
		if (helper->signDataObject(dObj, privKey)) {
			HAGGLE_DBG("Successfully signed data object %s, which was added by an application.\n", 
				   dObj->getIdStr());
		} else {
			HAGGLE_DBG("Signing of data object %s, which was added by an application, failed!\n", 
				   dObj->getIdStr());
		}
	}
}
开发者ID:dmonakhov,项目名称:haggle,代码行数:48,代码来源:SecurityManager.cpp

示例8: _onDynamicConfig

void Manager::_onDynamicConfig(Event *e)
{
	if (!e || !e->hasData())
		return;

	DataObjectRef dObj = e->getDataObject();
	if (!dObj)
		return;

	Metadata *m = dObj->getMetadata();
	if (!m)
		return;

	m = m->getMetadata(DATAOBJECT_METADATA_APPLICATION_CONTROL_DYNAMIC_CONFIGURATION);
	if (!m)
		return;

	m = m->getMetadata(getName());
	if (!m)
		return;

	onDynamicConfig(m);

}
开发者ID:SRI-CSL,项目名称:ENCODERS,代码行数:24,代码来源:Manager.cpp


注:本文中的DataObjectRef::getMetadata方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。