本文整理汇总了C++中DeviceMap类的典型用法代码示例。如果您正苦于以下问题:C++ DeviceMap类的具体用法?C++ DeviceMap怎么用?C++ DeviceMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DeviceMap类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: myRelease
static ULONG __stdcall myRelease(ID3D10Device *pDevice) {
//TODO: Move logic to HardHook.
// Call base without active hook in case of no trampoline.
ReleaseType oRelease = (ReleaseType) hhRelease.call;
hhRelease.restore();
ULONG res = oRelease(pDevice);
hhRelease.inject();
Mutex m;
DeviceMap::iterator it = devices.find(pDevice);
if (it != devices.end()) {
D10State *ds = it->second;
// If we are receiving a lot of subsequent releases lets eagerly drop
// our state object. If the device presents something again a state
// object is created again just fine anyway.
if (res < ds->lHighMark / 2) {
ods("D3D10: Deleting resources %u < 0.5 * %u", res, ds->lHighMark);
devices.erase(it);
chains.erase(ds->pSwapChain);
delete ds;
ods("D3D10: Deleted");
ds = NULL;
}
}
return res;
}
示例2: AddDevice
int32_t CParseDevice::AddDevice(DeviceInfo& deviceInfo)
{
//check Id
DeviceMap::iterator deviceIter = g_deviceMap.find(deviceInfo.m_nId);
if (deviceIter != g_deviceMap.end())
{
return fail;
}
//new
DeviceInfo* pDeviceInfo = new DeviceInfo;
*pDeviceInfo = deviceInfo;
//bool bHasUserInfo = false;
//if ((0 != strlen(deviceInfo.m_szUser)) && (0 != strlen(deviceInfo.m_szPassword)))
//{
// bHasUserInfo = true;
//}
//if (0 == strcmp("DH", deviceInfo.m_szIdentifier))
//{
// if (deviceInfo.m_nRate)
// {
// sprintf(pDeviceInfo->m_szSourceUrl, "rtsp://%s:%d/cam/realmonitor?channel=2&subtype=1", deviceInfo.m_szIP, deviceInfo.m_nPort);
// }
// else
// {
// sprintf(pDeviceInfo->m_szSourceUrl, "rtsp://%s:%d/cam/realmonitor?channel=2&subtype=0", deviceInfo.m_szIP, deviceInfo.m_nPort);
// }
//}
//else if (0 == strcmp("HK", deviceInfo.m_szIdentifier))
//{
// if (deviceInfo.m_nRate)
// {
// sprintf(pDeviceInfo->m_szSourceUrl, "rtsp://%s:%d/h264/ch1/main/av_stream", deviceInfo.m_szIP, deviceInfo.m_nPort);
// }
// else
// {
// sprintf(pDeviceInfo->m_szSourceUrl, "rtsp://%s:%d/h264/ch1/sub/av_stream", deviceInfo.m_szIP, deviceInfo.m_nPort);
// }
//}
//else
//{
// delete pDeviceInfo;
// return fail;
//}
//±êʶÃû
//sprintf(pDeviceInfo->m_szIdname, "%s%s%d", deviceInfo.m_szIdentifier, deviceInfo.m_szModel, deviceInfo.m_nId);
//insert
g_deviceMap.insert(make_pair(pDeviceInfo->m_nId, pDeviceInfo));
return success;
}
示例3: Clear
void CParseDevice::Clear()
{
DeviceMap::iterator deviceIter = g_deviceMap.begin();
for (; deviceIter != g_deviceMap.end(); deviceIter++)
{
delete (*deviceIter).second;
}
g_deviceMap.clear();
}
示例4: pthread_mutex_lock
void CParseDevice::Clear()
{
pthread_mutex_lock(&dmt);
DeviceMap::iterator deviceIter = g_deviceMap.begin();
for (; deviceIter != g_deviceMap.end(); deviceIter++)
{
delete (*deviceIter).second;
}
g_deviceMap.clear();
pthread_mutex_unlock(&dmt);
}
示例5: logging
void monitor::EventMonitor::processTopologyModifiedDimms(const DeviceMap &devices,
const std::vector<std::string> &replacedUids)
{
LogEnterExit logging(__FUNCTION__, __FILE__, __LINE__);
for (DeviceMap::const_iterator iter = devices.begin();
iter != devices.end(); iter++)
{
const std::string &uidStr = iter->first;
const struct deviceInfo &device = iter->second;
// device has moved (handle has changed)
if (device.discovered && device.stored &&
(device.discovery.device_handle.handle !=
device.storedState.device_handle))
{
store_event_by_parts(EVENT_TYPE_CONFIG,
EVENT_SEVERITY_INFO,
EVENT_CODE_CONFIG_TOPOLOGY_MOVED_DEVICE,
device.discovery.uid,
false,
uidStr.c_str(),
NULL,
NULL,
DIAGNOSTIC_RESULT_UNKNOWN);
}
// old device not discovered
else if (device.stored && !device.discovered)
{
// Make sure it's not in the replaced UIDs list
// if so it's already been covered by replacement events
if (std::find(replacedUids.begin(), replacedUids.end(),
uidStr) == replacedUids.end())
{
NVM_UID uid;
uid_copy(uidStr.c_str(), uid);
store_event_by_parts(EVENT_TYPE_CONFIG,
EVENT_SEVERITY_CRITICAL,
EVENT_CODE_CONFIG_TOPOLOGY_MISSING_DEVICE,
uid,
false,
uidStr.c_str(),
NULL,
NULL,
DIAGNOSTIC_RESULT_UNKNOWN);
// since the dimm is missing,
// automatically acknowledge any action required events for this dimm
acknowledgeEvent(-1, uid);
}
}
}
}
示例6: DelDevice
int32_t CParseDevice::DelDevice(uint32_t nId)
{
//check Id
DeviceMap::iterator deviceIter = g_deviceMap.find(nId);
if (deviceIter == g_deviceMap.end())
{
return fail;
}
//delete
delete (*deviceIter).second;
g_deviceMap.erase(deviceIter);
return success;
}
示例7: myAddRef
static ULONG __stdcall myAddRef(ID3D10Device *pDevice) {
//TODO: Move logic to HardHook.
// Call base without active hook in case of no trampoline.
AddRefType oAddRef = (AddRefType) hhAddRef.call;
hhAddRef.restore();
ULONG res = oAddRef(pDevice);
hhAddRef.inject();
Mutex m;
DeviceMap::iterator it = devices.find(pDevice);
if (it != devices.end()) {
it->second->lHighMark = res;
}
return res;
}
示例8: GetDeviceInfoByIdName
DeviceInfo* CParseDevice::GetDeviceInfoByIdName(const char *pszIdName)
{
DeviceMap::iterator deviceIter = g_deviceMap.begin();
for (; deviceIter != g_deviceMap.end(); deviceIter++)
{
DeviceInfo* pDeviceInfo = (*deviceIter).second;
if (NULL == pDeviceInfo)
{
continue;
}
if (0 == strcmp(pszIdName, pDeviceInfo->m_szIdname))
{
return pDeviceInfo;
}
}
return NULL;
}
示例9:
std::string monitor::EventMonitor::getReplacedDimmUid(
const DeviceMap &devices, const NVM_UINT32 &handle)
{
std::string replacedUid = "";
// find a stored device with the same handle that is no longer discovered
// this would indicated a new dimm replaced an old dimm
for (DeviceMap::const_iterator iter = devices.begin();
iter != devices.end(); iter++)
{
const struct deviceInfo &device = iter->second;
if (!device.discovered &&
device.stored &&
device.storedState.device_handle == handle)
{
replacedUid = device.storedState.uid;
break;
}
}
return replacedUid;
}
示例10: get_lib_store
void monitor::EventMonitor::monitor()
{
PersistentStore *pStore = get_lib_store();
if (pStore)
{
LogEnterExit logging(__FUNCTION__, __FILE__, __LINE__);
// clean up any context
nvm_create_context();
DeviceMap devMap;
buildDeviceMap(devMap);
for (DeviceMap::const_iterator devIter = devMap.begin();
devIter != devMap.end(); devIter++)
{
const std::string &uidStr = devIter->first;
const struct device_discovery &discovery = devIter->second.discovery;
// ignore unmanageable dimms
if (discovery.manageability == MANAGEMENT_VALIDCONFIG)
{
bool storedStateChanged = false;
bool firstState = false;
// get stored device state
struct db_dimm_state storedState;
memset(&storedState, 0, sizeof (storedState));
if (db_get_dimm_state_by_device_handle(pStore,
discovery.device_handle.handle, &storedState) != DB_SUCCESS)
{
// initial state, just store current
firstState = true;
COMMON_LOG_INFO_F("Failed to retrieve the stored health state of dimm %u",
discovery.device_handle.handle);
storedState.device_handle = discovery.device_handle.handle;
storedStateChanged = true;
}
// check for dimm health state transition
monitorDimmStatus(uidStr, discovery, storedState,
storedStateChanged, firstState);
// check for dimm sensor transitions
monitorDimmSensors(uidStr, discovery, storedState,
storedStateChanged, firstState);
// update stored dimm state
if (storedStateChanged)
{
// clear existing dimm state
if (!firstState)
{
db_delete_dimm_state_by_device_handle(pStore,
discovery.device_handle.handle);
}
// add current state
if (db_add_dimm_state(pStore, &storedState) != DB_SUCCESS)
{
COMMON_LOG_ERROR_F("Failed to store the health state of dimm %u",
discovery.device_handle.handle);
}
}
}
}
// Monitor namespace health transitions
monitorNamespaces(pStore);
// clean up
devMap.clear();
nvm_free_context();
}
}
示例11: resizeD3D10
void resizeD3D10(IDXGISwapChain *pSwapChain) {
// Remove the D10State from our "cache" (= Invalidate)
SwapchainMap::iterator it = chains.find(pSwapChain);
if (it != chains.end()) {
D10State *ds = it->second;
devices.erase(ds->pDevice);
chains.erase(it);
delete ds;
}
}
示例12: presentD3D10
// D3D10 specific logic for the Present function.
void presentD3D10(IDXGISwapChain *pSwapChain) {
ID3D10Device *pDevice = NULL;
HRESULT hr = pSwapChain->GetDevice(__uuidof(ID3D10Device), (void **) &pDevice);
if (SUCCEEDED(hr) && pDevice) {
SwapchainMap::iterator it = chains.find(pSwapChain);
D10State *ds = it != chains.end() ? it->second : NULL;
if (ds && ds->pDevice != pDevice) {
ods("D3D10: SwapChain device changed");
devices.erase(ds->pDevice);
delete ds;
ds = NULL;
}
if (ds == NULL) {
ods("D3D10: New state");
ds = new D10State(pSwapChain, pDevice);
if (!ds->init()) {
pDevice->Release();
delete ds;
return;
}
chains[pSwapChain] = ds;
devices[pDevice] = ds;
}
ds->draw();
pDevice->Release();
} else {
#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
// DXGI is used for multiple D3D versions. Thus, it is possible a device
// associated with the DXGISwapChain may very well not be a D3D10 one,
// in which case we can safely ignore it.
ods("D3D10: Could not draw because ID3D10Device could not be retrieved.");
#endif
}
}
示例13:
// D3D11 specific logic for the Present function.
extern void presentD3D11(IDXGISwapChain *pSwapChain) {
ID3D11Device *pDevice = NULL;
HRESULT hr = pSwapChain->GetDevice(__uuidof(ID3D11Device), (void **) &pDevice);
if (SUCCEEDED(hr) && pDevice) {
SwapchainMap::iterator it = chains.find(pSwapChain);
D11State *ds = it != chains.end() ? it->second : NULL;
if (ds && ds->pDevice != pDevice) {
ods("D3D11: SwapChain device changed");
devices.erase(ds->pDevice);
delete ds;
ds = NULL;
}
if (ds == NULL) {
ods("D3D11: New state");
ds = new D11State(pSwapChain, pDevice);
if (!ds->init()) {
pDevice->Release();
delete ds;
return;
}
chains[pSwapChain] = ds;
devices[pDevice] = ds;
}
ds->draw();
pDevice->Release();
} else {
#ifdef EXTENDED_OVERLAY_DEBUGOUTPUT
// DXGI is used for multiple D3D versions. Thus, this is expected if
// another version is used (like D3D10).
ods("D3D11: Could not draw because ID3D11Device could not be retrieved.");
#endif
}
}
示例14:
CParseDevice::CParseDevice()
{
g_deviceMap.clear();
}