void InstanceManager::AddInstance() { InstanceConfig config; config.mcfg = DEFAULT_CONFIG; config.mcfg.id = CreateId(); config.menu = new upsMenu(_appinst, config.mcfg, &_balmgr, this); _instances.push_back(config); Write(); }
void InstanceManager::CreateMonitors() { list<InstanceConfig> unsorted; InstanceConfig config; // Open registry key for instance configs HKEY nuttray; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, INSTANCES_KEY, 0, KEY_READ, &nuttray) == ERROR_SUCCESS) { // Iterate though all instance keys, reading the config for each // instance into a list. int i = 0; char name[128]; DWORD len = sizeof(name); while (RegEnumKeyExA(nuttray, i++, name, &len, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { unsorted.push_back(ReadConfig(nuttray, name)); len = sizeof(name); } RegCloseKey(nuttray); // Now that we've read all instance configs, place them in a sorted list. // This is a really inefficient algorithm, but even O(N^2) is tolerable // for small N. list<InstanceConfig>::iterator iter, lowest; for (lowest = unsorted.begin(); lowest != unsorted.end(); lowest++) { lowest = unsorted.begin(); for (iter = unsorted.begin(); iter != unsorted.end(); ++iter) { if (iter->order < lowest->order) lowest = iter; } _instances.push_back(*lowest); //unsorted.remove(*lowest); } unsorted.clear(); } // If no instances were found, create a default one if (_instances.empty()) { InstanceConfig config; config.mcfg = DEFAULT_CONFIG; config.mcfg.id = CreateId(); _instances.push_back(config); Write(); } // Loop thru sorted instance list and create an upsMenu for each list<InstanceConfig>::iterator iter; for (iter = _instances.begin(); iter != _instances.end(); ++iter) iter->menu = new upsMenu(_appinst, iter->mcfg, &_balmgr, this); }
GrBatchAtlas::BatchPlot::BatchPlot(int index, uint64_t genID, int offX, int offY, int width, int height, GrPixelConfig config) : fLastUpload(GrBatchDrawToken::AlreadyFlushedToken()) , fLastUse(GrBatchDrawToken::AlreadyFlushedToken()) , fIndex(index) , fGenID(genID) , fID(CreateId(fIndex, fGenID)) , fData(nullptr) , fWidth(width) , fHeight(height) , fX(offX) , fY(offY) , fRects(nullptr) , fOffset(SkIPoint16::Make(fX * fWidth, fY * fHeight)) , fConfig(config) , fBytesPerPixel(GrBytesPerPixel(config)) #ifdef SK_DEBUG , fDirty(false) #endif { fDirtyRect.setEmpty(); }
HRESULT CStopJumpMark::Init(bool bIsJumpMark, LPCTSTR tszLabel, UINT nPositionMs, UINT nId, bool bIsDemoDocumentObject) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); m_bIsJumpMark = bIsJumpMark; m_nPositionMs = nPositionMs; ZeroMemory(m_tszLabel, MAX_MARK_LABEL_LENGTH * sizeof _TCHAR); if (tszLabel != NULL) { int nLength = _tcslen(tszLabel); _tcsncpy(m_tszLabel, tszLabel, min(MAX_MARK_LABEL_LENGTH, nLength)); } // TODO is this unique? m_nId = CreateId(nId); m_bIsDemoDocumentObject = bIsDemoDocumentObject; m_bIsInitialized = true; return S_OK; }