bool Databases::open(const Common::String &id, const Common::String &file) { if (_databases.contains(id)) { warning("Databases::open(): A database with the ID \"%s\" already exists", id.c_str()); return false; } Common::File dbFile; if (!dbFile.open(file)) { warning("Databases::open(): No such file \"%s\"", file.c_str()); return false; } dBase db; if (!db.load(dbFile)) { warning("Databases::open(): Failed loading database file \"%s\"", file.c_str()); return false; } _databases.setVal(id, Common::StringMap()); DBMap::iterator map = _databases.find(id); assert(map != _databases.end()); if (!buildMap(db, map->_value)) { warning("Databases::open(): Failed building a map for database \"%s\"", file.c_str()); _databases.erase(map); return false; } return true; }
void Engine::init() { /* Build the opencl kernel */ ocl->build(KERNEL_ENTRY); buildResult = ocl->buildLog(); buildMap(); }
void MapBuilder::buildAllMaps(int threads) { std::vector<BuilderThread*> _threads; BuilderThreadPool* pool = threads > 0 ? new BuilderThreadPool() : NULL; for (TileList::iterator it = m_tiles.begin(); it != m_tiles.end(); ++it) { uint32 mapID = it->first; if (!shouldSkipMap(mapID)) { if (threads > 0) pool->Enqueue(new MapBuildRequest(mapID)); else buildMap(mapID); } } for (int i = 0; i < threads; ++i) _threads.push_back(new BuilderThread(this, pool->Queue())); // Free memory for (std::vector<BuilderThread*>::iterator _th = _threads.begin(); _th != _threads.end(); ++_th) { (*_th)->wait(); delete *_th; } delete pool; }
/* * Select the appropriate conversion routine for unpacked data. * * NB: we assume that unpacked single channel data is directed * to the "packed routines. */ static int pickTileSeparateCase(TIFFRGBAImage* img) { tileSeparateRoutine put = 0; if (buildMap(img)) { switch (img->photometric) { case PHOTOMETRIC_RGB: switch (img->bitspersample) { case 8: if (!img->Map) { if (img->alpha == EXTRASAMPLE_ASSOCALPHA) put = putRGBAAseparate8bittile; else if (img->alpha == EXTRASAMPLE_UNASSALPHA) put = putRGBUAseparate8bittile; else put = putRGBseparate8bittile; } else put = putRGBseparate8bitMaptile; break; case 16: put = putRGBseparate16bittile; if (!img->Map) { if (img->alpha == EXTRASAMPLE_ASSOCALPHA) put = putRGBAAseparate16bittile; else if (img->alpha == EXTRASAMPLE_UNASSALPHA) put = putRGBUAseparate16bittile; } break; } break; } } return ((img->put.separate = put) != 0); }
//Main int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE); glutInitWindowSize(600,600); glutInitWindowPosition(0, 0); glutCreateWindow("Game of Life"); glutCallBacks(); initMenu(); glViewport( 0,0, 600, 600 ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glOrtho( 0.0, 600.0, 0.0, 600.0, 1.0, -1.0 ); glClear(GL_COLOR_BUFFER_BIT); buildMap(); timerRedisplay(0); glutMainLoop(); return(0); }
//Right Click Menu. void menu(int value) { if(value == 0) { clearMap(); } else if(value == 1) { paused = !paused; } else if(value == 2) { incrementSpeed(); } else if(value ==3) { decrementSpeed(); } else if(value == 4) { buildMap(); } else if(value == 5) { exit(0); } }
TextQuery(std::ifstream& infile) : file(new std::vector<std::string>()), map(new wordMap()) { std::string line; while(getline(infile, line)) file->push_back(line); buildMap(); }
int main(int argc, char ** argv) { (void) argc; std::ifstream input{argv[1]}; std::string data; std::getline(input, data); while(input) { auto map = buildMap(data); #if 1 std::cout << map.countLakes() << '\n'; #else auto toWrite = map._width; std::for_each(std::begin(map._data), std::end(map._data), [&toWrite, &map](char ch) { std::cout << ch; if((--toWrite) == 0) { toWrite = map._width; std::cout << '\n'; } }); std::cout << '\t' << map._lakes << "\n\n"; #endif std::getline(input, data); } return 0; }
void chunk::loadMap(int ChunkX, int ChunkZ) { //ÉèÖÃ×ø±ê chunk::ChunkX = ChunkX; chunk::ChunkZ = ChunkZ; buildMap(); }
void MapBuilder::buildAllMaps() { for (TileList::iterator it = m_tiles.begin(); it != m_tiles.end(); ++it) { int mapID = (*it).first; if (!shouldSkipMap(mapID)) { buildMap(mapID); } } }
void phase_two(char* path) { //using shortest path, create map from start to finish double map[MAP_SIZE][2]; buildMap(map, path); printMap(map); //Follow map to finish followMap(map); slowDown(); }
// note: zelda map size is 16x11 MapRoom::MapRoom( int x, int y, int z) : m_xSize(x), m_ySize(y), m_zSize(z) { m_map.resize( x*y*z ); buildMap( MAP_START_ZONE ); //buildMap( MAP_CAVE ); }
Foam::autoPtr<Foam::mapDistribute> Foam::backgroundMeshDecomposition::distributePoints ( List<PointType>& points ) const { labelList toProc(processorPosition(points)); autoPtr<mapDistribute> map(buildMap(toProc)); map().distribute(points); return map; }
void MapBuilder::WorkerThread() { while (1) { uint32 mapId; _queue.WaitAndPop(mapId); if (_cancelationToken) return; buildMap(mapId); } }
Foam::labelList Foam::backgroundMeshDecomposition::processorPosition ( const List<PointType>& pts ) const { DynamicList<label> toCandidateProc; DynamicList<point> testPoints; labelList ptBlockStart(pts.size(), -1); labelList ptBlockSize(pts.size(), -1); label nTotalCandidates = 0; forAll(pts, pI) { const pointFromPoint pt = topoint(pts[pI]); label nCandidates = 0; forAll(allBackgroundMeshBounds_, procI) { if (allBackgroundMeshBounds_[procI].contains(pt)) { toCandidateProc.append(procI); testPoints.append(pt); nCandidates++; } } ptBlockStart[pI] = nTotalCandidates; ptBlockSize[pI] = nCandidates; nTotalCandidates += nCandidates; } // Needed for reverseDistribute label preDistributionToCandidateProcSize = toCandidateProc.size(); autoPtr<mapDistribute> map(buildMap(toCandidateProc)); map().distribute(testPoints); List<bool> pointOnCandidate(testPoints.size(), false); // Test candidate points on candidate processors forAll(testPoints, tPI) { pointOnCandidate[tPI] = positionOnThisProcessor(testPoints[tPI]); }
vector<vector<string> > findLadders(string start, string end, unordered_set<string> &dict) { vector<vector<string> > results; queue<vector<int> > q; unordered_map<string, int> pos; vector<string> words; words.push_back(start); buildMap(dict, pos, words); vector<int> r; bool reached = false; r.push_back(0); q.push(r); vector<int> seperator; seperator.push_back(-1); q.push(seperator); while(!q.empty()){ vector<int> cur = q.front(); q.pop(); if(cur[0] == -1){ if(reached || q.empty()){ break; } q.push(seperator); continue; } string s = words[cur.back()]; for(int i = 0; i < s.size(); i++){ for(char c = 'a'; c <= 'z'; c++){ string tmp = s; tmp[i] = c; if(tmp == end){ results.push_back(genStr(cur, words, end)); reached = true; } else if(dict.count(tmp) > 0 && notUsed(cur, pos[tmp])){ cur.push_back(pos[tmp]); q.push(cur); cur.pop_back(); } } } } return results; }
int minCut(string s) { if (s.empty()) return 0; int n = s.size(); vector<vector<bool>> map = buildMap(s); vector<int> f(n + 1, INT_MAX); f[0] = -1; for (int i = 1; i <= n; ++ i) { for (int j = i - 1; j >= 0; -- j) { if (map[j][i - 1]) f[i] = min(f[i], f[j] + 1); } } return f[n]; }
int build_index(byte *text, ulong length, char *build_options, void **index) { lzindex *I; uint *ids,maxdepth; I = malloc(sizeof(lzindex)); text[length] = selectSymbol(text, length); // build index I->fwdtrie = buildLZTrie(text,&ids,text[length]); I->map = buildMap(I->fwdtrie,ids,&maxdepth); I->bwdtrie = buildRevTrie(I->fwdtrie,I->map,maxdepth,&ids); I->rmap = buildRMap(I->bwdtrie,ids); I->TPos = createPosition(I->fwdtrie, length, I->map); I->u = length; *index = I; // return index return 0; // no errors yet }
void MapBuilder::buildAllMaps() { for (TileList::iterator it = m_tiles.begin(); it != m_tiles.end(); ++it) { uint32 mapID = (*it).first; if (!shouldSkipMap(mapID,m_skipContinents,m_skipJunkMaps,m_skipBattlegrounds)) { buildMap(mapID, false); } } if (activated()) { Tile_Message_Block *finish_mb = new Tile_Message_Block(NULL); finish_mb->msg_type(ACE_Message_Block::MB_HANGUP); m_threadPool->putq(finish_mb); m_threadPool->wait(); } }
vector<vector<string>> findLadders(string start, string end, unordered_set<string> &dict) { // Start typing your C/C++ solution below // DO NOT write int main() function dict.insert(start); dict.insert(end); buildMap(dict); int src, dst; for (src = 0; start != vdict[src]; src++); for (dst = 0; end != vdict[dst]; dst++); buildReverseMap(src, dst); vector<vector<string>> result; vector<int> path; dfs(src, dst, path, result); return move(result); }
bool InputImpl::isKeyPressed(Keyboard::Key key) { if (!mapBuilt) buildMap(); // Sanity checks if (key < 0 || key >= sf::Keyboard::KeyCount) return false; // Convert to keycode xcb_keycode_t keycode = keycodeMap[key]; ScopedXcbPtr<xcb_generic_error_t> error(NULL); // Open a connection with the X server xcb_connection_t* connection = OpenConnection(); // Get the whole keyboard state ScopedXcbPtr<xcb_query_keymap_reply_t> keymap( xcb_query_keymap_reply( connection, xcb_query_keymap(connection), &error ) ); // Close the connection with the X server CloseConnection(connection); if (error) { err() << "Failed to query keymap" << std::endl; return false; } // Check our keycode return (keymap->keys[keycode / 8] & (1 << (keycode % 8))) != 0; }
void MapBuilder::buildAllMaps(int threads) { for (int i = 0; i < threads; ++i) { _workerThreads.push_back(std::thread(&MapBuilder::WorkerThread, this)); } m_tiles.sort([](MapTiles a, MapTiles b) { return a.m_tiles->size() > b.m_tiles->size(); }); for (TileList::iterator it = m_tiles.begin(); it != m_tiles.end(); ++it) { uint32 mapId = it->m_mapId; if (!shouldSkipMap(mapId)) { if (threads > 0) _queue.Push(mapId); else buildMap(mapId); } } while (!_queue.Empty()) { std::this_thread::sleep_for(std::chrono::milliseconds(1000)); } _cancelationToken = true; _queue.Cancel(); for (auto& thread : _workerThreads) { thread.join(); } }
CSMWorld::RegionMap::RegionMap (Data& data) : mData (data) { buildRegions(); buildMap(); QAbstractItemModel *regions = data.getTableModel (UniversalId (UniversalId::Type_Regions)); connect (regions, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)), this, SLOT (regionsAboutToBeRemoved (const QModelIndex&, int, int))); connect (regions, SIGNAL (rowsInserted (const QModelIndex&, int, int)), this, SLOT (regionsInserted (const QModelIndex&, int, int))); connect (regions, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)), this, SLOT (regionsChanged (const QModelIndex&, const QModelIndex&))); QAbstractItemModel *cells = data.getTableModel (UniversalId (UniversalId::Type_Cells)); connect (cells, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)), this, SLOT (cellsAboutToBeRemoved (const QModelIndex&, int, int))); connect (cells, SIGNAL (rowsInserted (const QModelIndex&, int, int)), this, SLOT (cellsInserted (const QModelIndex&, int, int))); connect (cells, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)), this, SLOT (cellsChanged (const QModelIndex&, const QModelIndex&))); }
bool TextureAtlas::create( GLuint* ahandle, int& width, int& height ) { if( internalTextures.size() < 1 ){ Debug::debug( Debug::GRAPHICS, "Textures is missing.\n" ); return false; } // Sort textures in buffer sort( internalTextures.begin(), internalTextures.end(), compareTextureProxies ); // Calculate texture positions and draw to texture if( !buildMap( width, height ) ){ Debug::debug( Debug::GRAPHICS, "Cannot build atlas map.\n" ); return false; } if( !build( ahandle, width, height ) ){ Debug::debug( Debug::GRAPHICS, "Cannot draw atlas.\n" ); return false; } // Push textures to render and clear array RenderManager::PushTextures( internalTextures, *ahandle ); clear_vector( &internalTextures ); return true; }
void newGame() { int i; int key; int accepted; player.x = 2; player.y = 2; player.level = 1; player.race = 0; player.is_dead = FALSE; player.avatar = "@"; player.slain = 0; player.xp = 0; player.xp_earned = 0; player.attack_bonus = 1; player.armor = 5; wclear(win); if (has_colors()) { init_pair(2, COLOR_WHITE, COLOR_BLUE); wbkgd(win, COLOR_PAIR(2) | A_BOLD); } else wbkgd(win, A_BOLD); wclear(win); box(win, ACS_VLINE, ACS_HLINE); refresh(); echo(); mvwaddstr(win, 2, 2, "Character Name (8 letter max): "); wgetnstr(win, player.player_name, 8); wrefresh(win); noecho(); mvwaddstr(win,3,2,"Race: "); for (i = 0; i < MAX_RACES; i++) { mvwprintw(win,4+i,4,"[%i] - %s",i+1,races[i].race_name); } player.race = wgetch(win); while (player.race < 49 || player.race > 51) { player.race = wgetch(win); } /* Convert the ASCII character number to an index by shifting down 49 (makes 1 = 0, 2 = 1, etc.) */ player.race -= 49; // Set up basic player data player.hp = (int)(races[player.race].start_hp + (player.level / 2)); // Do the stat rolls now. If the player doesn't like the // rolls with modifiers applied, they can do them over again accepted = 0; while (accepted == 0) { player.str = statRoll(races[player.race].max_str); player.def = statRoll(races[player.race].max_def); player.agi = statRoll(races[player.race].max_agi); wclear(win); box(win, ACS_VLINE, ACS_HLINE); mvwprintw(win,2,2,"%s - %s", player.player_name,races[player.race].race_name); mvwprintw(win,4,15,"STR: %i",player.str); mvwprintw(win,5,15,"DEF: %i",player.def); mvwprintw(win,6,15,"AGI: %i",player.agi); wattrset(win,A_REVERSE); mvwprintw(win,10,15,"Enter/Space: Roll Again\tA - Accept Character"); wattroff(win,A_REVERSE); flushinp(); wrefresh(win); noecho(); keypad(win, TRUE); raw(); key = wgetch(win); switch(key) { case 10: case 13: case ' ': case KEY_ENTER: accepted = 0; break; case 'a': case 'A': accepted = 1; break; } } clearPlay(); mvwprintw(win,4,15,"Generating Dungeon..."); wrefresh(win); buildMap(); /* Resize the main window so we can use it as the gameplay area. */ resize_window(win,20,60); drawPlayArea(); drawStatsArea(); gameLoop(); }
main::main(CkArgMsg *m) { CkGetChareID(&mainhandle); // CProxy_main M(mainhandle); int numObjs=-1, numMsgs=-1, msgSize=-1, distribution=-1, connectivity=-1, locality=-1, grainSize=-1, elapsePattern=-1, offsetPattern=-1, sendPattern=-1, pattern=-1, i; double granularity=-1.0; char grainString[20]; char *text; if(m->argc<10) { CkPrintf("Usage: asim <numObjs> <numMsgs> <msgSize> <distribution> <connectivitiy> <locality> <endTime> [ -g[f|m|c|z] | -t<granularity> ] <pattern>\n"); CkExit(); } numObjs = atoi(m->argv[1]); map = (int *)malloc(numObjs*sizeof(int)); numMsgs = atoi(m->argv[2]); msgSize = atoi(m->argv[3]); text = ""; if (msgSize == MIX_MS) { text = "MIXED"; } else if (msgSize == SMALL) { text = "SMALL"; } else if (msgSize == MEDIUM) { text = "MEDIUM"; } else if (msgSize == LARGE) { text = "LARGE"; } CkPrintf("asim run with: %d objects %d messages %s message size\n", numObjs, numMsgs, text); if (strcmp(m->argv[4], "RANDOM") == 0) distribution = RANDOM; else if (strcmp(m->argv[4], "IMBALANCED") == 0) distribution = IMBALANCED; else if (strcmp(m->argv[4], "UNIFORM") == 0) distribution = UNIFORM; else { CkPrintf("Invalid distribution type: %s\n", m->argv[4]); CkExit(); } if (strcmp(m->argv[5], "SPARSE") == 0) connectivity = SPARSE; else if (strcmp(m->argv[5], "HEAVY") == 0) connectivity = HEAVY; else if (strcmp(m->argv[5], "FULL") == 0) connectivity = FULL; else { CkPrintf("Invalid connectivity type: %s\n", m->argv[5]); CkExit(); } locality = atoi(m->argv[6]); strcpy(grainString, m->argv[8]); if (strcmp(grainString, "-gf") == 0) { grainSize = FINE; text = "FINE"; } else if (strcmp(grainString, "-gm") == 0) { grainSize = MEDIUM_GS; text = "MEDIUM"; } else if (strcmp(grainString, "-gc") == 0) { grainSize = COARSE; text = "COARSE"; } else if (strcmp(grainString, "-gz") == 0) { grainSize = MIX_GS; text = "MIXED"; } else if (strncmp(grainString, "-t", 2) == 0) granularity = atof(&(grainString[2])); CkPrintf("%s distribution %s connectivity %d%% locality %d endtime %s grainsize %f granularity\n", m->argv[4], m->argv[5], locality, atoi(m->argv[7]), text, granularity); pattern = atoi(m->argv[9]); elapsePattern = pattern / 100; pattern -= elapsePattern*100; offsetPattern = pattern / 10; pattern -= offsetPattern*10; sendPattern = pattern; CkPrintf(" %d elapsePattern %d offsetPattern %d sendPattern\n", elapsePattern, offsetPattern, sendPattern); #if USE_LONG_TIMESTAMPS long long endtime = atoll(m->argv[7]); if(endtime == -1) POSE_init(); else POSE_init(endtime); #else int endtime = atoll(m->argv[7]); if(endtime == -1) POSE_init(); else POSE_init(endtime); #endif // create all the workers WorkerData *wd; int dest, j; srand48(42); buildMap(numObjs, distribution); for (i=0; i<numObjs; i++) { wd = new WorkerData; dest = map[i]; wd->numObjs = numObjs; wd->numMsgs = numMsgs; wd->msgSize = msgSize; wd->distribution = distribution; wd->connectivity = connectivity; wd->locality = locality; wd->grainSize = grainSize; wd->elapsePattern = elapsePattern; wd->offsetPattern = offsetPattern; wd->sendPattern = sendPattern; wd->granularity = granularity; // compute elapseTimes, numSends, offsets, neighbors, numNbrs if (connectivity == SPARSE) wd->numNbrs = 4; else if (connectivity == HEAVY) wd->numNbrs = 25; else if (connectivity == FULL) wd->numNbrs = 100; if (elapsePattern == 1) for (j=0; j<5; j++) wd->elapseTimes[j] = (lrand48() % 2); else if (elapsePattern == 2) for (j=0; j<5; j++) wd->elapseTimes[j] = (lrand48() % 48) + 3; else if (elapsePattern == 3) for (j=0; j<5; j++) wd->elapseTimes[j] = (lrand48() % 50) + 51; else if (elapsePattern == 4) for (j=0; j<5; j++) wd->elapseTimes[j] = (lrand48() % 400) + 101; else if (elapsePattern == 5) for (j=0; j<5; j++) wd->elapseTimes[j] = (lrand48() % 500) + 501; if (offsetPattern == 1) for (j=0; j<5; j++) wd->offsets[j] = (lrand48() % 2); else if (offsetPattern == 2) for (j=0; j<5; j++) wd->offsets[j] = (lrand48() % 48) + 3; else if (offsetPattern == 3) for (j=0; j<5; j++) wd->offsets[j] = (lrand48() % 50) + 51; else if (offsetPattern == 4) for (j=0; j<5; j++) wd->offsets[j] = (lrand48() % 400) + 101; else if (offsetPattern == 5) for (j=0; j<5; j++) wd->offsets[j] = (lrand48() % 500) + 501; if (sendPattern == 1) for (j=0; j<5; j++) wd->numSends[j] = (lrand48()%numMsgs)/4; else if (sendPattern == 2) for (j=0; j<5; j++) wd->numSends[j] = (lrand48()%numMsgs)/3; else if (sendPattern == 3) for (j=0; j<5; j++) wd->numSends[j] = (lrand48()%numMsgs)/2; else if (sendPattern == 4) for (j=0; j<5; j++) wd->numSends[j] = (lrand48()%numMsgs); for (j=0; j<wd->numNbrs; j++) wd->neighbors[j] = getAnbr(numObjs, locality, dest); wd->Timestamp(0); //wd->dump(); if (distribution == RANDOM) (*(CProxy_worker *) &POSE_Objects)[i].insert(wd); else (*(CProxy_worker *) &POSE_Objects)[i].insert(wd, dest); } POSE_Objects.doneInserting(); }
int* CleverMonster::getMap(int x, int y) { return maps[y*mapsCountX + x] != NULL ? maps[y*mapsCountX + x] : buildMap(x, y); }
void Input(SDL_Event *e) { float deltaTime = 0.001f; static float step = 0.f; Vector3 Movement = InputAxis(e); Movement.normalise(); static float rot = 0; rot += 0.0005f; if (Axis(SDL_SCANCODE_C, SDL_SCANCODE_X) < 0) { bone.Unchild(); } skull.scale.x += Axis(SDL_SCANCODE_E, SDL_SCANCODE_Q) / skull.aabb.h * skull.speed * 5 * deltaTime * skull.aabb.h; skull.scale.y += Axis(SDL_SCANCODE_E, SDL_SCANCODE_Q) / skull.aabb.w * skull.speed * 5 * deltaTime * skull.aabb.w; skull.rotation += Axis(SDL_SCANCODE_D, SDL_SCANCODE_A) * 0.0004f; world.m11 += Axis(SDL_SCANCODE_PAGEUP, SDL_SCANCODE_PAGEDOWN) * 0.00004f; world.m22 += Axis(SDL_SCANCODE_PAGEUP, SDL_SCANCODE_PAGEDOWN) * 0.00004f; Camera.x += Axis(SDL_SCANCODE_J, SDL_SCANCODE_L) * skull.speed * deltaTime * 2; Camera.y += Axis(SDL_SCANCODE_I, SDL_SCANCODE_K) * skull.speed * deltaTime * 2; //skull.localMatrix.setRotateZ(rot); //skull.position = skull.position + Movement * skull.speed * deltaTime * 2; if (KeyDown(SDL_SCANCODE_LEFT) && moved) { // Player if (moved) { step += 0.00001; skull.position.x -= UNIT * world.m11; // * deltaTime; } //enemyMove(); moved = false; } if (KeyDown(SDL_SCANCODE_RIGHT) && moved) { // Player if (moved) { step += 0.00001; skull.position.x += UNIT * world.m11; // * deltaTime; } //enemyMove(); moved = false; } if (KeyDown(SDL_SCANCODE_UP) && moved) { // Player if (moved) { step += 0.00001; skull.position.y -= UNIT * world.m11; // * deltaTime; } //enemyMove(); moved = false; } if (KeyDown(SDL_SCANCODE_DOWN) && moved) { // Playre if (moved) { step += 0.00001; skull.position.y += UNIT * world.m11; // * deltaTime; } //enemyMove(); moved = false; } if (!moved && (KeyUp(SDL_SCANCODE_UP) && KeyUp(SDL_SCANCODE_DOWN) && KeyUp(SDL_SCANCODE_LEFT) && KeyUp(SDL_SCANCODE_RIGHT))) { step = 0; moved = true; } if (KeyDown(SDL_SCANCODE_R)) { buildMap(); } }
/* * Select the appropriate conversion routine for packed data. */ static int pickTileContigCase(TIFFRGBAImage* img) { tileContigRoutine put = 0; if (buildMap(img)) { switch (img->photometric) { case PHOTOMETRIC_RGB: switch (img->bitspersample) { case 8: if (!img->Map) { if (img->alpha == EXTRASAMPLE_ASSOCALPHA) put = putRGBAAcontig8bittile; else if (img->alpha == EXTRASAMPLE_UNASSALPHA) put = putRGBUAcontig8bittile; else put = putRGBcontig8bittile; } else put = putRGBcontig8bitMaptile; break; case 16: put = putRGBcontig16bittile; if (!img->Map) { if (img->alpha == EXTRASAMPLE_ASSOCALPHA) put = putRGBAAcontig16bittile; else if (img->alpha == EXTRASAMPLE_UNASSALPHA) put = putRGBUAcontig16bittile; } break; } break; case PHOTOMETRIC_SEPARATED: if (img->bitspersample == 8) { if (!img->Map) put = putRGBcontig8bitCMYKtile; else put = putRGBcontig8bitCMYKMaptile; } break; case PHOTOMETRIC_PALETTE: switch (img->bitspersample) { case 8: put = put8bitcmaptile; break; case 4: put = put4bitcmaptile; break; case 2: put = put2bitcmaptile; break; case 1: put = put1bitcmaptile; break; } break; case PHOTOMETRIC_MINISWHITE: case PHOTOMETRIC_MINISBLACK: switch (img->bitspersample) { case 8: put = putgreytile; break; case 4: put = put4bitbwtile; break; case 2: put = put2bitbwtile; break; case 1: put = put1bitbwtile; break; } break; case PHOTOMETRIC_YCBCR: if (img->bitspersample == 8) put = initYCbCrConversion(img); break; } } return ((img->put.contig = put) != 0); }
map<string, Command*> buildMap() { map<string, Command*> map; map[COMMAND_HELP] = dynamic_cast<Command*>(new HelpCommand()); map[COMMAND_RESET] = dynamic_cast<Command*>(new ResetCommand()); map[COMMAND_SET_ITERATION] = dynamic_cast<Command*>(new SetIterationCommand()); map[COMMAND_SET_ESCAPE_RADIUS] = dynamic_cast<Command*>(new SetEscapeRadiusCommand()); map[COMMAND_GET_POSITION] = dynamic_cast<Command*>(new GetPositionCommand()); map[COMMAND_SAVE_POSITIONF] = dynamic_cast<Command*>(new SavePositionFCommand()); map[COMMAND_SAVE_POSITION] = dynamic_cast<Command*>(new SavePositionCommand()); map[COMMAND_LOAD_POSITION] = dynamic_cast<Command*>(new LoadPositionCommand()); map[COMMAND_LOAD_POSITIONF] = dynamic_cast<Command*>(new LoadPositionFCommand()); return map; } map<string, Command*> Parser::commands = buildMap(); CommandResult Parser::parse(const string& in){ CommandResult result; map<string, Command*>::iterator it; string command; vector<string> args = vector<string>(); size_t firstSpace; result.error = true; result.out = "Invalid input, must be a valid command"; if ( in.empty() ) return result; command = Utility::trim(in);