• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ desc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中desc函数的典型用法代码示例。如果您正苦于以下问题:C++ desc函数的具体用法?C++ desc怎么用?C++ desc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了desc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char** argv) {
  size_t parent_pid = getppid();
  // Options
  std::string program_name = argv[0];
  std::string server_address;

  // Handle server commandline options
  boost::program_options::variables_map vm;
  po::options_description desc("Allowed options");
  desc.add_options()
      ("help", "Print this help message.")
      ("server_address", 
       po::value<std::string>(&server_address)->implicit_value(server_address),
       "This must be a valid ZeroMQ endpoint and "
                         "is the address the server listens on");

  po::positional_options_description positional;
  positional.add("server_address", 1);

  // try to parse the command line options
  try {
    po::command_line_parser parser(argc, argv);
    parser.options(desc);
    parser.positional(positional);
    po::parsed_options parsed = parser.run();
    po::store(parsed, vm);
    po::notify(vm);
  } catch(std::exception& error) {
    std::cout << "Invalid syntax:\n"
              << "\t" << error.what()
              << "\n\n" << std::endl
              << "Description:"
              << std::endl;
    print_help(program_name, desc);
    return 1;
  }

  if(vm.count("help")) {
    print_help(program_name, desc);
    return 0;
  }

  try {
    graphlab::lambda::init_python(argc, argv);
  } catch (const std::string& error) {
    logstream(LOG_WARNING) << "Fail initializing python: " << error << std::endl;
    exit(-1);
  }

  // construct the server
  cppipc::comm_server server(std::vector<std::string>(), "", server_address);

  server.register_type<graphlab::lambda::lambda_evaluator_interface>([](){
                                            return new graphlab::lambda::pylambda_evaluator();
                                          });
  server.register_type<graphlab::lambda::graph_lambda_evaluator_interface>([](){
                                            return new graphlab::lambda::graph_pylambda_evaluator();
                                          });

  server.start();

#ifdef HAS_TCMALLOC
  graphlab::thread memory_release_thread;
  memory_release_thread.launch(memory_release_loop);
#endif

  while(1) {
    sleep(5);
    // has parent_pid and parent_pid 
    if (parent_pid != 0 && kill(parent_pid, 0) == -1) {
      break;
    }

  }

#ifdef HAS_TCMALLOC
  stop_memory_release_thread = true;
  memory_release_cond.signal();
  memory_release_thread.join();
#endif

}
开发者ID:Hannah1999,项目名称:Dato-Core,代码行数:82,代码来源:pylambda_worker.cpp


示例2: suspend

    threads::thread_state_ex_enum suspend(
        util::steady_time_point const& abs_time,
        util::thread_description const& description, error_code& ec)
    {
        // schedule a thread waking us up at_time
        threads::thread_self& self = threads::get_self();
        threads::thread_id_type id = threads::get_self_id();

        // handle interruption, if needed
        threads::interruption_point(id, ec);
        if (ec) return threads::wait_unknown;

        // let the thread manager do other things while waiting
        threads::thread_state_ex_enum statex = threads::wait_unknown;

        {
#ifdef HPX_HAVE_VERIFY_LOCKS
            // verify that there are no more registered locks for this OS-thread
            util::verify_no_locks();
#endif
#ifdef HPX_HAVE_THREAD_DESCRIPTION
            detail::reset_lco_description desc(id, description, ec);
#endif
#ifdef HPX_HAVE_THREAD_BACKTRACE_ON_SUSPENSION
            detail::reset_backtrace bt(id, ec);
#endif
            threads::thread_id_type timer_id = threads::set_thread_state(id,
                abs_time, threads::pending, threads::wait_timeout,
                threads::thread_priority_boost, ec);
            if (ec) return threads::wait_unknown;

            // suspend the HPX-thread
            statex = self.yield(threads::suspended);

            if (statex != threads::wait_timeout)
            {
                error_code ec(lightweight);    // do not throw
                threads::set_thread_state(timer_id,
                    threads::pending, threads::wait_abort,
                    threads::thread_priority_boost, ec);
            }
        }

        // handle interruption, if needed
        threads::interruption_point(id, ec);
        if (ec) return threads::wait_unknown;

        // handle interrupt and abort
        if (statex == threads::wait_abort) {
            std::ostringstream strm;
            strm << "thread(" << threads::get_self_id() << ", "
                  << threads::get_thread_description(id)
                  << ") aborted (yield returned wait_abort)";
            HPX_THROWS_IF(ec, yield_aborted, "suspend_at",
                strm.str());
        }

        if (&ec != &throws)
            ec = make_success_code();

        return statex;
    }
开发者ID:AALEKH,项目名称:hpx,代码行数:62,代码来源:thread_helpers.cpp


示例3: main

