Example #1
0
string parseCLArgs(int argc, char ** argv) {

	if( argc < 2 ) {
		printHelpInfo(argv[0]);
		exit(EXIT_FAILURE);
	}

	string recipe = argv[1];

	if( recipe == "bez-curve" ) {
		scene = new SceneBezCurve();
	} else if( recipe == "point-sprite") {
		scene = new ScenePointSprite();
	} else if( recipe == "quad-tess") {
		scene = new SceneQuadTess();
	} else if( recipe == "shade-wire" ) {
		scene = new SceneShadeWire();
	} else if( recipe == "silhouette") {
		scene = new SceneSilhouette();
	} else if( recipe == "tess-teapot" ) {
		scene = new SceneTessTeapot();
	} else if( recipe == "tess-teapot-depth" ) {
		scene = new SceneTessTeapotDepth();
	} else {
		printf("Unknown recipe: %s\n", recipe.c_str());
		printHelpInfo(argv[0]);
		exit(EXIT_FAILURE);
	}

	return recipe;
}
Example #2
0
string parseCLArgs(int argc, char ** argv) {

	if( argc < 2 ) {
		printHelpInfo(argv[0]);
		exit(EXIT_FAILURE);
	}

	string recipe = argv[1];

	if( recipe == "fire" ) {
		scene = new SceneFire();
	} else if( recipe == "particles") {
		scene = new SceneParticles();
	} else if( recipe == "particles-feedback") {
		scene = new SceneParticlesFeedback();
	} else if( recipe == "particles-instanced" ) {
		scene = new SceneParticlesInstanced();
	} else if( recipe == "smoke" ) {
		scene = new SceneSmoke();
	} else if( recipe == "wave" ) {
		scene = new SceneWave();
	} else {
		printf("Unknown recipe: %s\n", recipe.c_str());
		printHelpInfo(argv[0]);
		exit(EXIT_FAILURE);
	}

	return recipe;
}
Example #3
0
string parseCLArgs(int argc, char ** argv) {

	if( argc < 2 ) {
		printHelpInfo(argv[0]);
		exit(EXIT_FAILURE);
	}

	string recipe = argv[1];

	if( recipe == "ao" ) {
		scene = new SceneAo();
	} else if( recipe == "jitter") {
		scene = new SceneJitter();
	} else if( recipe == "pcf") {
		scene = new ScenePcf();
	} else if( recipe == "shadow-map" ) {
		scene = new SceneShadowMap();
        } else if( recipe == "shadow-volume" ) {
          scene = new SceneShadowVolume();
	} else {
		printf("Unknown recipe: %s\n", recipe.c_str());
		printHelpInfo(argv[0]);
		exit(EXIT_FAILURE);
	}

	return recipe;
}
Example #4
0
string parseCLArgs(int argc, char ** argv) {

    if( argc < 2 ) {
        printHelpInfo(argv[0]);
        exit(EXIT_FAILURE);
    }

    string recipe = argv[1];

    if( recipe == "directional" ) {
        scene = new SceneDirectional();
    } else if( recipe == "fog") {
        scene = new SceneFog();
    } else if( recipe == "multi-light") {
        scene = new SceneMultiLight();
    } else if( recipe == "per-frag" ) {
        scene = new ScenePerFragment();
    } else if( recipe == "spot") {
        scene = new SceneSpot();
    } else if( recipe == "toon" ) {
        scene = new SceneToon();
    } else {
        printf("Unknown recipe: %s\n", recipe.c_str());
        exit(EXIT_FAILURE);
    }

    return recipe;
}
Example #5
0
void readCmdline(const int argc, char* argv[]){

	int start = clock();		//计时器


	for (int arg_i = 0; arg_i < argc; arg_i++){
		m_cmdInfo.push_back(argv[arg_i]);
		m_cmdInfo.push_back(" ");
	}
	m_cmdInfo.push_back("\n");

	if (1 == argc){
		printHelpInfo();
		DisplayCMDUsage();
	}else if (argc == 2 && (stringProcess::bMatchingFix(argv[1], ".cfg", true, true) || stringProcess::bMatchingFix(argv[1], ".para", true, true))){
		readPara(argv);
	}else{
		//readCmd();
		cout << "Todo: 准备加入从命令行读取参数的运行方式" << endl;
		getchar();
	}

	int seconds = (clock() - start) / CLOCKS_PER_SEC;
	cout << "\t    == == == Time elapsed: " << seconds << " seconds. == == ==" << endl;
}
Example #6
0
string parseCLArgs(int argc, char ** argv) {

	if( argc < 2 ) {
		printHelpInfo(argv[0]);
		exit(EXIT_FAILURE);
	}

	string recipe = argv[1];

	if( recipe == "ads" ) {
		scene = new SceneADS();
	} else if( recipe == "diffuse") {
		scene = new SceneDiffuse();
	} else if( recipe == "discard") {
		scene = new SceneDiscard();
	} else if( recipe == "flat" ) {
		scene = new SceneFlat();
	} else if( recipe == "subroutine") {
		scene = new SceneSubroutine();
	} else if( recipe == "two-side" ) {
		scene = new SceneTwoSide();
	} else {
		printf("Unknown recipe: %s\n", recipe.c_str());
		exit(EXIT_FAILURE);
	}

	return recipe;
}
Example #7
0
string parseCLArgs(int argc, char ** argv) {

	if( argc < 2 ) {
		printHelpInfo(argv[0]);
		exit(EXIT_FAILURE);
	}

	string recipe = argv[1];

	if( recipe == "alpha-test" ) {
		scene = new SceneAlphaTest();
	} else if( recipe == "multi-tex") {
		scene = new SceneMultiTex();
	} else if( recipe == "normal-map") {
		scene = new SceneNormalMap();
	} else if( recipe == "proj-tex" ) {
		scene = new SceneProjTex();
	} else if( recipe == "reflect-cube") {
		scene = new SceneReflectCube();
	} else if( recipe == "refract-cube" ) {
		scene = new SceneRefractCube();
	} else if( recipe == "render-to-tex" ) {
		scene = new SceneRenderToTex();
	} else if( recipe == "sampler-obj" ) {
		scene = new SceneSamplerObj();
	} else if( recipe == "texture" ) {
		scene = new SceneTexture();
	} else {
		printf("Unknown recipe: %s\n", recipe.c_str());
		exit(EXIT_FAILURE);
	}

	return recipe;
}
Example #8
0
/**
 * main programme will be excuted.
 * By default, words are read from stdin and
 * added to hashtable before being printed out
 * alongside their frequencies to stdout.
 * @param argc an integer saying how many arguments
 *  there are argc for “argument count”
 * @param argv an array of strings in which the arguments
 *  are stored (argv for “argument vector ”).
 * @return integer 1 to indicate if the programme excuted successfully or not.
 */
int main(int argc, char *argv[]) {
    const char *optstring = "ht:c:deps:";
    char option;
    char word[256];
    int capacity = 113;

    FILE *infile = NULL;
    clock_t start, end;

    hashing_t method = LINEAR_P;

    double fillTime;
    double searchTime;

    int unknownWords = 0;
    int numOfSnapshot = 0;

    htable  h;
    char *fileToBeChecked = NULL;
    int withC = 0;
    int withE = 0;
    int withP = 0;
    int withS = 0;
    /*
     * Begin processing the argument from the command line
     */
    while ((option = getopt(argc, argv, optstring)) != EOF) {
        switch (option) {
            case 't':
                if (atoi(optarg) <= 0){
                    capacity = 113;
                }else {
                    capacity = primegt(atoi(optarg));
                }
                break;
            case 'd':
                method = DOUBLE_H;
                break;
            case 'c':
                withC = 1;
                fileToBeChecked = optarg;
                break;
            case 'e':
                withE = 1;
                break;
            case 's':
                numOfSnapshot = atoi(optarg);
                if (numOfSnapshot <= 0) {
                    numOfSnapshot = 10;
                }
                withS = 1;
                break;
            case 'p':
                withP = 1;
                break;
            case 'h':
                printHelpInfo();
                return EXIT_SUCCESS;
            default:
                printHelpInfo();
                return EXIT_FAILURE;
        }

    }

    h = htable_new(capacity, method);
    start = clock();

    while (getword(word, sizeof word, stdin) != EOF) {
        htable_insert(h, word);
    }

    end = clock();
    fillTime = (end-start)/(double)CLOCKS_PER_SEC;

    /* prints all the details of the table (-e argument)*/
    if (withE == 1) {
        htable_print_entire_table(h, stderr);
    }

    /* Checks the input file against a dictionary (-c <filename> argument)*/
    if (withC == 1) {
        /*open file and check if it is valid*/
        if (NULL == (infile = fopen(fileToBeChecked, "r"))) {
            fprintf(stderr, "Can't open file '%s' using mode r\n",
                    fileToBeChecked);
            htable_free(h);
            return EXIT_FAILURE;
        }
        start = clock();
        /*Get words from input file, and search for them in the dictionary*/
        while (getword(word, sizeof word, infile) != EOF) {
            /*If the word isn't in the dictionary*/
            if (htable_search(h, word) == 0) {
                printf("%s\n", word);
                unknownWords += 1;
            }
        }
        end = clock();
        fclose(infile);
        searchTime = (end-start)/(double)CLOCKS_PER_SEC;
        fprintf(stderr, "Fill time\t:%f\n", fillTime);
        fprintf(stderr, "Search time\t:%f\n", searchTime);
        fprintf(stderr, "Unknown words = %d\n", unknownWords);

        htable_free(h);
        return EXIT_SUCCESS;
    }


    /*Prints table stats (-p -s arguments)*/
    if (withP == 1 && withS == 0) {
        htable_print_stats(h, stdout, 10);
    } else if (withP == 1 && withS == 1) {
        htable_print_stats(h, stdout, numOfSnapshot);
    } else {
        htable_print(h, print_info);
    }

    htable_free(h);

    return EXIT_SUCCESS;
}
Example #9
0
int main(int argc, char* const* argv){

	const char* short_options = "hdc:s:";

	const struct option long_options[] = {
		{  "help",      0,   NULL,   'h'  },
		{  "daemon",      0,   NULL,   'd'  },
		{  "config",    1,   NULL,   'c'  },
		{  NULL,      0,    NULL,   0  }
	};

	int c;

	std::string type;
	std::string config;
	std::string spath;
	bool dm = false;

	while((c = getopt_long (argc, argv, short_options, long_options, NULL)) != -1){
		switch(c){
		case 'h':
			printHelpInfo();
			return 0;

		case 'd':
			dm = true;
			break;

		case 'c':
			config = optarg;
			break;		
		
		}			
	}

	if(!config.size()){
		printHelpInfo();
		return -1;
	}
	
	
	signal(SIGPIPE, SIG_IGN);
	signal(SIGCHLD, SIG_IGN);
	signal(SIGTSTP, SIG_IGN); 
	signal(SIGTTOU, SIG_IGN);
	signal(SIGTTIN, SIG_IGN);
	signal(SIGHUP,  SIG_IGN);
	signal(SIGQUIT,  SIG_IGN);
	signal(SIGURG,  SIG_IGN);
	signal(SIGTERM, signal_handler);

	if(dm){
		ef::daemonize();
	}


	gim::PushServer sv;
	
	g_pdb = &sv;

	int ret = sv.init(config);

	if(ret < 0){
		std::cout << "PushServer init fail\n";
		goto exit;
	}	

	sv.start();

	while(g_run){
		//std::cout << "running!\n";
		sleep(1);
	}

	sv.stop();
	
exit:

	return ret;
}
Example #10
0
int main(int argc, char* const* argv){


	const char* short_options = "hdc:s:";

	const struct option long_options[] = {
		{  "help",      0,   NULL,   'h'  },
		{  "daemon",      0,   NULL,   'd'  },
		{  "config",    1,   NULL,   'c'  },
		{  NULL,      0,    NULL,   0  }
	};

	int c;

	std::string type;
	std::string config;
	bool dm = false;

	while((c = getopt_long (argc, argv, short_options, long_options, NULL)) != -1){
		switch(c){
		case 'h':
			printHelpInfo();
			return 0;

		case 'd':
			dm = true;
			break;

		case 'c':
			config = optarg;
			break;		
		
		}			
	}

	if(!config.size()){
		printHelpInfo();
		return -1;
	}
	
	
	signal(SIGPIPE, SIG_IGN);
	signal(SIGCHLD, SIG_IGN);
	signal(SIGTSTP, SIG_IGN); 
	signal(SIGTTOU, SIG_IGN);
	signal(SIGTTIN, SIG_IGN);
	signal(SIGHUP,  SIG_IGN);
	signal(SIGQUIT,  SIG_IGN);
	signal(SIGURG,  SIG_IGN);
	signal(SIGTERM, signal_handler);

	if(dm){
		ef::daemonize();
	}

	int ret = 0;
	gim::ConnectServer s;
	g_pdb = &s;

	ret = s.init(config);

	if(ret < 0){
		std::cout << "ConnectServer init fail\n";
		return ret;
	}	

	ret = s.start();
	
	if(ret < 0){
		std::cout << "ConnectServer start fail\n";
	}

	s.free();

	return 0;
}