vsModelInstance * vsModelInstanceLodGroup::MakeInstance() { vsModelInstance *inst = new vsModelInstance; AddInstance(inst); return inst; }
/** Update all Test data Throws: SCXInternalErrorException - If any instance is not a TestInstance */ void WkEnumeration::Update(bool updateInstances) { size_t count = 5; SCX_LOGTRACE(m_log, StrAppend(StrAppend(L"WkEnumeration Update() - ", updateInstances).append(L" - "), count)); // add items if needed (i.e. currently empty) if (0 == Size()) { for (size_t i=Size(); i<count; i++) { SCX_LOGTRACE(m_log, StrAppend(L"WkEnumeration Update() - Adding Test ", i)); AddInstance(SCXHandle<TestInstance>(new TestInstance(i))); } } if (updateInstances) { for (size_t i=0; i<Size(); i++) { SCXHandle<TestInstance> inst = GetInstance(i); unsigned int valA = 0; unsigned int valB = 0; inst->GetAValue(valA); inst->GetBValue(valB); inst->UpdateValueA(valA + 1); inst->UpdateValueB(valB + 2); inst->UpdateValueD(); inst->UpdateValueE(); inst->UpdateValueF(); } } }
void ACityMapMeshHolder::AddInstance(ECityMapMeshTag Tag, uint32 X, uint32 Y, float Angle) { const FQuat rotation(FVector(0.0f, 0.0f, 1.0f), Angle); const FVector location = GetTileLocation(X, Y); AddInstance(Tag, FTransform(rotation, location)); }
void CSysClass::LoadTable(CBGame* Game, CBPersistMgr* PersistMgr) { m_SavedID = PersistMgr->GetDWORD(); int numInstances = PersistMgr->GetDWORD(); for (int i = 0; i < numInstances; i++) { if (m_Persistent) { int instId = PersistMgr->GetDWORD(); if (i > 0) { Game->LOG(0, "Warning: attempting to load multiple instances of persistent class %s (%d)", m_Name.c_str(), numInstances); continue; } Instances::iterator it = m_Instances.begin(); if (it != m_Instances.end()) { (*it)->SetSavedID(instId); CSysClassRegistry::GetInstance()->AddInstanceToTable((*it), (*it)->GetInstance()); } else Game->LOG(0, "Warning: instance %d of persistent class %s not found", i, m_Name.c_str()); } // normal instances, create empty objects else { void* emptyObject = m_Build(); AddInstance(emptyObject, CSysClassRegistry::GetInstance()->GetNextID(), PersistMgr->GetDWORD()); } } }
void vsModelInstanceLodGroup::TakeInstancesFromGroup( vsModelInstanceLodGroup *otherGroup ) { while( !otherGroup->m_instance.IsEmpty() ) { vsModelInstance *instance = otherGroup->m_instance[0]; bool visible = instance->visible; otherGroup->RemoveInstance(instance); AddInstance(instance); instance->SetVisible(visible); // UpdateInstance(instance, visible); } }
/** Add a new disk instacne if it does not already exist. \param name name of instance. \param device device string (only used if new instance created). \returns NULL if a disk with the given name already exists - otherwise the new disk. \note The disk will be marked as online if found. */ SCXCoreLib::SCXHandle<StatisticalPhysicalDiskInstance> StatisticalPhysicalDiskEnumeration::AddDiskInstance(const std::wstring& name, const std::wstring& device) { SCXCoreLib::SCXHandle<StatisticalPhysicalDiskInstance> disk = FindDiskByDevice(name); if (0 == disk) { disk = new StatisticalPhysicalDiskInstance(m_deps); disk->SetId(name); disk->m_device = device; disk->m_online = true; AddInstance(disk); return disk; } disk->m_online = true; return SCXCoreLib::SCXHandle<StatisticalPhysicalDiskInstance>(0); }
/** Enumeration Helper for the Solaris platform. Not all disks are available from MNTTAB on this platform, this it is necessary to perform some additional searching of the file system. */ void StaticPhysicalDiskEnumeration::UpdateSolarisHelper() { // workaround for unknown FS/devices // try to get a list of disks from /dev/dsk std::vector<SCXCoreLib::SCXHandle<SCXCoreLib::SCXFileInfo> > disk_infos = m_deps->GetDevDskInfo(); std::map< std::wstring, int > found_devices; // iterate through all devices for ( unsigned int i = 0; i < disk_infos.size(); i++ ){ std::wstring dev_name = disk_infos[i]->GetFullPath().GetFilename(); dev_name = dev_name.substr(0,dev_name.find_last_not_of(L"0123456789")); if ( found_devices.find( dev_name ) != found_devices.end() ) continue; // already considered found_devices[dev_name] = 0; try { SCXCoreLib::SCXHandle<StaticPhysicalDiskInstance> disk = GetInstance(dev_name); if ( disk == 0 ){ disk = new StaticPhysicalDiskInstance(m_deps); disk->SetId(dev_name); disk->m_device = disk_infos[i]->GetDirectoryPath().Get() + dev_name; disk->m_online = true; // NOTE: Update will throw in case if disk is removable media, so // we will skip it (no call to AddInstance) disk->Update(); AddInstance(disk); } else { disk->Update(); // check if disk is still 'alive' // if disk goes off-line, Update throws and status remains 'false' disk->m_online = true; } } catch ( SCXCoreLib::SCXException& e ) { //std::wcout << L"excp in dsk update: " << e.What() << endl << e.Where() << endl; // ignore errors, since disk may not be accessible and it's fine } } }
void Pipe::CreateInstances() { timeval start, end; gettimeofday(&start, NULL); LOG(INFO) << "Creating instances..."; reader_->Open(options_->GetTrainingFilePath()); DeleteInstances(); Instance *instance = reader_->GetNext(); while (instance) { AddInstance(instance); instance = reader_->GetNext(); } reader_->Close(); LOG(INFO) << "Number of instances: " << instances_.size(); gettimeofday(&end, NULL); LOG(INFO) << "Time: " << diff_ms(end,start); }
/** Add a new disk instance if it does not already exist. \param name name of instance. \param device device string (only used if new instance created). \param cdDrive device is an optical drive. \returns NULL if a disk with the given name already exists - otherwise the new disk. \note The disk will be marked as online if found. */ SCXCoreLib::SCXHandle<StaticPhysicalDiskInstance> StaticPhysicalDiskEnumeration::AddDiskInstance( const std::wstring& name, const std::wstring& device #if defined(linux) , bool cdDrive #endif ) { SCXCoreLib::SCXHandle<StaticPhysicalDiskInstance> disk = GetInstance(name); if (0 == disk) { disk = new StaticPhysicalDiskInstance(m_deps); disk->SetId(name); disk->m_device = device; disk->m_online = true; #if defined(linux) disk->m_cdDrive = cdDrive; #endif AddInstance(disk); return disk; } disk->m_online = true; return SCXCoreLib::SCXHandle<StaticPhysicalDiskInstance>(0); }
size_t CParticleSystemLibrary::AddInstance(const tstring& sName, Vector vecOrigin, EAngle angAngles) { return AddInstance(CParticleSystemLibrary::Get()->FindParticleSystem(sName), vecOrigin, angAngles); }
/** Creates a new instance. returns the created instance. */ SCXHandle<TestInstance> WkEnumeration::Create(unsigned int instanceNumber) { SCXHandle<TestInstance> inst(new TestInstance(instanceNumber)); AddInstance(inst); return inst; }
void ACityMapMeshHolder::AddInstance(ECityMapMeshTag Tag, uint32 X, uint32 Y) { AddInstance(Tag, FTransform(GetTileLocation(X, Y))); }
/** @param[in] SCXHandle<NxNetRouteInstance> An NxNetRouteInstance instance @detailed This method wraps the inherited AddInstance method, so that instances passed in will be stored in the super classes' array */ void NxNetRouteEnumeration::AddNetRouteInstance(SCXCoreLib::SCXHandle<NxNetRouteInstance> instance) { AddInstance(instance); }
/** Discover logical disks. Logical disks are identified by the /etc/mnttab file (by design). If ever seen in that file, the disk will be discovered. If the disk is removed it will be marked as offline. */ void StatisticalLogicalDiskEnumeration::FindLogicalDisks() { for (EntityIterator iter=Begin(); iter!=End(); iter++) { SCXCoreLib::SCXHandle<StatisticalLogicalDiskInstance> disk = *iter; disk->m_online = false; } m_deps->RefreshMNTTab(); for (std::vector<MntTabEntry>::const_iterator it = m_deps->GetMNTTab().begin(); it != m_deps->GetMNTTab().end(); it++) { if ( ! m_deps->FileSystemIgnored(it->fileSystem) && ! m_deps->DeviceIgnored(it->device)) { SCXCoreLib::SCXHandle<StatisticalLogicalDiskInstance> disk = FindDiskByDevice(it->device); if (0 == disk) { disk = new StatisticalLogicalDiskInstance(m_deps); disk->m_device = it->device; disk->m_mountPoint = it->mountPoint; disk->m_fsType = it->fileSystem; disk->SetId(disk->m_mountPoint); #if defined(linux) static SCXLVMUtils lvmUtils; if (lvmUtils.IsDMDevice(it->device)) { try { // Try to convert the potential LVM device path into its matching // device mapper (dm) device path. std::wstring dmDevice = lvmUtils.GetDMDevice(it->device); SCXASSERT(!dmDevice.empty()); disk->m_samplerDevices.push_back(dmDevice); } catch (SCXCoreLib::SCXException& e) { static SCXCoreLib::LogSuppressor suppressor(SCXCoreLib::eWarning, SCXCoreLib::eTrace); std::wstringstream out; out << L"An exception occurred resolving the dm device that represents the LVM partition " << it->device << L" : " << e.What(); SCX_LOG(m_log, suppressor.GetSeverity(out.str()), out.str()); } } // no else required; device was not an LVM device #endif AddInstance(disk); #if defined(hpux) if (m_pathToRdev.end() == m_pathToRdev.find(disk->m_device)) { SCXCoreLib::SCXFilePath fp(disk->m_device); fp.SetFilename(L""); UpdatePathToRdev(fp.Get()); } SCXASSERT(m_pathToRdev.end() != m_pathToRdev.find(disk->m_device)); m_deps->AddDeviceInstance(disk->m_device, L"", disk->FindLVInfoByID(m_pathToRdev.find(disk->m_device)->second), m_pathToRdev.find(disk->m_device)->second); #endif } disk->m_online = true; } } }
/** Update /detailed This method parses an entire line of a route file and creates an instance for each line which is then stored in an array. @param[in] updateInstances If true (the default) the file will be read. If false, the file will not be read and instead any pre-loaded testing lines will instead be used. @throws SCXInternalErrorException If 11 elements are not parsed for each route file line. */ void NxNetRouteEnumeration::Update(bool updateInstances /* = true */ ) { SCX_LOGTRACE(m_log, L"NxNetRouteEnumeration Update()"); if( updateInstances ) { m_deps->Init(); // read in data from file } RemoveInstances(); vector<std::wstring>::iterator iter; iter = m_deps->GetLines().begin();// get iterator at beginning of file while (iter != m_deps->GetLines().end()) { std::wstring temp = *iter; std::vector<std::wstring> lineElements; StrTokenize(temp, lineElements, L"\t\n"); if (lineElements.size() != 11) { std::wostringstream error; error << L"NxNetRouteEnumeration::Update expected 11 elements in line, got " << std::endl; error << lineElements.size() << "." << std::endl; throw SCXInternalErrorException(error.str(), SCXSRCLOCATION); } if (m_log.GetSeverityThreshold() <= SCXCoreLib::eTrace ) { std::wostringstream error; error << L"NxNetRouteEnumeration::Update, parsing line of file:" << std::endl; error << temp; SCX_LOGTRACE( m_log, error.str() ); } // create new instance SCXCoreLib::SCXHandle<NxNetRouteInstance> route; route = new NxNetRouteInstance(lineElements[0], lineElements[1], lineElements[2], lineElements[3], lineElements[4], lineElements[5], lineElements[6], lineElements[7], lineElements[8], lineElements[9], lineElements[10]); AddInstance(route); ++iter;// next line } SCX_LOGTRACE(m_log, L"NxNetRouteEnumeration Update()"); }
UINT InternalDdeInitialize( LPDWORD pidInst, PFNCALLBACK pfnCallback, DWORD afCmd, BOOL fUnicode) { UINT uiRet = DMLERR_MEMORY_ERROR; register PCL_INSTANCE_INFO pcii; if (afCmd & APPCLASS_MONITOR) { afCmd |= CBF_MONMASK; } if (afCmd & APPCMD_CLIENTONLY) { afCmd |= CBF_FAIL_CONNECTIONS; } EnterDDECrit; if (*pidInst != 0) { pcii = ValidateInstance((HANDLE)LongToHandle( *pidInst )); if (pcii == NULL) { uiRet = DMLERR_INVALIDPARAMETER; goto Exit; } // only allow certain bits to be changed on reinitialize call pcii->afCmd = (pcii->afCmd & ~(CBF_MASK | MF_MASK)) | (afCmd & (CBF_MASK | MF_MASK)); LeaveDDECrit; NtUserUpdateInstance(pcii->hInstServer, &pcii->MonitorFlags, afCmd); return (DMLERR_NO_ERROR); } pcii = (PCL_INSTANCE_INFO)DDEMLAlloc(sizeof(CL_INSTANCE_INFO)); if (pcii == NULL) { uiRet = DMLERR_MEMORY_ERROR; goto Exit; } pcii->plaNameService = (LATOM *)DDEMLAlloc(sizeof(LATOM)); if (pcii->plaNameService == NULL) { uiRet = DMLERR_MEMORY_ERROR; goto Backout3; } // *pcii->plaNameService = 0; // zero init takes care of this pcii->cNameServiceAlloc = 1; /* * Flag this window as being create from a diff hmod as the app so * hotkeys don't take it as the first window created in the app and * assign it as the hotkey. */ pcii->hwndMother = _CreateWindowEx(0, (LPTSTR)(gpsi->atomSysClass[ICLS_DDEMLMOTHER]), L"", WS_POPUP, 0, 0, 0, 0, (HWND)0, (HMENU)0, 0, (LPVOID)NULL, CW_FLAGS_DIFFHMOD); if (pcii->hwndMother == 0) { uiRet = DMLERR_SYS_ERROR; goto Backout2; } SetWindowLongPtr(pcii->hwndMother, GWLP_INSTANCE_INFO, (LONG_PTR)pcii); pcii->afCmd = afCmd | APPCMD_FILTERINITS; pcii->pfnCallback = pfnCallback; // pcii->LastError = DMLERR_NO_ERROR; // zero init pcii->tid = GetCurrentThreadId(); // pcii->aServerLookup = NULL; // zero init // pcii->cServerLookupAlloc = 0; // zero init // pcii->ConvStartupState = 0; // zero init - Not blocked. // pcii->flags = 0; // zero init // pcii->cInDDEMLCallback = 0; // zero init // pcii->pLinkCounts = NULL; // zero init // Do this last when the client side is ready for whatever events // flying around may come charging in. LeaveDDECrit; uiRet = NtUserDdeInitialize(&pcii->hInstServer, &pcii->hwndEvent, &pcii->MonitorFlags, pcii->afCmd, pcii); EnterDDECrit; if (uiRet != DMLERR_NO_ERROR) { Backout: NtUserDestroyWindow(pcii->hwndMother); Backout2: DDEMLFree(pcii->plaNameService); Backout3: DDEMLFree(pcii); goto Exit; } pcii->hInstClient = AddInstance(pcii->hInstServer); *pidInst = HandleToUlong(pcii->hInstClient); if (pcii->hInstClient == 0) { LeaveDDECrit; NtUserCallOneParam((ULONG_PTR)pcii->hInstServer, SFI__CSDDEUNINITIALIZE); EnterDDECrit; uiRet = DMLERR_MEMORY_ERROR; goto Backout; } SetHandleData(pcii->hInstClient, (ULONG_PTR)pcii); pcii->next = pciiList; pciiList = pcii; if (fUnicode) { pcii->flags |= IIF_UNICODE; } uiRet = DMLERR_NO_ERROR; Exit: LeaveDDECrit; return (uiRet); }
/** Enumeration Helper for the Solaris platform. Not all disks are available from MNTTAB on this platform, this it is necessary to perform some additional searching of the file system. */ void StatisticalPhysicalDiskEnumeration::UpdateSolarisHelper() { // workaround for unknown FS/devices // try to get a list of disks from /dev/dsk SCXCoreLib::SCXDirectoryInfo oDisks( L"/dev/dsk/" ); std::vector<SCXCoreLib::SCXHandle<SCXCoreLib::SCXFileInfo> > disk_infos = oDisks.GetSysFiles(); std::map< std::wstring, int > found_devices; // iterate through all devices for ( unsigned int i = 0; i < disk_infos.size(); i++ ){ std::wstring dev_name = disk_infos[i]->GetFullPath().GetFilename(); dev_name = dev_name.substr(0,dev_name.find_last_not_of(L"0123456789")); if ( found_devices.find( dev_name ) != found_devices.end() ) continue; // already considered found_devices[dev_name] = 0; try { SCXCoreLib::SCXHandle<StatisticalPhysicalDiskInstance> disk = FindDiskByDevice(dev_name); if ( disk == 0 ){ disk = new StatisticalPhysicalDiskInstance(m_deps); disk->SetId(dev_name); disk->m_device = disk_infos[i]->GetDirectoryPath().Get() + dev_name; disk->m_online = true; // verify that hardware is accessible by calling 'physical' disk instance { SCXCoreLib::SCXHandle<StaticPhysicalDiskInstance> disk_physical; disk_physical = new StaticPhysicalDiskInstance(m_deps); disk_physical->SetId(dev_name); disk_physical->SetDevice(disk_infos[i]->GetDirectoryPath().Get() + dev_name); // update will throw exception if disk is not accessible disk_physical->Update(); } AddInstance(disk); } else { if ( !disk->m_online ){ // verify if dsik is online { SCXCoreLib::SCXHandle<StaticPhysicalDiskInstance> disk_physical; disk_physical = new StaticPhysicalDiskInstance(m_deps); disk_physical->SetId(dev_name); disk_physical->SetDevice(disk_infos[i]->GetDirectoryPath().Get() + dev_name); disk_physical->Update(); } disk->m_online = true; } } } catch ( SCXCoreLib::SCXException& e ) { //wcout << L"excp in dsk update: " << e.What() << endl << e.Where() << endl; // ignore errors, since disk may not be accessible and it's fine } } }