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


C++ AssetPtr::getTimestamp方法代码示例

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


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

示例1: 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;
}
开发者ID:nikhilbchilwant,项目名称:cppagent,代码行数:80,代码来源:agent.cpp


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