TFSBasis* StatusType::serialize( SocketPackage& cPackage, bool bWriteToStorage ) { TFSBasis* pResult = this; if ( bWriteToStorage ) { cPackage.add( m_nAllowedOn ); cPackage.add( m_sName ); } else { std::string sName; setAllowedOn( cPackage.getInt() ); cPackage.getString( sName ); if ( getStorage().isPresent(sName) ) pResult = getStorage().get( sName ); else setName( sName.c_str() ); } serialize( m_saPrevStatus, m_nPrevCount, cPackage, bWriteToStorage ); serialize( m_saNextStatus, m_nNextCount, cPackage, bWriteToStorage ); return pResult; }
Ogre::WorkQueue::Response* World::handleRequest(const Ogre::WorkQueue::Request *req, const Ogre::WorkQueue *srcQ) { if (req->getType() == REQ_ID_CHUNK) { const LoadRequestData data = Ogre::any_cast<LoadRequestData>(req->getData()); QuadTreeNode* node = data.mNode; LoadResponseData* responseData = new LoadResponseData(); getStorage()->fillVertexBuffers(node->getNativeLodLevel(), node->getSize(), node->getCenter(), getAlign(), responseData->mPositions, responseData->mNormals, responseData->mColours); return OGRE_NEW Ogre::WorkQueue::Response(req, true, Ogre::Any(responseData)); } else // REQ_ID_LAYERS { const LayersRequestData data = Ogre::any_cast<LayersRequestData>(req->getData()); LayersResponseData* responseData = new LayersResponseData(); getStorage()->getBlendmaps(data.mNodes, responseData->mLayerCollections, data.mPack); return OGRE_NEW Ogre::WorkQueue::Response(req, true, Ogre::Any(responseData)); } }
//============================================================================= // METHOD : SPELLwsListDataHandler::read() //============================================================================= void SPELLwsListDataHandler::read() { // Load the number of items unsigned int numItems = getStorage()->loadLong(); // Create a list PyObject* listObject = PyList_New(numItems); for( unsigned int index = 0; index < numItems; index++) { // Load the item code SPELLwsData::Code code = loadDataCode(); // Create an appropriate handler SPELLwsDataHandler* handler = SPELLwsDataHandlerFactory::createDataHandler(code); handler->setStorage(getStorage()); // Read the data handler->read(); // Add the item to the list PyList_SetItem(listObject, index, handler->getObject()); delete handler; } // Set it as associated object setObject( listObject ); }
//============================================================================= // METHOD : SPELLwsClassDataHandler::read() //============================================================================= void SPELLwsClassDataHandler::read() { // Store the class name SPELLwsObjectDataHandler nameHandler( NULL ); nameHandler.setStorage(getStorage()); SPELLwsDictDataHandler dictHandler( NULL ); dictHandler.setStorage(getStorage()); // Read the data DEBUG("[CDH] Reading name"); nameHandler.read(); DEBUG("[CDH] Name read: " + PYREPR(nameHandler.getObject())); PyObject* classObject = NULL; if ( PYSTR(nameHandler.getObject()) == "__FAILED_WS_CLASS__" ) { classObject = PyClass_New( NULL, PyDict_New(), nameHandler.getObject() ); std::string msg = "Detected failed WS class, assuming error during marshal process"; LOG_ERROR(msg); std::cerr << msg << std::endl; } else { DEBUG("[CDH] Reading dictionary"); dictHandler.read(); DEBUG("[CDH] Dictionary read: " + PYREPR(dictHandler.getObject())); // Create the class object classObject = PyClass_New( NULL, dictHandler.getObject(), nameHandler.getObject() ); } // Set it as associated object setObject( classObject ); }
//============================================================================= // METHOD : SPELLwsTimeDataHandler::read() //============================================================================= void SPELLwsTimeDataHandler::read() { // Load the number of seconds int seconds = getStorage()->loadLong(); // Load number of milliseconds int msec = getStorage()->loadLong(); // Load delta flag int delta = getStorage()->loadLong(); SPELLtime theTime; theTime.set( seconds, msec, (delta == 1) ); DEBUG("[TIMEDH] Loaded time: " + theTime.toTIMEString() ); // CREATE TIME PyObject* timeObject = SPELLpythonHelper::instance().pythonTime(theTime); if (timeObject == NULL) { THROW_EXCEPTION("Cannot load TIME", "Unable to create instance", SPELL_ERROR_WSTART); } setObject(timeObject); DEBUG("[TIMEDH] Load database items"); }
PlayerListing * PlayerListingIDRegistry::getPlayerFromName(const QString & name) { std::map<unsigned int, PlayerListing *>::iterator i; for(i = getStorage()->begin(); i != getStorage()->end(); i++) { if(i->second->name == name) return (i->second); } return NULL; }
PlayerListing * PlayerListingRegistry::getPlayerFromNotNickName(const QString & notnickname) { std::map<QString, PlayerListing *>::iterator i; for(i = getStorage()->begin(); i != getStorage()->end(); i++) { if(i->second->notnickname == notnickname) return (i->second); } return NULL; }
//============================================================================= // METHOD : SPELLwsListDataHandler::write() //============================================================================= void SPELLwsListDataHandler::write() { assert( PyList_Check(getObject())); unsigned int numItems = PyList_Size( getObject() ); // Store the number of items getStorage()->storeLong( (long) numItems ); // Store each list item for( unsigned int index = 0; index < numItems; index++) { PyObject* item = PyList_GetItem( getObject(), index ); try { SPELLwsDataHandler* handler = SPELLwsDataHandlerFactory::createDataHandler(item); handler->setStorage(getStorage()); // Store the item data code. We need it for reading operation, in order to // know which type of handler to create. handler->storeDataCode(); // IMPORTANT in the case of lists and dictionaries, we want to be able to continue // the storage evenif there is a problem in the handler processing at this point. // If that is the case, a fake empty object will be replaced by the object being // processed by the handler, and the dumping of this collection will continue. try { // Store the data handler->write(); } catch(SPELLcoreException& ex) { std::string msg = "WARNING! Storage of element " + ISTR(index) + " failed: " + ex.what(); LOG_WARN(msg); std::cerr << msg << std::endl; storeFakeObject( handler->getCode() ); } delete handler; } catch(SPELLcoreException& ex) { std::string msg = "WARNING! Failed to create data handler: " + ex.what(); LOG_WARN(msg); storeFakeObject( SPELLwsData::DATA_NONE ); } } }
void TraceManager::init() { // ensure storage is initialized getStorage(); load_plugins(); changeNumber = 0; }
//Attach an android native buffer to the V3D backend (for the current context) static void attach_buffer(EGLDisplay display, struct surface *surface) { LOGV("attach_buffer - 1" ); if( surface && surface->buffer ) { EGLBoolean ret = EGL_FALSE; LOGV("attach_buffer - 2" ); KHRN_IMAGE_WRAP_T vc_buffer; if( brcm_egl_convert_anative_buf_to_khrn_image( surface->buffer, &vc_buffer ,surface->isTiled) ) { LOGV("attach_buffer - 3" ); if(surface->buffer->format == HAL_PIXEL_FORMAT_YCbCr_422_I) { vc_buffer.storage = getStorage(surface->buffer); vc_buffer.aux = getvStorage(surface->buffer); } //call Giles function here ret = eglDirectRenderingPointer( display, surface->surface, &vc_buffer ); if( !ret ) { LOGE("attach_buffer - eglDirectRenderingPointer FAILED" ); } } else { LOGE("attach_buffer - brcm_egl_convert_anative_buf_to_khrn_image FAILED" ); } } }
std::string JSONConfig::comesFromGlobalVar(const std::string &func, const std::string &var) const { const auto &f = impl->getConfigFunctionByNameOrEmptyFunction(func); auto v = f.locals.getObjectByName(var); return v && v->getStorage().isRegister() ? impl->getNameOfRegister(*v) : std::string(); }
void Blob::getBytes(Range range, UInt8 *outBuffer) { gfx_assert_param(outBuffer); gfx_assert(range.location < length() && range.max() < length(), str("out of bounds range")); CFDataGetBytes(getStorage(), range, outBuffer); }
detail::Configuration *Mechanoid::getConfiguration() { if (configuration) return configuration; // create new working configuration from the initial one // do not create new configuration while in db tool mode if (getSettings().flags[gfDbTool]) return initial_configuration; configuration = getStorage()->configurations.createAtEnd(*initial_configuration); configuration->deepCopyFrom(*initial_configuration); // to differ from initial configurations in DB Tool configuration->text_id += L" - " + getName(); // replace pointers auto c = replace<Configuration>(configuration.get()); for (auto &w : c->weapons) replace<ConfigurationWeapon>(w); // setup c->setMechanoid(this); c->armor = c->getMaxArmor(); c->energy = c->getMaxEnergy(); c->energy_shield = c->getMaxEnergyShield(); return configuration; }
ptr<Texture2D> ParticleProducer::copyToTexture(ptr<Texture2D> t, int paramCount, getParticleParams getParams, bool useFuncRes) { int width = (int) ceil(paramCount / 4.0f); int height = getStorage()->getCapacity(); if (t == NULL || t->getWidth() != width || t->getHeight() != height) { t = new Texture2D(width, height, RGBA16F, RGBA, FLOAT, Texture::Parameters().wrapS(CLAMP_TO_BORDER).wrapT(CLAMP_TO_BORDER).min(NEAREST).mag(NEAREST), Buffer::Parameters(), CPUBuffer(NULL)); } if (params == NULL || paramSize < 4 * width * height) { if (params != NULL) { delete[] params; } params = new float[4 * width * height]; } int maxHeight = 0; vector<ParticleStorage::Particle*>::iterator i = storage->getParticles(); vector<ParticleStorage::Particle*>::iterator end = storage->end(); int h = 0; while (i != end) { ParticleStorage::Particle *p = *i++; if (useFuncRes) { h += getParams(this, p, params + 4 * width * h); } else { h = storage->getParticleIndex(p); getParams(this, p, params + 4 * width * h); ++h; } maxHeight = max(maxHeight, h); } if (maxHeight > 0) { t->setSubImage(0, 0, 0, width, maxHeight, RGBA, FLOAT, Buffer::Parameters(), CPUBuffer(params)); } return t; }
void StorageController::processRequest(const cmd_type& cmd, Storage::result_type& result) { if (cmd.name() == "stats") { storage_list_type::iterator storageIter = storages_.begin(); while(storageIter != storages_.end()) { (*storageIter->second)->get_stats(storageIter->first, result); storageIter ++; } result.append("END\n\r"); return; } Timer timer("[StorageController::processRequest]: preprocess commands"); string_list key_map; for(Command::arg_iterator x = cmd.arg_begin(); x != cmd.arg_end(); ++x) { std::string command; std::string::const_iterator i; for (i = (*x).begin(); i != (*x).end() && (*i) != ':'; i++) { command += (*i); } string_list::iterator funcMapIterator = function_map_.find(command); if (funcMapIterator == function_map_.end() ) { key_map[*x] = "default"; } else { key_map[*x] = funcMapIterator->second; } __LOG_DEBUG << "storage for: " << *x << " - " << key_map[*x]; } timer.show(); Timer searchStorageTimer("Search storage for command"); string_list::iterator i = key_map.begin(); std::map<std::string, Command> command_list; while (i != key_map.end()) { if ((command_list.find(i->second)) == command_list.end()) { cmd_type command (""); command.name(cmd.name()); command_list[i->second] = command; } command_list.at(i->second).insert(i->first); i++; } searchStorageTimer.show(); std::map<std::string, Command>::iterator j = command_list.begin(); while (j != command_list.end()) { Timer storageTimer("Storage " + j->first + " processed request"); getStorage(j->first)->_do(j->second, result); storageTimer.show(); j++; } result.append("END\r\n"); }
StatusType* StatusType::withName( const char* szName ) { if ( szName == NULL || *szName == '\0' ) return NULL; else return getStorage().get( szName ); }
void BufferStorage11::markTransformFeedbackUsage() { TypedBufferStorage11 *transformFeedbackStorage = getStorage(BUFFER_USAGE_VERTEX_OR_TRANSFORM_FEEDBACK); if (transformFeedbackStorage) { transformFeedbackStorage->setDataRevision(transformFeedbackStorage->getDataRevision() + 1); } }
std::string JSONConfig::getRegisterForGlobalVar(const std::string &var) const { const auto reg = impl->getConfigRegisterByName(var); if (!reg) { return {}; } std::string registerName; bool inRegister = reg->getStorage().isRegister(registerName); return inRegister ? registerName : std::string(); }
//============================================================================= // METHOD : SPELLwsClassDataHandler::write() //============================================================================= void SPELLwsClassDataHandler::write() { assert( PyClass_Check(getObject()) ); PyClassObject* classObject = reinterpret_cast<PyClassObject*>(getObject()); DEBUG("[CDH] Storing name: " + PYREPR(classObject->cl_name) ); SPELLwsObjectDataHandler nameHandler( classObject->cl_name ); nameHandler.setStorage(getStorage()); DEBUG("[CDH] Storing dictionary: " + PYREPR(classObject->cl_dict)); SPELLwsDictDataHandler dictHandler( classObject->cl_dict ); dictHandler.setStorage(getStorage()); // Store the class name, We dont need a data code, we know what is there nameHandler.write(); // Store the class dictionary dictHandler.write(); DEBUG("[CDH] Storing class done" ); }
void MtpServer::addStorage(MtpStorage* storage) { android::Mutex::Autolock autoLock(mMutex); MTPD("addStorage(): storage: %x\n", storage); if (getStorage(storage->getStorageID()) != NULL) { MTPE("MtpServer::addStorage Storage for storage ID %i already exists.\n", storage->getStorageID()); return; } mDatabase->createDB(storage, storage->getStorageID()); mStorages.push(storage); sendStoreAdded(storage->getStorageID()); }
void World::buildQuadTree(QuadTreeNode *node, std::vector<QuadTreeNode*>& leafs) { float halfSize = node->getSize()/2.f; if (node->getSize() <= mMinBatchSize) { // We arrived at a leaf float minZ,maxZ; Ogre::Vector2 center = node->getCenter(); float cellWorldSize = getStorage()->getCellWorldSize(); if (mStorage->getMinMaxHeights(node->getSize(), center, minZ, maxZ)) { Ogre::AxisAlignedBox bounds(Ogre::Vector3(-halfSize*cellWorldSize, -halfSize*cellWorldSize, minZ), Ogre::Vector3(halfSize*cellWorldSize, halfSize*cellWorldSize, maxZ)); convertBounds(bounds); node->setBoundingBox(bounds); leafs.push_back(node); } else node->markAsDummy(); // no data available for this node, skip it return; } if (node->getCenter().x - halfSize > mMaxX || node->getCenter().x + halfSize < mMinX || node->getCenter().y - halfSize > mMaxY || node->getCenter().y + halfSize < mMinY ) // Out of bounds of the actual terrain - this will happen because // we rounded the size up to the next power of two { node->markAsDummy(); return; } // Not a leaf, create its children node->createChild(SW, halfSize, node->getCenter() - halfSize/2.f); node->createChild(SE, halfSize, node->getCenter() + Ogre::Vector2(halfSize/2.f, -halfSize/2.f)); node->createChild(NW, halfSize, node->getCenter() + Ogre::Vector2(-halfSize/2.f, halfSize/2.f)); node->createChild(NE, halfSize, node->getCenter() + halfSize/2.f); buildQuadTree(node->getChild(SW), leafs); buildQuadTree(node->getChild(SE), leafs); buildQuadTree(node->getChild(NW), leafs); buildQuadTree(node->getChild(NE), leafs); // if all children are dummy, we are also dummy for (int i=0; i<4; ++i) { if (!node->getChild((ChildDirection)i)->isDummy()) return; } node->markAsDummy(); }
BufferStorage11::NativeBuffer11 *BufferStorage11::getStagingBuffer() { TypedBufferStorage11 *stagingStorage = getStorage(BUFFER_USAGE_STAGING); if (!stagingStorage) { // Out-of-memory return NULL; } ASSERT(HAS_DYNAMIC_TYPE(NativeBuffer11*, stagingStorage)); return static_cast<NativeBuffer11*>(stagingStorage); }
Class* TFSBasis::getElementAt( const std::vector<Class*>& paVector, size_t nSize, size_t nIndex ) const { if ( nIndex < 0 || nIndex >= nSize ) return NULL; else { if ( getStorage().isPresent(paVector[nIndex]) ) return paVector[nIndex]; else return NULL; } }
BufferStorage11::PackStorage11 *BufferStorage11::getPackStorage() { TypedBufferStorage11 *packStorage = getStorage(BUFFER_USAGE_PIXEL_PACK); if (!packStorage) { // Out-of-memory return NULL; } ASSERT(HAS_DYNAMIC_TYPE(PackStorage11*, packStorage)); return static_cast<PackStorage11*>(packStorage); }
//============================================================================= // METHOD : SPELLwsObjectDataHandler::storeFakeObject() //============================================================================= void SPELLwsObjectDataHandler::storeFakeObject( SPELLwsData::Code code ) { switch(code) { case SPELLwsData::DATA_BYTECODE: case SPELLwsData::DATA_GENERIC: case SPELLwsData::DATA_NONE: getStorage()->storeObject(Py_None); break; case SPELLwsData::DATA_CLASS: getStorage()->storeObject( PyString_FromString("__FAILED_WS_CLASS__")); break; case SPELLwsData::DATA_DICTIONARY: getStorage()->storeObject(PyDict_New()); break; case SPELLwsData::DATA_LIST: getStorage()->storeObject(PyList_New(0)); break; default: THROW_EXCEPTION("Cannot store fake object", "Unknown handler type: " + ISTR(code), SPELL_ERROR_WSTART); } }
//============================================================================= // METHOD : SPELLwsTimeDataHandler::write() //============================================================================= void SPELLwsTimeDataHandler::write() { if (getObject() == NULL) { getStorage()->storeLong( -1 ); return; } SPELLtime theTime = SPELLpythonHelper::instance().evalTime( getObject() ); DEBUG("[TIMEDH] Storing time value: " + theTime.toTIMEString() ); DEBUG("[TIMEDH] Storing seconds from epoch"); // Store the seconds getStorage()->storeLong( theTime.getSeconds() ); // Store the milliseconds getStorage()->storeLong( theTime.getMilliseconds() ); // Store delta flag getStorage()->storeLong( theTime.isDelta() ? 1 : 0 ); DEBUG("[TIMEDH] Storing time done"); }
void showOptionsWindow(Area *parentArea) { Font titleFont(L"nova.ttf", 26); Font font(L"laudcn2.ttf", 14); bool fullscreen = (getStorage()->get(L"fullscreen", 1) != 0); bool niceCursor = (getStorage()->get(L"niceCursor", 1) != 0); bool hideCursor = (getStorage()->get(L"hideCursor", 0) != 0); bool invertShoulder = (getStorage()->get(L"invertShoulder", 0) != 0); float volume = ((float)getStorage()->get(L"volume", 20)) / 100.0f; Area area; area.add(parentArea); area.add(new Window(250, 170, 300, 260, L"blue.bmp")); area.add(new Label(&titleFont, 250, 175, 300, 40, Label::ALIGN_CENTER, Label::ALIGN_MIDDLE, 255,255,0, msg(L"options"))); OPTION(240, L"fullscreen", fullscreen); #ifndef __APPLE__ OPTION(260, L"niceCursor", niceCursor); OPTION(280, L"hideCursor", hideCursor); #endif OPTION(300, L"invertShoulder", invertShoulder); area.add(new Label(&font, 265, 330, 300, 20, Label::ALIGN_LEFT, Label::ALIGN_MIDDLE, 255,255,255, msg(L"volume"))); area.add(new Slider(360, 332, 160, 16, volume)); ExitCommand exitCmd(area); OptionsChangedCommand okCmd(&area, fullscreen, niceCursor,hideCursor,invertShoulder, volume); area.add(new Button(315, 390, 85, 25, &font, 255,255,0, L"blue.bmp", msg(L"ok"), &okCmd)); area.add(new Button(405, 390, 85, 25, &font, 255,255,0, L"blue.bmp", msg(L"cancel"), &exitCmd)); area.add(new KeyAccel(SDLK_ESCAPE, &exitCmd)); area.add(new KeyAccel(SDLK_RETURN, &okCmd)); area.run(); }
int8 CCharEntity::getShieldSize() { CItemArmor* PItem = (CItemArmor*)(getStorage(LOC_INVENTORY)->GetItem(equip[SLOT_SUB])); if(PItem == NULL){ return 0; } if(!PItem->IsShield()){ return 0; } return PItem->getShieldSize(); }
std::string JSONConfig::Impl::getNameOfRegister(const retdec_config::Object ®) const { // Each register has a name set in its storage. However, this name may be // just our internal LLVM IR name. To get the real name, we have to perform // another check. auto name = reg.getStorage().getRegisterName(); auto realReg = getConfigRegisterByName(name); if (!realReg) { return name; } auto realName = realReg->getStorage().getRegisterName(); return !realName.empty() ? realName : name; }
void SmsReader::check() { if (!m_atChat->isOpen()) { return; } if (m_storage.isEmpty()) { getStorage(); return; } SimpleAtCommand *cmd = new SimpleAtCommand("AT+CMGL=4"); cmd->setWaitDataTimeout(2000); connect(cmd, SIGNAL(isProcessed()), this, SLOT(onRequestSmsCommand())); m_atChat->addCommand(cmd); }