int main(int argc, char* argv[]) {
    try {
        po::options_description desc( "Options" );
        desc.add_options()
            ( "help,h", "Show detailed help." )
			( "options,p", "Show parameter information." )
			( "version,p", "Show version information." )
			( "input-file,i", po::value<std::vector<std::string> >(), "Define file(s) for the convertion input." )
			( "input-type,I", po::value<std::vector<std::string> >(), "Define file type(s) for automatic conversion of files in the working directory." )
			( "output-file,o", po::value<std::string>(), "Define file for the convertion output." )
			( "noheader,h", "Disable adding of header support defines." )
            ( "const,C", "Define array as const." )
			( "respectcase,r", "Disable converting file types into lower case." )
			( "wxnone,w", "Disable adding of wxWidgets support macro's." )
			( "wxheader,W", po::value<std::string>()->default_value( "wx/wx.h" ), "Select the header that includes wxWidgets (precompiled header?)." )
			( "appendtype,t", "Add the file type at the end of the identifier (myimage_png)." )
			( "text,T", "Disable binary output and use text output, converts feed codes to systems defaults." )
          ( "silent", "No console output except errors")
		;

        po::positional_options_description posdesc;
        posdesc.add( "input-file", -1 );

        po::variables_map opt;
        po::store( po::command_line_parser( argc, argv ).options( desc ).positional( posdesc ).run(), opt );
//		po::store( po::parse_config_file( fs::ifstream( fs::path( "default.cfg" ) ), desc ), opt );
        po::notify( opt );

//		std::cout << WXINCLUDE_INFO << std::endl;

		/* Show options when requested */
        if ( opt.count( "options" ) ) {
			std::cout << desc << std::endl << std::endl;
            exit( 0 );
        }

		/* Show help when requested */
        if ( opt.count( "help" ) ) {
			std::cout << WXINCLUDE_HELP;
			std::cout << std::endl << desc << std::endl << std::endl;
            exit( 0 );
        }

		/* Show version when requested */
        if ( opt.count( "version" ) ) {
			std::cout << WXINCLUDE_VERSION << std::endl;
            exit( 0 );
        }

        bool silent = opt.count( "silent" );

		/* Process */
        if ( opt.count( "input-file" ) || opt.count( "input-type" ) ) {
			if ( opt.count( "output-file" ) ) {	
				/* Create timer */
				boost::timer timer;

				/* Create output file */
				std::string headername( opt[ "output-file" ].as<std::string>() );

				fs::path outputpath( headername );
				fs::ofstream output( outputpath, std::ios::out | std::ios::trunc );

				/* Use buffer */
				char outbuffer[BUFFER_SIZE];
				output.rdbuf()->pubsetbuf( outbuffer, BUFFER_SIZE );

//				if ( !opt.count( "text" ) )
//					output.setf( std::ios::binary );

				if ( !output )
					throw std::runtime_error( "Failed to create output file!" );

				/* Show status */
                if (!silent)
                  std::cout << "Build  : file '" << outputpath.leaf() << "'..." << std::endl;

				/* Get base name of file */
				headername = fs::basename( outputpath );

				/* Data string stream */
				std::ostringstream data;

				/* Write header start when wanted */
				if ( !opt.count( "noheader" ) )
					defineheader_start( data, headername, opt.count( "wxnone" ) ? false : true, opt.count( "const" ) ? true : false );

				/* Get defined or else default wx header */
				std::string includename( opt[ "wxheader" ].as<std::string>() );

				/* Write macros when wanted */
				if ( !opt.count( "wxnone" ) )
					definemacros( data, includename, opt[ "wxheader" ].defaulted() );

				/* Common input buffer */
				char inbuffer[BUFFER_SIZE];

				/* Process input files based on provided list */
				if ( opt.count( "input-file" ) ) {
					std::vector<std::string> files( opt[ "input-file" ].as<std::vector<std::string> >() );
//.........这里部分代码省略.........
开发者ID:ArkBriar,项目名称:rlvm,代码行数:101,代码来源:wxInclude.cpp


示例4: PreprocessTransferFreenect

void PreprocessTransferFreenect(libusb_transfer* transfer, const int read)
{
	fnusb_isoc_stream* xferstrm = (fnusb_isoc_stream*)transfer->user_data;
	freenect_device* dev = xferstrm->parent->parent;
	packet_stream* pktstrm = (transfer->endpoint == 0x81) ? &dev->video : &dev->depth;

	// Kinect Camera Frame Packed Header:
	struct pkt_hdr
	{
		uint8_t magic[2];
		uint8_t pad;
		uint8_t flag;
		uint8_t unk1;
		uint8_t seq;
		uint8_t unk2;
		uint8_t unk3;
		uint32_t timestamp;
	};  // 12 bytes

	//packet sizes:
	//          first  middle  last
	// Bayer    1920    1920    24
	// IR       1920    1920  1180
	// YUV422   1920    1920    36
	// Depth    1760    1760  1144
	const unsigned int pktlen = sizeof(pkt_hdr) + pktstrm->pkt_size;
	const unsigned int pktend = sizeof(pkt_hdr) + pktstrm->last_pkt_size;

	unsigned int remaining (read);
	unsigned int leftover (transfer->length);
	unsigned char* pktbuffer (transfer->buffer);
	const int pkts (transfer->num_iso_packets);
	for (int i=0; i<pkts; ++i)
	{
		const pkt_hdr& header (*(pkt_hdr*)pktbuffer);
		libusb_iso_packet_descriptor& desc (transfer->iso_packet_desc[i]);
		if ((header.magic[0] == 'R') && (header.magic[1] == 'B'))
		{
			switch(header.flag & 0x0F)
			{
			case 0x01 : // begin
			case 0x02 : // middle
				desc.actual_length = __min(remaining, pktlen);
				break;
			case 0x05 : // final
				desc.actual_length = __min(remaining, pktend);
				break;
			default :
				fprintf(stdout, "0x%02X\n", header.flag);
				break;
			}
		}
		else
		{
			desc.actual_length = 0;
		}
		remaining -= desc.actual_length;
		pktbuffer += desc.length;   // a.k.a: += 1920
		leftover  -= desc.length;   // a.k.a: -= 1920
	}

	if (remaining > 0)
	{
		fprintf(stdout, "%d remaining out of %d\n", remaining, read);
		if (remaining == read)
		{
		}
	}
}
开发者ID:CFC-Media-Lab,项目名称:unification,代码行数:69,代码来源:libusbemu.cpp


示例5: main

int main(int argc, char** argv)
{
	/* ARG PARSER *****************************************************/
	std::string fn_rules;
	std::string fn_bary;
	std::string fn_dev;
	std::string fn_out;

	boostPO::variables_map vm;
	boostPO::options_description desc("Allowed options");
	desc.add_options()
		("help,h",
		 "produce help message")
		("rule,r",
		 boostPO::value<std::string>(&fn_rules)->required(),
		 "REQUIRED | Subdivision rule filename")
		("bary,b",
		 boostPO::value<std::string>(&fn_bary),
		 "Barycenter offset filename (for each rule id)")
		("dev,d",
		 boostPO::value<std::string>(&fn_dev),
		 "Offset filename (for each structural indices)")
		("out,o",
		 boostPO::value<std::string>(&fn_out),
		 "Output filename")
		;

	try
	{
		boostPO::store(
				boostPO::command_line_parser(argc, argv).
				options(desc).run(), vm);
		boostPO::notify(vm);
	}
	catch(boost::program_options::error& e)
	{
		std::cerr << e.what() << std::endl;
		std::cout << desc << "\n";
		exit(EXIT_FAILURE);
	}

	if(vm.count("help"))
	{
		std::cout << desc << "\n";
		exit(EXIT_SUCCESS);
	}

	/* PROG ***********************************************************/
	Sampler sampler(fn_rules, fn_bary, fn_dev);
	/*
	WriterFilePts write(fn_out);
	/*/
	WriterEmpty write;
	//*/
	char ans;
	float density = 2;
	unsigned short int seed = 0;
	float spaceScale = 0.21;
	while(true)
	{
		std::cout << "=================================" << std::endl;
		std::cout << "? Generate a distribution (Y/n) ? ";
		if( std::cin.peek() == '\n' ) ans='y';
		else if( !(std::cin >> ans) ) break;
		std::cin.ignore();
		if( std::cin.fail() || ans=='n' || ans=='N') break;

		std::cout << "? set initial seed [0-" << sampler.tiling().ruleSize()-1 << "] (" << ++seed << "): ";
		if( std::cin.peek() == '\n' );
		else if( !(std::cin >> seed) ) break;
		std::cin.ignore();

		std::cout << "? set final density [0-inf] (" << density << "): ";
		if( std::cin.peek() == '\n' );
		else if( !(std::cin >> density) ) break;
		std::cin.ignore();

		std::cout << "? set boundary (" << spaceScale << "): ";
		if( std::cin.peek() == '\n' );
		else if( !(std::cin >> spaceScale) ) break;
		std::cin.ignore();

		sampler.generateUniform(density, -1, write, seed, spaceScale);
	}
}
开发者ID:fwachtel,项目名称:sampler,代码行数:85,代码来源:cli.cpp


示例6: UHD_SAFE_MAIN

int UHD_SAFE_MAIN(int argc, char *argv[]){
    uhd::set_thread_priority_safe();

    //variables to be set by po
    std::string args, file, ant, subdev, ref;
    size_t total_num_samps;
    double rate, freq, gain, bw;
    std::string addr, port;

    //setup the program options
    po::options_description desc("Allowed options");
    desc.add_options()
        ("help", "help message")
        ("args", po::value<std::string>(&args)->default_value(""), "multi uhd device address args")
        ("nsamps", po::value<size_t>(&total_num_samps)->default_value(1000), "total number of samples to receive")
        ("rate", po::value<double>(&rate)->default_value(100e6/16), "rate of incoming samples")
        ("freq", po::value<double>(&freq)->default_value(0), "rf center frequency in Hz")
        ("gain", po::value<double>(&gain)->default_value(0), "gain for the RF chain")
        ("ant", po::value<std::string>(&ant), "antenna selection")
        ("subdev", po::value<std::string>(&subdev), "subdevice specification")
        ("bw", po::value<double>(&bw), "analog frontend filter bandwidth in Hz")
        ("port", po::value<std::string>(&port)->default_value("7124"), "server udp port")
        ("addr", po::value<std::string>(&addr)->default_value("192.168.1.10"), "resolvable server address")
        ("ref", po::value<std::string>(&ref)->default_value("internal"), "reference source (internal, external, mimo)")
        ("int-n", "tune USRP with integer-N tuning")
    ;
    po::variables_map vm;
    po::store(po::parse_command_line(argc, argv, desc), vm);
    po::notify(vm);

    //print the help message
    if (vm.count("help")){
        std::cout << boost::format("UHD RX to UDP %s") % desc << std::endl;
        return ~0;
    }

    //create a usrp device
    std::cout << std::endl;
    std::cout << boost::format("Creating the usrp device with: %s...") % args << std::endl;
    uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(args);
    std::cout << boost::format("Using Device: %s") % usrp->get_pp_string() << std::endl;

    //Lock mboard clocks
    usrp->set_clock_source(ref);

    //set the rx sample rate
    std::cout << boost::format("Setting RX Rate: %f Msps...") % (rate/1e6) << std::endl;
    usrp->set_rx_rate(rate);
    std::cout << boost::format("Actual RX Rate: %f Msps...") % (usrp->get_rx_rate()/1e6) << std::endl << std::endl;

    //set the rx center frequency
    std::cout << boost::format("Setting RX Freq: %f MHz...") % (freq/1e6) << std::endl;
    uhd::tune_request_t tune_request(freq);
    if(vm.count("int-n")) tune_request.args = uhd::device_addr_t("mode_n=integer");
    usrp->set_rx_freq(tune_request);
    std::cout << boost::format("Actual RX Freq: %f MHz...") % (usrp->get_rx_freq()/1e6) << std::endl << std::endl;

    //set the rx rf gain
    std::cout << boost::format("Setting RX Gain: %f dB...") % gain << std::endl;
    usrp->set_rx_gain(gain);
    std::cout << boost::format("Actual RX Gain: %f dB...") % usrp->get_rx_gain() << std::endl << std::endl;

    //set the analog frontend filter bandwidth
    if (vm.count("bw")){
        std::cout << boost::format("Setting RX Bandwidth: %f MHz...") % (bw/1e6) << std::endl;
        usrp->set_rx_bandwidth(bw);
        std::cout << boost::format("Actual RX Bandwidth: %f MHz...") % (usrp->get_rx_bandwidth()/1e6) << std::endl << std::endl;
    }

    //set the antenna
    if (vm.count("ant")) usrp->set_rx_antenna(ant);

    boost::this_thread::sleep(boost::posix_time::seconds(1)); //allow for some setup time

    //Check Ref and LO Lock detect
    std::vector<std::string> sensor_names;
    sensor_names = usrp->get_rx_sensor_names(0);
    if (std::find(sensor_names.begin(), sensor_names.end(), "lo_locked") != sensor_names.end()) {
        uhd::sensor_value_t lo_locked = usrp->get_rx_sensor("lo_locked",0);
        std::cout << boost::format("Checking RX: %s ...") % lo_locked.to_pp_string() << std::endl;
        UHD_ASSERT_THROW(lo_locked.to_bool());
    }
    sensor_names = usrp->get_mboard_sensor_names(0);
    if ((ref == "mimo") and (std::find(sensor_names.begin(), sensor_names.end(), "mimo_locked") != sensor_names.end())) {
        uhd::sensor_value_t mimo_locked = usrp->get_mboard_sensor("mimo_locked",0);
        std::cout << boost::format("Checking RX: %s ...") % mimo_locked.to_pp_string() << std::endl;
        UHD_ASSERT_THROW(mimo_locked.to_bool());
    }
    if ((ref == "external") and (std::find(sensor_names.begin(), sensor_names.end(), "ref_locked") != sensor_names.end())) {
        uhd::sensor_value_t ref_locked = usrp->get_mboard_sensor("ref_locked",0);
        std::cout << boost::format("Checking RX: %s ...") % ref_locked.to_pp_string() << std::endl;
        UHD_ASSERT_THROW(ref_locked.to_bool());
    }

    //create a receive streamer
    uhd::stream_args_t stream_args("fc32"); //complex floats
    uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args);

    //setup streaming
    uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE);
//.........这里部分代码省略.........
开发者ID:211217613,项目名称:uhd,代码行数:101,代码来源:rx_samples_to_udp.cpp


示例7: main

int main(int argc, char **argv)
{
	// RNGs
	RNG rng(0);
	RNG rng2(1);

	/*
	 **********************************************************************
	 * Print program information
	 **********************************************************************
	 */
	std::cout << "Psychopath v" << VERSION_MAJOR << "." << VERSION_MINOR << "." << VERSION_PATCH;
#ifdef DEBUG
	std::cout << " (DEBUG build)";
#endif
	std::cout << std::endl;

#ifdef DEBUG
	std::cout << std::endl << "Struct sizes:" << std::endl;
	std::cout << "\tvoid*: " << sizeof(void*) << std::endl;
	std::cout << "\tVec3: " << sizeof(Vec3) << std::endl;
	std::cout << "\tBBox: " << sizeof(BBox) << std::endl;
	std::cout << "\tRay: " << sizeof(Ray) << std::endl;
	std::cout << "\tIntersection: " << sizeof(Intersection) << std::endl;
	std::cout << "\tPotentialInter: " << sizeof(PotentialInter) << std::endl;
	std::cout << "\tBVH::Node: " << sizeof(BVH::Node) << std::endl;
#endif


	/*
	 **********************************************************************
	 * Command-line options.
	 **********************************************************************
	 */
	int spp = SPP;
	int spp_max = SPP;
	float variance_max = -1.0f;
	int threads = std::thread::hardware_concurrency();
	std::string output_path = "default.png";
	std::string input_path = "";
	Resolution resolution(XRES, YRES);

	// Define them
	BPO::options_description desc("Allowed options");
	desc.add_options()
	("help,h", "Print this help message")
	("scenefile,i", BPO::value<std::string>(), "Input scene file")
	("spp,s", BPO::value<int>(), "Number of samples to take per pixel")
	("sppmax,m", BPO::value<int>(), "Max number of samples to take per pixel")
	("variance,v", BPO::value<float>(), "Max image variance")
	("threads,t", BPO::value<int>(), "Number of threads to render with")
	("output,o", BPO::value<std::string>(), "The PNG file to render to")
	("nooutput,n", "Don't save render (for timing tests)")
	("resolution,r", BPO::value<Resolution>()->multitoken(), "The resolution to render at, e.g. 1280 720")
	;

	// Collect them
	BPO::variables_map vm;
	BPO::store(BPO::parse_command_line(argc, argv, desc), vm);
	BPO::notify(vm);

	// Help message
	if (vm.count("help")) {
		std::cout << desc << "\n";
		return 1;
	}

	// Suppress image writing
	Config::no_output = bool(vm.count("nooutput"));

	// Samples per pixel
	if (vm.count("spp")) {
		spp = vm["spp"].as<int>();
		if (spp < 1)
			spp = 1;
		std::cout << "Samples per pixel: " << spp << "\n";
	}
	if (vm.count("sppmax")) {
		spp_max = vm["sppmax"].as<int>();
		if (spp_max < spp)
			spp_max = spp;
		std::cout << "Max samples per pixel: " << spp_max << "\n";
	}
	if (vm.count("variance")) {
		variance_max = vm["variance"].as<float>();
		std::cout << "Max image variance: " << variance_max << "\n";
	}

	// Thread count
	if (vm.count("threads")) {
		threads = vm["threads"].as<int>();
		if (threads < 1)
			threads = 1;
		std::cout << "Threads: " << threads << "\n";
	}

	// Input file
	if (vm.count("scenefile")) {
		input_path = vm["scenefile"].as<std::string>();
		std::cout << "Input scene: " << input_path << "\n";
//.........这里部分代码省略.........
开发者ID:JerryCao1985,项目名称:psychopath,代码行数:101,代码来源:main.cpp


示例8: main

int main(int argc, const char * argv[])
{
	setbuf (stdout, NULL);


#if TARGET_OS_MAC
	{
		thread_extended_policy_data_t		theFixedPolicy;
		theFixedPolicy.timeshare = false;	// set to true for a non-fixed thread
		thread_policy_set(pthread_mach_thread_np(pthread_self()), 
													THREAD_EXTENDED_POLICY, 
													(thread_policy_t)&theFixedPolicy, 
													THREAD_EXTENDED_POLICY_COUNT);

		// We keep a reference to the spawning thread's priority around (initialized in the constructor), 
		// and set the importance of the child thread relative to the spawning thread's priority.
		thread_precedence_policy_data_t		thePrecedencePolicy;
		
		thePrecedencePolicy.importance = 63 - 36;
		thread_policy_set(pthread_mach_thread_np(pthread_self()), 
													THREAD_PRECEDENCE_POLICY, 
													(thread_policy_t)&thePrecedencePolicy, 
													THREAD_PRECEDENCE_POLICY_COUNT);
	}
#endif


// These are the variables that are set up from the input parsing
	char* srcFilePath = NULL;
	char* destFilePath = NULL;
	char* auPresetFile = NULL;
	bool shortMemoryProfile = false;
	OSType manu, subType, type = 0;
	int userSetFrames = -1;
	
	for (int i = 1; i < argc; ++i)
	{
		if (strcmp (argv[i], "-au") == 0) {
            if ( (i + 3) < argc ) {                
                StrToOSType (argv[i + 1], type);
                StrToOSType (argv[i + 2], subType);
                StrToOSType (argv[i + 3], manu);
				i += 3;
			} else {
				printf ("Which Audio Unit:\n%s", usageStr);
				exit(1);
			}
		}
		else if (strcmp (argv[i], "-i") == 0) {
			srcFilePath = const_cast<char*>(argv[++i]);
		}
		else if (strcmp (argv[i], "-o") == 0) {
			destFilePath = const_cast<char*>(argv[++i]);
		}
		else if (strcmp (argv[i], "-p") == 0) {
			auPresetFile = const_cast<char*>(argv[++i]);
		}
		else if (strcmp (argv[i], "-m") == 0) {
			shortMemoryProfile = true;
		}
		else if (strcmp (argv[i], "-f") == 0) {
			sscanf(argv[++i], "%d", &userSetFrames);
		}
		else {
			printf ("%s\n", usageStr);
			exit(1);
		}
	}
	
	if (!type || !srcFilePath) {
		printf ("%s\n", usageStr);
		exit(1);
	}
	if (!destFilePath) {
		if (!shortMemoryProfile) {
			printf ("%s\n", usageStr);
			exit(1);
		}
	}
			// delete pre-existing output file
	if (!shortMemoryProfile) {
		FSRef destFSRef;
		if (FSPathMakeRef((UInt8 *)destFilePath, &destFSRef, NULL) == noErr) {
			// output file exists - delete it
			if (FSDeleteObject(&destFSRef)) {
				printf ("Cannot Delete Output File\n");
				exit(1);
			}
		}
	}
	
	CAComponentDescription desc(type, subType, manu);
	
	CFPropertyListRef presetDict = ReadPresetFromPresetFile(auPresetFile);
	
		// the num of frames to use when processing the file with the Render call
	UInt32 maxFramesToUse = shortMemoryProfile ? 512 : 32768;

		// not set from command line
	if (userSetFrames > 0) {
//.........这里部分代码省略.........
开发者ID:arnelh,项目名称:Examples,代码行数:101,代码来源:auprocess.cpp


示例9: UHD_SAFE_MAIN

int UHD_SAFE_MAIN(int argc, char *argv[]){
    std::string args, input_str, key, val;

    po::options_description desc("Allowed options");
    desc.add_options()
        ("help", "help message")
        ("args", po::value<std::string>(&args)->default_value(""), "device address args [default = \"\"]")
        ("values", po::value<std::string>(&input_str), "keys+values to read/write, separate multiple by \",\"")
        ("key", po::value<std::string>(&key), "identifiers for new values in EEPROM, separate multiple by \",\" (DEPRECATED)")
        ("val", po::value<std::string>(&val), "the new values to set, omit for readback, separate multiple by \",\" (DEPRECATED)")
        ("read-all", "Read all motherboard EEPROM values without writing")
    ;

    po::variables_map vm;
    po::store(po::parse_command_line(argc, argv, desc), vm);
    po::notify(vm);

    //print the help message
    if (vm.count("help") or (not vm.count("key") and not vm.count("values") and not vm.count("read-all"))){
        std::cout << boost::format("USRP Burn Motherboard EEPROM %s") % desc << std::endl;
        std::cout << boost::format(
            "Omit the value argument to perform a readback,\n"
            "Or specify a new value to burn into the EEPROM.\n"
        ) << std::endl;
        return EXIT_FAILURE;
    }

    std::cout << "Creating USRP device from address: " + args << std::endl;
    uhd::device::sptr dev = uhd::device::make(args, uhd::device::USRP);
    uhd::property_tree::sptr tree = dev->get_tree();
    uhd::usrp::mboard_eeprom_t mb_eeprom = tree->access<uhd::usrp::mboard_eeprom_t>("/mboards/0/eeprom").get();
    std::cout << std::endl;

    std::vector<std::string> keys_vec, vals_vec;
    if(vm.count("read-all")) keys_vec = mb_eeprom.keys(); //Leaving vals_vec empty will force utility to only read
    else if(vm.count("values")){
        //uhd::device_addr_t properly parses input values
        uhd::device_addr_t vals(input_str);
        keys_vec = vals.keys();
        vals_vec = vals.vals();
    }
    else{
        std::cout << "WARNING: Use of --key and --val is deprecated!" << std::endl;
        //remove whitespace, split arguments and values 
        boost::algorithm::erase_all(key, " ");
        boost::algorithm::erase_all(val, " ");

        boost::split(keys_vec, key, boost::is_any_of("\"',"));
        boost::split(vals_vec, val, boost::is_any_of("\"',"));

        if((keys_vec.size() != vals_vec.size()) and val != "") {
            //If zero values are given, then user just wants values read to them
            throw std::runtime_error("Number of keys must match number of values!");
        }
    }

    std::cout << "Fetching current settings from EEPROM..." << std::endl;
    for(size_t i = 0; i < keys_vec.size(); i++){
        if (not mb_eeprom.has_key(keys_vec[i])){
            std::cerr << boost::format("Cannot find value for EEPROM[%s]") % keys_vec[i] << std::endl;
            return EXIT_FAILURE;
        }
        std::cout << boost::format("    EEPROM [\"%s\"] is \"%s\"") % keys_vec[i] % mb_eeprom[keys_vec[i]] << std::endl;
    }
    std::cout << std::endl;
    for(size_t i = 0; i < vals_vec.size(); i++){
        if(vals_vec[i] != ""){
            uhd::usrp::mboard_eeprom_t mb_eeprom; mb_eeprom[keys_vec[i]] = vals_vec[i];
            std::cout << boost::format("Setting EEPROM [\"%s\"] to \"%s\"...") % keys_vec[i] % vals_vec[i] << std::endl;
            tree->access<uhd::usrp::mboard_eeprom_t>("/mboards/0/eeprom").set(mb_eeprom);
        }
    }
    std::cout << "Power-cycle the USRP device for the changes to take effect." << std::endl;
    std::cout << std::endl;

    std::cout << "Done" << std::endl;
    return EXIT_SUCCESS;
}
开发者ID:lifeatthesharpend,项目名称:uhd,代码行数:78,代码来源:usrp_burn_mb_eeprom.cpp


示例10: main

int main(int argc, char** argv) {
  int ngames=1;
  bool print_game=false;

  // Declare the supported options.
  po::options_description desc("Allowed options");
  desc.add_options()
      ("help", "produce help message")
      ("print_game", "Print Game Output")
      ("rand_inputs", "Randomize the inputs")
      ("games", po::value<int>(), "set number of games")
  ;
  
  po::variables_map vm;
  po::store(po::parse_command_line(argc, argv, desc), vm);
  po::notify(vm);
  
  if (vm.count("help")) {
      cout << desc << "\n";
      return 1;
  }
  
  if(vm.count("print_game")) {
    print_game=true;
  }

  if(vm.count("rand_inputs")) {
    std::srand(std::time(0));
  }

  if (vm.count("games")) {
    ngames=vm["games"].as<int>();
    cout << "Running" << ngames  << "\n";
  } else {
    cout << "Running Game.\n";
  }

  Game game;
  std::map<Player*,int> losses;
  std::vector<Player*> players;

  //for(int i = 0; i < 2; ++i) {
  //  addPlayer(new Player(),game,players);
  //}
  addPlayer(new TimingPlayer(),game,players);
  addPlayer(new WittyPlayer(),game,players);
  addPlayer(new SecretivePlayer(),game,players);
  //addPlayer(new TimingPlayer(),game,players);
  addPlayer(new HoldoutPlayer(),game,players);

  for(int i = 0; i < ngames; ++i) {
    game.shufflePlayers();
    std::set<Player*> losers = game.play(print_game);
    for(Player* loser : losers) {
      losses[loser]+=1;
      if(print_game) {
        cout << loser->player_name() << " " << loser->id() << " lost\n";
      }
    }
  }

  for(Player* p : players) {
    //cout << p->player_name() << " lost " << losses[p] << " games\n";
    cout << p->player_name() << " lost " << std::setprecision(5) <<
(double)losses[p]/(double)ngames << " games\n";
  }
}
开发者ID:tony-nowatzki,项目名称:thirty-one,代码行数:67,代码来源:main.cpp


示例11: main

int main(int argc, char** argv) {
  bool extract, train;
  int width, height,
      max_horizontal_steps,
      max_vertical_steps,
      video_source;
  std::string output_file;
  std::string model_file;
  std::string positive_source_directory;
  std::string negative_source_directory;

  try {
    namespace po=boost::program_options;
    po::options_description desc("Options");
    desc.add_options()
    ("help,h", "Print help messages")
    ("extract,e", po::value<bool>(&extract)->default_value(true), "Specify whether to extract features")
    ("train,t", po::value<bool>(&train)->default_value(false), "Specify whether to train")
    ("camera,c", po::value<int>(&video_source)->default_value(0), "Specify camera to retrieve test feed")
    ("width,w", po::value<int>(&width)->required(), "Specify train window width")
    ("height,h", po::value<int>(&height)->required(), "Specify train window height")
    ("max_horizontal_steps,mh", po::value<int>(&max_horizontal_steps)->default_value(0), "Specify max horizontal steps the window can take")
    ("max_vertical_steps,mh", po::value<int>(&max_vertical_steps)->default_value(0), "Specify max vertical steps the window can take")
    ("positive,p", po::value<std::string>(&positive_source_directory)->default_value(boost::filesystem::current_path().string<std::string>()+"/positive"), "Specify positive video files directory")
    ("negative,n", po::value<std::string>(&negative_source_directory)->default_value(boost::filesystem::current_path().string<std::string>()+"/negative"), "Specify negative video files direcotry")
    ("output,o", po::value<std::string>(&output_file)->default_value(boost::filesystem::current_path().string<std::string>()+"/features.dump"), "Specify an features file for save/load")
    ("model,m", po::value<std::string>(&model_file)->default_value(boost::filesystem::current_path().string<std::string>()+"/result.model"), "Specify an model file for save/load");

    po::variables_map vm;
    po::store(po::command_line_parser(argc,argv).options(desc).run(), vm);

    if (vm.count("help")) {
      std::cout << "Usage: " << argv[0] << " [options]" << std::endl;
      std::cout << desc;
      return 0;
    }

    po::notify(vm);
  } catch(std::exception& e) {
    std::cerr << "Error: " << e.what() << std::endl;
    return 1;
  } catch(...) {
    std::cerr << "Exception of unknown type!" << std::endl;
    return 1;
  }

  const cv::Size window_size=cv::Size(width, height);

  std::vector<maav::Features> features_collection;
  std::vector<unsigned int> divider;

  maav::HOGExtractor extractor(window_size);

  if(extract) {
    maav::FeatureExtractMethod extract_method(extractor, features_collection);
    boost::function<void (const cv::Mat &)> f=boost::ref(extract_method);

    boost::filesystem::path positive_dir(positive_source_directory);
    if(boost::filesystem::is_directory(positive_dir)) {
      boost::filesystem::directory_iterator dir_iter(positive_dir), eod;

      unsigned int counter=0;
      BOOST_FOREACH(boost::filesystem::path const &file_path, std::make_pair(dir_iter, eod)) {
        maav::LoadEachFrameFromFile(file_path.string<std::string>(), f);
        for(unsigned int i=0;i<(features_collection.size()-divider.size());i++) {
          divider.push_back(counter);
        }
        counter++;
      }
    }

    boost::filesystem::path negative_dir(positive_source_directory);
    if(boost::filesystem::is_directory(negative_dir)) {
      boost::filesystem::directory_iterator dir_iter(negative_dir), eod;

      BOOST_FOREACH(boost::filesystem::path const &file_path, std::make_pair(dir_iter, eod)) {
        maav::LoadEachFrameFromFile(file_path.string<std::string>(), f);
      }
    }
开发者ID:agiantwhale,项目名称:VideoTrainer,代码行数:79,代码来源:main.cpp


示例12: main

int main(int argc, char** argv)
{
  use_case::UseCaseEnvironment use_case_environment(&argc, &argv);
  stk::ParallelMachine comm = use_case_environment.m_comm;

  //----------------------------------
  // Broadcast argc and argv to all processors.

  stk::BroadcastArg b_arg(comm, argc, argv);

  //----------------------------------
  // Process the broadcast command line arguments

  bopt::options_description desc("options");

  stk::get_options_description().add(desc);

  int num_trials = 0;
  int nthreads = 1;
  int bucket_size = 1000;

  desc.add_options()
    ("help,h",        "produce help message")
    ("performance",   "run performance test [14/14a/blas only]")
    ("mesh,m",        bopt::value<std::string>(), "mesh file. Use name of form 'gen:NxMxL' to internally generate a hex mesh of size N by M by L intervals. See GeneratedMesh documentation for more options. Use 'gears' to generate the gears mesh." )
    ("directory,d",   bopt::value<std::string>(), "working directory with trailing '/'" )
    ("output-log,o",  bopt::value<std::string>(), "output log path" )
    ("runtest,r",     bopt::value<std::string>(), "runtest pid file" )
    ("threads",       bopt::value<int>(&nthreads)->default_value(1),   "number of threads [14/14a/blas only]")
    ("trials",        bopt::value<int>(&num_trials)->default_value(1),   "number of trials (execute loops) [14/14a/blas only]")
    ("bucket_size",    bopt::value<int>(&bucket_size)->default_value(1000),   "size of buckets used internally in stk::mesh [14/14a/blas only]")
    ("tbb",           "Use Threaded Building Blocks algorithm thread runner [14/14a/blas only]")
    ("tpi",           "Use Thread Pool Interface algorithm thread runner [14/14a/blas only]")
    ("nonthreaded",   "Run algorithms non-threaded [default] [14/14a/blas only]")
    ( use_case_7 ,   "use case 7" )
    ( use_case_blas , "use case blas (fill, axpby, dot, norm)" )
    ( use_case_14 ,   "use case 14 (hex internal force algorithm)" )
    ( use_case_14a ,  "use case 14a (hex internal force algorithm)" )
    ( use_case_24 ,   "use case 24 " );

  bopt::variables_map vm;
  try {
    bopt::store(bopt::parse_command_line(b_arg.m_argc, b_arg.m_argv, desc), vm);
    bopt::notify(vm);
  }
  catch (std::exception &x) {
    std::cout << x.what() << std::endl;
    std::exit(1);
  }


  //----------------------------------

  if (vm.count("help")) {
    std::cout << desc << "\n";
    std::exit(EXIT_SUCCESS);
  }

  bool run_performance_test = vm.count( "performance" ) > 0;

  std::string thread_runner = "NonThreaded";
  if (vm.count("tbb"))
    thread_runner = "TBB";
  if (vm.count("tpi"))
    thread_runner = "TPI";
//   if (vm.count("dgb"))
//     thread_runner = "DGB";
  if (vm.count("nonthreaded"))
    thread_runner = "NonThreaded";

  std::string working_directory = "";
  std::string in_filename = "";
  std::string in_filetype = "exodusii";
  if (vm.count("mesh")) {
    in_filename = boost::any_cast<std::string>(vm["mesh"].value());;

    if (strncasecmp("gen:", in_filename.c_str(), 4) == 0) {
      // Strip off the 'gen:' prefix and set the type to "generated"
      in_filename = in_filename.substr(4, in_filename.size());
      in_filetype = "generated";
    }

    if (strncasecmp("gears:", in_filename.c_str(), 6) == 0) {
      // Strip off the 'gears:' prefix and set the type to "gears"
      in_filename = in_filename.substr(6, in_filename.size());
      in_filetype = "gears";
    }

    if (vm.count("directory")) {
      working_directory = boost::any_cast<std::string>(vm["directory"].value());
    }
  } else {
    std::cout << "OPTION ERROR: The '--mesh <filename>' option is required for all use cases!\n";
    std::exit(EXIT_FAILURE);
  }

  bool success = false;

  if ( vm.count( use_case_7 ) ) {

//.........这里部分代码省略.........
开发者ID:gitter-badger,项目名称:quinoa,代码行数:101,代码来源:UseCase_driver.cpp


示例13: realmain

int realmain(int argc, char** argv)
{
    while(!FARender::Renderer::get()) {}

    FARender::Renderer& renderer = *FARender::Renderer::get();
    Input::InputManager& input = *Input::InputManager::get();

    size_t levelNum;

    boost::program_options::options_description desc("Options");
    desc.add_options()
        ("help,h", "Print help")
        ("level,l", boost::program_options::value<size_t>(&levelNum)->default_value(0), "Level number to load (0-4)");

    boost::program_options::variables_map vm; 
    try 
    { 
        boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);

        if(vm.count("help"))
        {
            std::cout << desc << std::endl;
            return 0;
        }
        
        boost::program_options::notify(vm);

        if(levelNum > 4)
            throw boost::program_options::validation_error(
                boost::program_options::validation_error::invalid_option_value, "level");
    }
    catch(boost::program_options::error& e)
    {
        std::cerr << "ERROR: " << e.what() << std::endl << std::endl;
        std::cerr << desc << std::endl;
        return 1;
    }


    DiabloExe::DiabloExe exe;
    FAWorld::World world;

    FALevelGen::FAsrand(time(NULL));

    std::vector<Level::Level*> levels(5);

    size_t currentLevel = levelNum;

    Level::Level* level;

    if(!(level = getLevel(levelNum, exe)))
    {
        done = true;
    }
    else
    {
        levels[currentLevel] = level;
        setLevel(levelNum, exe, world, renderer, *level);
    }
    
    FAWorld::Player* player = world.getPlayer();

    if(levelNum == 0)
        player->mPos = FAWorld::Position(75, 68);
    else
        player->mPos = FAWorld::Position(level->upStairsPos().first, level->upStairsPos().second);

    boost::posix_time::ptime last = boost::posix_time::microsec_clock::local_time();
    
    std::pair<size_t, size_t> destination = player->mPos.current();
    
    // Main game logic loop
    while(!done)
    {
        if(mouseDown)
        {
            destination = renderer.getClickedTile(xClick, yClick);
            if(click)
                level->activate(destination.first, destination.second);

            click = false;
        }

        input.processInput();

        if(changeLevel)
        {
            int32_t tmp = currentLevel + changeLevel;
            if(tmp >= 0 && tmp < (int32_t)levels.size())
            {
                currentLevel = tmp;

                if(levels[currentLevel] == NULL)
                    levels[currentLevel] = getLevel(currentLevel == 0 ? 0 : 1, exe);

                level = levels[currentLevel];
                
                if(changeLevel == -1)
                    player->mPos = FAWorld::Position(level->downStairsPos().first, level->downStairsPos().second);
                else
//.........这里部分代码省略.........
开发者ID:2amdevelopment,项目名称:freeablo,代码行数:101,代码来源:main.cpp


示例14: UHD_SAFE_MAIN


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ descend函数代码示例发布时间:2022-05-30
下一篇:
C++ des_ecb_encrypt函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap