本文整理汇总了C++中AssetPtr::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ AssetPtr::getType方法的具体用法?C++ AssetPtr::getType怎么用?C++ AssetPtr::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AssetPtr
的用法示例。
在下文中一共展示了AssetPtr::getType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateAsset
bool Agent::updateAsset (Device *aDevice, const std::string & aId, AssetChangeList & aList,
const string & aTime)
{
AssetPtr asset;
string time;
if ( aTime.empty( ) )
{
time = getCurrentTime(GMT_UV_SEC);
}
else
{
time = aTime;
}
{
dlib::auto_mutex lock(*mAssetLock);
asset = mAssetMap[aId];
if ( asset.getObject( ) == NULL )
{
return false;
}
if ( asset->getType( ) != "CuttingTool" )
{
return false;
}
CuttingToolPtr tool((CuttingTool *) asset.getObject( ));
AssetChangeList::iterator iter;
for ( iter = aList.begin( ); iter != aList.end( ); ++iter )
{
if ( iter->first == "xml" )
{
mXmlParser->updateAsset(asset, asset->getType( ), iter->second);
}
else
{
tool->updateValue(iter->first, iter->second);
}
}
tool->setTimestamp(aTime);
tool->setDeviceUuid(aDevice->getUuid( ));
tool->changed( );
}
addToBuffer(aDevice->getAssetChanged( ), asset->getType( ) + "|" + aId, time);
return true;
}
示例2: addAsset
bool Agent::addAsset(Device *aDevice, const string &aId, const string &aAsset,
const string &aType,
const string &aTime)
{
// Check to make sure the values are present
if (aType.empty() || aAsset.empty() || aId.empty()) {
sLogger << LWARN << "Asset '" << aId << "' missing required type, id, or body. Asset is rejected.";
return false;
}
string time;
if (aTime.empty())
time = getCurrentTime(GMT_UV_SEC);
else
time = aTime;
// Lock the asset addition to protect from multithreaded collisions. Releaes
// before we add the event so we don't cause a race condition.
{
dlib::auto_mutex lock(*mAssetLock);
AssetPtr old = mAssetMap[aId];
if (old.getObject() != NULL)
mAssets.remove(old);
else
mAssetCounts[aType] += 1;
AssetPtr ptr;
if (aType == "CuttingTool") {
try {
ptr = mXmlParser->parseAsset(aId, aType, aAsset);
}
catch (runtime_error &e) {
sLogger << LERROR << "addAsset: Error parsing asset: " << aAsset << "\n" << e.what();
return false;
}
} else {
ptr.setObject(new Asset(aId, aType, aAsset), true);
ptr->setTimestamp(time);
ptr->setDeviceUuid(aDevice->getUuid());
}
if (ptr.getObject() == NULL) {
sLogger << LWARN << "Asset could not be created";
return false;
} else {
if (ptr->getTimestamp().empty())
ptr->setTimestamp(time);
if (ptr->getDeviceUuid().empty())
ptr->setDeviceUuid(aDevice->getUuid());
}
// Check for overflow
if (mAssets.size() >= mMaxAssets)
{
old = mAssets.front();
mAssetCounts[old->getType()] -= 1;
mAssets.pop_front();
mAssetMap.erase(old->getAssetId());
}
mAssetMap[aId] = ptr;
mAssets.push_back(ptr);
// Add secondary keys
AssetKeys &keys = ptr->getKeys();
AssetKeys::iterator iter;
for (iter = keys.begin(); iter != keys.end(); iter++)
{
AssetIndex &index = mAssetIndices[iter->first];
index[iter->second] = ptr;
}
}
// Generate an asset chnaged event.
addToBuffer(aDevice->getAssetChanged(), aType + "|" + aId, time);
return true;
}