void TearDown() { //print_lmc_get_scene(); t_ilm_layer* layers = NULL; t_ilm_int numLayer=0; EXPECT_EQ(ILM_SUCCESS, ilm_getLayerIDs(&numLayer, &layers)); for (t_ilm_int i=0; i<numLayer; i++) { EXPECT_EQ(ILM_SUCCESS, ilm_layerRemove(layers[i])); }; free(layers); t_ilm_surface* surfaces = NULL; t_ilm_int numSurfaces=0; EXPECT_EQ(ILM_SUCCESS, ilm_getSurfaceIDs(&numSurfaces, &surfaces)); for (t_ilm_int i=0; i<numSurfaces; i++) { EXPECT_EQ(ILM_SUCCESS, ilm_surfaceRemove(surfaces[i])); }; free(surfaces); EXPECT_EQ(ILM_SUCCESS, ilm_commitChanges()); EXPECT_EQ(ILM_SUCCESS, ilmClient_destroy()); EXPECT_EQ(ILM_SUCCESS, ilm_destroy()); }
void TearDown() { //print_lmc_get_scene(); t_ilm_layer* layers = NULL; t_ilm_int numLayer=0; EXPECT_EQ(ILM_SUCCESS, ilm_getLayerIDs(&numLayer, &layers)); for (t_ilm_int i=0; i<numLayer; i++) { EXPECT_EQ(ILM_SUCCESS, ilm_layerRemove(layers[i])); }; free(layers); for (std::vector<iviSurface>::reverse_iterator it = iviSurfaces.rbegin(); it != iviSurfaces.rend(); ++it) { ivi_surface_destroy((*it).surface); } iviSurfaces.clear(); EXPECT_EQ(ILM_SUCCESS, ilm_commitChanges()); EXPECT_EQ(ILM_SUCCESS, ilm_destroy()); }
void TearDown() { ilm_destroy(); }
int main(int argc, char *argv[]) { ilmErrorTypes result = ILM_FAILED; t_ilm_layer layerid = (t_ilm_layer)LAYER_CHROMAKEY; t_ilm_surface surfaceid = (t_ilm_surface)SURFACE_CHROMAKEY; char* bitmapFile = NULL; int o; static const char opts[] = "f:c:h"; static const struct option longopts[] = { { "file", 1, NULL, 'f' }, { "color", 1, NULL, 'c' }, { "help", 1, NULL, 'h' }, { NULL, } }; unsigned int rgb[] = {255, 255, 255}; /* Default color key is 'White' */ while (o = getopt_long(argc, argv, opts, longopts, &o), o > 0) { switch (o) { case 'f': bitmapFile = optarg; break; case 'c': sscanf(optarg, "%d,%d,%d", &rgb[0], &rgb[1], &rgb[2]); break; case 'h': print_usage(); return 0; } } if (bitmapFile == NULL) { print_usage(); return -1; } printf("[INFO] bitmap file = %s\n", bitmapFile); printf("[INFO] color key = R(%d),G(%d),B(%d)\n", rgb[0], rgb[1], rgb[2]); /* signal handling */ signal(SIGINT, sigFunc); signal(SIGKILL, sigFunc); gRun = 1; memset(&g_wlContextStruct, 0x00, sizeof(g_wlContextStruct)); g_wlContextStruct.ctx_bmp = bmpaccessor_open(bitmapFile); if (NULL == g_wlContextStruct.ctx_bmp) { printf("Failed to create bmp accessor\n"); return -1; } do { createWLContext(); result = ilm_init(); if (ILM_SUCCESS == result) { printf("ilm_init success\n"); } else { printf("ilm_init failed\n"); break; } result = createILMAttribute(&layerid, &surfaceid, rgb); if (result != ILM_SUCCESS) { break; } t_ilm_layer layer[] = {1000, 2000, 3000, LAYER_CHROMAKEY}; ilm_displaySetRenderOrder(0, &layer[0], 4); ilm_commitChanges(); while(gRun) { drawImage(); } ilm_surfaceRemove(surfaceid); ilm_layerRemove(layerid); } while(0); ilm_destroy(); destroyWLContext(); bmpaccessor_close(g_wlContextStruct.ctx_bmp); return 0; }
CommandResult ExpressionInterpreter::interpretCommand(string userInput) { CommandResult result = CommandSuccess; string text; stringstream ss; ss << userInput; ExpressionList currentState; currentState.push_back(mpRoot); ExpressionList nextState; while (result == CommandSuccess && !ss.eof()) { ss >> text; transform(text.begin(), text.end(), text.begin(), ::tolower); ExpressionList::const_iterator iter = currentState.begin(); ExpressionList::const_iterator end = currentState.end(); for (; iter != end; ++iter) { Expression* expr = *iter; ExpressionList exprNextList = expr->getNextExpressionClosure(text); nextState.splice(nextState.end(), exprNextList); } if (nextState.size() > 0) { currentState = nextState; nextState.clear(); } else { mErrorText = "'" + text + "' not recognized."; result = CommandInvalid; } } //remove impossible expressions in the final state before checking for ambiguity nextState.clear(); ExpressionList::const_iterator iter = currentState.begin(); ExpressionList::const_iterator end = currentState.end(); for (; iter != end; ++iter) { Expression* expr = *iter; if (expr->isExecutable()) { nextState.push_back(expr); } else { ExpressionList children = expr->getNextExpressions(); bool flag = false; ExpressionList::const_iterator iter = children.begin(); ExpressionList::const_iterator end = children.end(); for (; iter != end; ++iter) { if ((*iter)->getName()[0] == '[') { flag = true; } } if (flag || children.size() == 0) { nextState.push_back(expr); } } } currentState = nextState; if (currentState.size() != 1) { mErrorText = "'" + text + "' ambiguous or incomplete."; result = CommandInvalid; } //run command if executable and non-ambiguous if (result == CommandSuccess) { Expression* expr = *(currentState.begin()); ExpressionList executables = expr->getClosureExecutables(false); if (executables.size() == 1) { ilmErrorTypes initResult = ilm_init(); if (ILM_SUCCESS != initResult) { mErrorText = ILM_ERROR_STRING(initResult); result = CommandExecutionFailed; } else { Expression* exec = executables.front(); exec->execute(); ilm_commitChanges(); ilm_destroy(); } } else if (executables.size() == 0) { mErrorText = "command is incomplete."; result = CommandIncomplete; } else { mErrorText = "command is ambiguous."; result = CommandIncomplete; } } return result; }