static int map_process(struct sol_flow_node *node, void *data, uint16_t port, uint16_t conn_id, const struct sol_flow_packet *packet) { struct drange_map_data *mdata = data; struct sol_drange in_value; double out_value; int r; r = sol_flow_packet_get_drange(packet, &in_value); SOL_INT_CHECK(r, < 0, r); if (mdata->use_input_range) { if (isgreaterequal(in_value.min, in_value.max)) { SOL_WRN("Invalid range: input max must to be bigger than min"); return -EINVAL; } r = _map(in_value.val, in_value.min, in_value.max, mdata->output.min, mdata->output.max, mdata->output_value.step, &out_value); } else r = _map(in_value.val, mdata->input.min, mdata->input.max, mdata->output.min, mdata->output.max, mdata->output_value.step, &out_value); SOL_INT_CHECK(r, < 0, r); mdata->output_value.val = out_value; return sol_flow_send_drange_packet(node, SOL_FLOW_NODE_TYPE_FLOAT_MAP__OUT__OUT, &mdata->output_value); }
/// Serialize to stream void Tracker::toStream(QDataStream& _os) const { PropertyMap _map; _map("center",center_); _map("direction",direction_); _os << _map; }
//----------------------------------------------------------------------------- void D3D11HardwarePixelBuffer::unlockImpl(void) { if(mUsage == HBU_STATIC) _unmapstagingbuffer(); else if(mUsage & HBU_DYNAMIC) { if(mCurrentLockOptions == HBL_READ_ONLY || mCurrentLockOptions == HBL_NORMAL || mCurrentLockOptions == HBL_WRITE_ONLY) { size_t sizeinbytes = D3D11Mappings::_getSizeInBytes(mParentTexture->getFormat(), mParentTexture->getWidth(), mParentTexture->getHeight()); PixelBox box; _map(mParentTexture->getTextureResource(), D3D11_MAP_WRITE_DISCARD, box); void *data = box.data; memcpy(data, mCurrentLock.data, sizeinbytes); // unmap the texture and the staging buffer _unmap(mParentTexture->getTextureResource()); _unmapstagingbuffer(false); } else _unmap(mParentTexture->getTextureResource()); } else _unmapstaticbuffer(); _genMipmaps(); }
//----------------------------------------------------------------------------- void *D3D11HardwarePixelBuffer::_mapstagingbuffer(D3D11_MAP flags) { if(!mStagingBuffer) createStagingBuffer(); if(flags == D3D11_MAP_READ_WRITE || flags == D3D11_MAP_READ || flags == D3D11_MAP_WRITE) { if(mLockBox.getHeight() == mParentTexture->getHeight() && mLockBox.getWidth() == mParentTexture->getWidth()) mDevice.GetImmediateContext()->CopyResource(mStagingBuffer, mParentTexture->getTextureResource()); else { D3D11_BOX dstBoxDx11 = OgreImageBoxToDx11Box(mLockBox); dstBoxDx11.front = 0; dstBoxDx11.back = mLockBox.getDepth(); unsigned int subresource = D3D11CalcSubresource(mSubresourceIndex, mLockBox.front, mParentTexture->getNumMipmaps()+1); mDevice.GetImmediateContext()->CopySubresourceRegion(mStagingBuffer, subresource, mLockBox.left, mLockBox.top, mSubresourceIndex, mParentTexture->getTextureResource(), subresource, &dstBoxDx11); } } else if(flags == D3D11_MAP_WRITE_DISCARD) flags = D3D11_MAP_WRITE; // stagingbuffer doesn't support discarding PixelBox box; _map(mStagingBuffer, flags, box); return box.data; }
void Water::_updatePaths() { auto reservoir = _d->overlay.selected.as<Reservoir>(); if( reservoir.isValid() ) { _d->ways.clear(); PathwayCondition wayCondition; auto fountains = reservoir->aquifer().overlays<Fountain>(); for( auto fountain : fountains ) { Pathway pathway = PathwayHelper::create( reservoir->pos(), fountain->pos(), wayCondition.bySomething(), Pathway::fourDirection ); if( pathway.isValid() ) _d->ways.push_back( { pathway.allTiles(), ColorList::red } ); } } auto fountain = _d->overlay.underMouse.as<Fountain>(); if( fountain.isValid() ) { _d->ways.clear(); PathwayCondition wayCondition; auto reservoirs = _map().rect( 10, fountain->pos() ).overlays<Reservoir>(); for( auto reservoir : reservoirs ) { Pathway pathway = PathwayHelper::create( reservoir->pos(), fountain->pos(), wayCondition.bySomething() ); if( pathway.isValid() ) _d->ways.push_back( { pathway.allTiles(), ColorList::blue } ); } } }
void Game::askGodToDo(Map & map, int & wait) { unsigned int x, y; int tBdstr = _god.makeStep((*this),x,y); //Ile zostanie zniszczonych if(tBdstr>0) { _printer.printMessage(GOD_DECIDE_TO_DO,cout); int result = putBlock(x,y,_map,PS_GOD_BLOCK); prepareWeights(_map); list<ElementData *> * path = testWeight(_map); if(path->size() > 0) { if(_map(x,y,DIM_WHO_TAB) != path->back()->operator [](DIM_WHO_TAB)) { _destroyedBlocks += destroyElements(path); _printer.printMessage(GOD_SAY_OMG,cout); _printer.makeBoomConsole(); } else _printer.printMessage(GOD_BLESS_YOU, cout); wait++; } delete path; } }
/// Write tuning to stream void Tuning::toStream(QDataStream& _os) const { PropertyMap _map; _map("color",color_) ("projector",projector_) ("warpGrid",warpGrid_) ("blendMask",blendMask_) ("outputDisabled",outputDisabled_) ("overlapOpacity",overlapOpacity_) ("colorCorrection",colorCorrection_) ("patches",patches_) ; _map("screenGeometry", screenGeometry()); _map("contentGeometry", contentGeometry()); _map("subScreenIndex", subScreenIndex_); _os << _map; }
vector<int> spiralOrder(vector<vector<int>>& matrix) { vector<int> result; int m = matrix.size(); int n = m > 0 ? matrix[0].size() : 0; if(m == 0 || n == 0) return result; vector<vector<int>> _map(matrix); for(int i = 0;i < m;++i) for(int j = 0;j < n;++j) _map[i][j] = 0; int x = 0; int y = 0; while(result.size() < m * n) { if(!_map[y][x]) { result.push_back(matrix[y][x]); _map[y][x] = 1; } // can right while(x < n - 1 && !_map[y][x + 1]) { x++; result.push_back(matrix[y][x]); _map[y][x] = 1; } // can down while(y < m - 1 && !_map[y + 1][x]) { y++; result.push_back(matrix[y][x]); _map[y][x] = 1; } // can left while(x > 0 && !_map[y][x - 1]) { x--; result.push_back(matrix[y][x]); _map[y][x] = 1; } // can up while(y > 0 && !_map[y - 1][x]) { y--; result.push_back(matrix[y][x]); _map[y][x] = 1; } } return result; }
void io::MMapInputStream::open(const std::string& fname, char* flags) { mLength = mOs.getSize(fname); // std::cout << mLength << std::endl; mFile = fopen(fname.c_str(), "r"); if (!mFile) throw sys::SystemException(FmtX("Failure while opening file: %s", fname.c_str())); _map(); }
/// Write transformation to stream void AffineTransform::toStream(QDataStream& _os) const { PropertyMap _map; _map("rotationEnabled",rotationEnabled_) ("rotation",rotation_) ("scaleEnabled",scaleEnabled_) ("scale",scale_) ("uniformScale",uniformScale_) ("uniformScaleEnabled",uniformScaleEnabled_) ("translationEnabled",translationEnabled_) ("translation",translation_); _os << _map; }
#include "clock.h" #include "driver.h" #include "events.h" #include "syslog.h" #include "cmdline.h" typedef struct generic_string_map_s { const char *item; int value; } generic_string_map_t; #define _map(x) { #x, LOG_ ## x } static generic_string_map_t options_table[] = { // Available Options _map( CONS ), _map( NDELAY ), _map( PERROR ), _map( PID ), // // Available Facilities _map( AUTH ), _map( AUTHPRIV ), _map( CRON ), _map( DAEMON ), _map( FTP ), _map( KERN ), _map( LOCAL0 ), _map( LOCAL1 ), _map( LOCAL2 ), _map( LOCAL3 ), _map( LOCAL4 ), _map( LOCAL5 ), _map( LOCAL6 ), _map( LOCAL7 ), _map( LPR ), _map( MAIL ), _map( NEWS ), _map( SYSLOG ), _map( USER ), _map( UUCP ), // // Available Levels _map( EMERG ), _map( ALERT ), _map( CRIT ), _map( ERR ), _map( WARNING ), _map( NOTICE ), _map( INFO ), _map( DEBUG ), { 0L, 0 } }; static int syslog_lookup_ident( const char *str ) { generic_string_map_t *ptr = options_table;
//----------------------------------------------------------------------------- PixelBox D3D11HardwarePixelBuffer::lockImpl(const Image::Box lockBox, LockOptions options) { // Check for misuse if(mUsage & TU_RENDERTARGET) OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "DirectX does not allow locking of or directly writing to RenderTargets. Use blitFromMemory if you need the contents.", "D3D11HardwarePixelBuffer::lockImpl"); mLockBox = lockBox; // Set extents and format // Note that we do not carry over the left/top/front here, since the returned // PixelBox will be re-based from the locking point onwards PixelBox rval(lockBox.getWidth(), lockBox.getHeight(), lockBox.getDepth(), mFormat); // Set locking flags according to options D3D11_MAP flags = D3D11_MAP_WRITE_DISCARD ; switch(options) { case HBL_NO_OVERWRITE: flags = D3D11_MAP_WRITE_NO_OVERWRITE; break; case HBL_NORMAL: flags = D3D11_MAP_READ_WRITE; break; case HBL_DISCARD: flags = D3D11_MAP_WRITE_DISCARD; break; case HBL_READ_ONLY: flags = D3D11_MAP_READ; break; case HBL_WRITE_ONLY: flags = D3D11_MAP_WRITE; break; default: break; }; size_t offset = 0; if(mUsage == HBU_STATIC || mUsage & HBU_DYNAMIC) { if(mUsage == HBU_STATIC || options == HBL_READ_ONLY || options == HBL_NORMAL || options == HBL_WRITE_ONLY) rval.data = _mapstagingbuffer(flags); else _map(mParentTexture->getTextureResource(), flags, rval); // calculate the offset in bytes offset = D3D11Mappings::_getSizeInBytes(rval.format, rval.left, rval.front); // add the offset, so the right memory will be changed //rval.data = static_cast<int*>(rval.data) + offset; } else { size_t sizeOfImage = rval.getConsecutiveSize(); mDataForStaticUsageLock = new int8[sizeOfImage]; rval.data = mDataForStaticUsageLock; } // save without offset mCurrentLock = rval; mCurrentLockOptions = options; // add the offset, so the right memory will be changed rval.data = static_cast<int*>(rval.data) + offset; return rval; }
result_t LruCache::put(v8::Local<v8::Object> map) { return _map(this, map, &LruCache::put); }
template <typename F, typename G> gf<block_index, std14::result_of_t<F(G)>> map(F &&f, gf_const_view<block_index, G> g) { return make_block_gf(get_block_names(g), _map(f, g.data())); }
result_t Map::put(v8::Local<v8::Object> map) { return _map(this, map, &Map::put); }
template <typename F, typename T> auto _map(F &&f, std::vector<std::vector<T>> &V) { std::vector<std::vector<std::result_of_t<F(T)>>> res; res.reserve(V.size()); for (auto &x : V) res.push_back(_map(f, x)); return res; }
result_t Redis::unpsub(v8::Local<v8::Object> map) { return _map(map, PUNSUBSCRIBE); }
static auto invoke(F &&f, G &&g) { return _map(std::forward<F>(f), std::forward<G>(g).data()); }
result_t HttpUploadCollection::set(v8::Local<v8::Object> map) { return _map(this, map, &HttpUploadCollection::set); }