当前位置: 首页>>代码示例>>C++>>正文


C++ ofstream::close方法代码示例

本文整理汇总了C++中std::ofstream::close方法的典型用法代码示例。如果您正苦于以下问题:C++ ofstream::close方法的具体用法?C++ ofstream::close怎么用?C++ ofstream::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::ofstream的用法示例。


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

示例1: run


//.........这里部分代码省略.........

		realKForeLeft = kneeEncoder(amarsi::LEFT_FORE).position();
		realKHindLeft = kneeEncoder(amarsi::LEFT_HIND).position();
		realKForeRight = kneeEncoder(amarsi::RIGHT_FORE).position();
		realKHindRight = kneeEncoder(amarsi::RIGHT_HIND).position();

		file_knee_trajectory
			<< realKForeLeft << " " 
			<< realKHindLeft << " " 
			<< realKForeRight << " " 
			<< realKHindRight << " " 
			<< distance << std::endl;


		//MAX ANGLE
		//correxpond a un test si l'angle entre les deux vecteurs est plus grand que 60 degrés
		//if(state.startingUpDirection*state.upDirection < 0.5)
		if (state.startingUpDirection*state.upDirection < max_angle)
			max_angle = state.startingUpDirection*state.upDirection;

		//STABILITY
		//The higher the less stable
		stability += state.startingUpDirection*state.upDirection;


		if (state.upDirection * state.startingUpDirection < cos(80 * PI / 180.0))
		{
			// Here the robot has a roll or pitch of more than 80
			// degrees
			break;
		}
      }
      
	//=====================================================
	// OUTPUT SECTION
	//=====================================================
	// Here we compute the value we monitor. We give some
	// example as comment, but there is better way to do it,
	// and better value to monitor.
	//=====================================================

	// First we output the parameters used for the run
	file_stats << d_amplitudeForeHip << " "
		<< d_amplitudeHindHip << " "
		<< d_offsetForeHip << " "
		<< d_offsetHindHip << " "
		<< d_amplitudeForeKnee << " "
		<< d_amplitudeHindKnee << " "
		<< d_offsetKnee << " "
		<< d_kneePhaseLag << " "
		<< d_frequency << " ";

	double duration = amarsi::Clock::getTime();

	file_stats << duration << " ";

	// Compute the algebraic distance in front direction of
	// the robot

	Vector3 frontDirection = state.frontDirection;

	frontDirection.y() = 0.0;
	frontDirection.normalize();

	double distance = max(((state.position - state.startingPosition) * frontDirection), 0.0);
	file_stats << distance << " ";

	file_stats << max_angle << " ";

	stability /= duration; // normalize by time
	file_stats << stability << " ";

	// Note: You may want to add other values!!!

	// Close the line
	file_stats << std::endl;

	// Reset the position and dynamics of the robot for the
	// next run.
	// amarsi::Supervisor::instance().resetSimulation();
	//cout << image_file << endl;
	//}

	//cout << image_file << endl;
  
	//~ webots::Supervisor().exportImage(image_file, 100);
  
	// amarsi::Supervisor::instance().simulationQuit();
  
	file_time.close();
	file_stats.close();
	file_leg_trajectory.close();
	file_leg_trajectory_rframe.close();
	file_hip_trajectory.close();
	file_knee_trajectory.close();
	file_rob_trajectory.close();
	file_forces.close();

	return 0;
}
开发者ID:douglas-watson,项目名称:cheetah-project,代码行数:101,代码来源:SystematicSearchController.cpp

示例2:

	~KinectDataDumper() {
		timestampStream.close();
	}
开发者ID:LRMPUT,项目名称:PUTSLAM_ROSBAG,代码行数:3,代码来源:imageConverter.cpp

示例3: closefile

	void closefile(){
		ply_file.seekp(pos);
		ply_file << i;
		ply_file.close();
	}
开发者ID:Modasshir,项目名称:socrob-ros-pkg,代码行数:5,代码来源:worldmapBlock.cpp

示例4: computeIntersections


//.........这里部分代码省略.........
  blueFlag[startBlue] = 1; // mark also the first one
  // also, red flag is declared outside the loop
  int * redFlag = new int [m_numPos+1];
  
  if (dbg)
    mout.open("patches.m");
  while( !blueQueue.empty() )
    {
      int n[3]; // flags for the side : indices in red mesh start from 0!!! (-1 means not found )
      for (k=0; k<3; k++)
	n[k] = -1; // a paired red not found yet for the neighbors of blue 
      int currentBlue = blueQueue.front();
      blueQueue.pop();
      for (k=0; k<m_numPos; k++)
	redFlag[k] = 0;
      redFlag[m_numPos] = 1; // to guard for the boundary
      int currentRed = redQueue.front(); // where do we check for redQueue???? 
      // red and blue queues are parallel
      redQueue.pop();// 
      redFlag[currentRed] = 1; // 
      std::queue<int> localRed;
      localRed.push(currentRed);
      while( !localRed.empty())
	{
	  // 
	  int redT = localRed.front();
	  localRed.pop();
	  double P[24], area;
          int nP = 0; // intersection points
	  int nc[3]= {0, 0, 0}; // means no intersection on the side (markers)
          computeIntersectionBetweenRedAndBlue(/* red */redT, currentBlue, P, nP, area,nc);
	  if (nP>0) 
	    {
	      // intersection found: output P and original triangles if nP > 2
	      if (dbg && area>0)
		{
		  //std::cout << "area: " << area<< " nP:"<<nP << " sources:" << redT+1 << ":" << m_redMesh[redT].oldId <<
		  //  " " << currentBlue+1<< ":" << m_blueMesh[currentBlue].oldId << std::endl;
		}
              if (dbg)
		{
		  mout << "pa=[\n";
		  
		  for (k=0; k<nP; k++)
		    {
		     
		      mout <<  P[2*k] << "\t " ;
		    }
	
		  mout << "\n";
		  for (k=0; k<nP; k++)
		    {
		    
		      mout << P[2*k+1] << "\t "; 
		    }
	
		  mout << " ]; \n";
		  mout << " patch(pa(1,:),pa(2,:),'m');       \n";
		}
	      // add neighbors to the localRed queue, if they are not marked
	      for (int nn= 0; nn<3; nn++)
		{
		  int neighbor = m_redMesh[redT].t[nn];
		  if (redFlag[neighbor] == 0)
		    {
		      localRed.push(neighbor);
		      redFlag[neighbor] =1; // flag it to not be added anymore
		    }
		  // n(find(nc>0))=ac;        % ac is starting candidate for neighbor
		  if (nc[nn]>0) // intersected  
		    n[nn] = redT;// start from 0!! 
		}
              if (nP>1) // this will also construct triangles, if needed
		findNodes(redT, currentBlue, P, nP);
	    }
	  
	}
      for (int j=0; j<3; j++)
	{
	  int blueNeigh = m_blueMesh[currentBlue].t[j];
	  if (blueFlag[blueNeigh]==0 && n[j] >=0 ) // not treated yet and marked as a neighbor
	    {
              // we identified triangle n[j] as intersecting with neighbor j of the blue triangle
	      blueQueue.push(blueNeigh);
	      redQueue.push(n[j]);
	      if (dbg)
		std::cout << "new triangles pushed: blue, red:" << blueNeigh+1 << " " << n[j]+1 << std::endl;
	      blueFlag[blueNeigh] = 1;
	    }
	}
    }
  delete [] redFlag;
  redFlag = NULL;

  delete [] blueFlag; // get rid of it
  blueFlag = NULL;
  if (dbg)
    mout.close();
  return 0;
}
开发者ID:vibraphone,项目名称:meshkit,代码行数:101,代码来源:ProjectShell.cpp

示例5: Update


//.........这里部分代码省略.........
		if (units_idled_frame_counter > -1){ // check if we have to compute units idle
			if (unitsIdled)
				units_idled_frame_counter++; // increase counter to know how much time all units are idled
			else
			  units_idled_frame_counter = 0; // reset units idle counter
		}
		// compute if we reach limits to accept idle units
		if ((units_idled_frame_counter - 1)/GAME_SPEED < UNITS_IDLED_TRIGGER && units_idled_frame_counter/GAME_SPEED >= UNITS_IDLED_TRIGGER)
			log("CProgAndPlay : units idle limit time exceed");
		bool unitsIdledReach = units_idled_frame_counter/GAME_SPEED >= UNITS_IDLED_TRIGGER;

		// Check if we have to start compression
		if (newExecutionDetected && (missionEndedReach || unitsIdledReach || askHelp) && !onGoingCompression){
			log("CProgAndPlay : ask parser to proceed and compress traces");
			// we ask trace parser to proceed all traces aggregated from the last new execution event
			tp.setProceed(true);
			onGoingCompression = true;
		}
	}

	// Check if it's time to launch analysis of compressed traces
	if (onGoingCompression){
		if (tp.compressionDone()){
			// compression is done then proceed compression result by computing feedback
			// or storing expert solution
			log("CProgAndPlay : compression done");
			onGoingCompression = false;
			// if mission ended we stop thread. Indeed even if compression is done, the
			// thread is steal running. Then we explicitly ask to stop now
			if (missionEnded && traceModuleCorrectlyInitialized) {
				log("CProgAndPlay : turn off trace parser and set traceModuleCorrectlyInitialized to false");
				tp.setEnd();
				tracesThread.join();
				ppTraces.close();
				// then the trace module is no longer initialized
				traceModuleCorrectlyInitialized = false;
			}

			// If we are not in testing mode => build the feedback and send it to Lua context
			if (!testMapMode) {
				// inform trace analyser if we detect an endless loop
				ta.setEndlessLoop(tracesComing && !endExecutionDetected);
				// load expert xml solutions
				std::vector<std::string> experts_xml;
				std::vector<std::string> files = vfsHandler->GetFilesInDir(archiveExpertPath + missionName);
				for (unsigned int i = 0; i < files.size(); i++) {
					if (files.at(i).find(".xml") != std::string::npos && files.at(i).compare("feedbacks.xml") != 0)
						experts_xml.push_back(loadFileFromVfs(archiveExpertPath + missionName + "\\" + files.at(i)));
				}

				std::string feedback = "";
				if (!experts_xml.empty()) {
					log("CProgAndPlay : expert compressed traces found => compute feedbacks");
					// load learner xml solution
					const std::string learner_xml = loadFile(springTracesPath + missionName + "_compressed.xml");
					// compute feedbacks
					feedback = ta.constructFeedback(learner_xml, experts_xml, -1, -1);
					// Write into file
					std::ofstream jsonFile;
					jsonFile.open(springLastFeedbacksPath.c_str());
					if (jsonFile.good()) {
						jsonFile << feedback;
						jsonFile.close();
					}
				}
				else{
开发者ID:Mocahteam,项目名称:SpringPP,代码行数:67,代码来源:ProgAndPlay.cpp

示例6: l

		~logger()
		{
			mutex::scoped_lock l(file_mutex);
			log_file.close();
			open_filename.clear();
		}
开发者ID:hammer,项目名称:genetorrent,代码行数:6,代码来源:debug.hpp

示例7: main


//.........这里部分代码省略.........
                           if(isInfected[i])
                           {
                                if(isSusceptible[j])
                                {
                                    si_s.push_back(j);
                                }
                            }
                            else
                            {
                                if(isInfected[j])
                                {
                                    if(isSusceptible[i])
                                    {
                                        si_s.push_back(i);
                                    }
                                }
                            }
                        }
                        SI=si_s.size();
                        Beta=beta*(double)SI;
                        Lambda=Beta+Mu; //new cumulative transition rate
                        // Draw new renormalized waiting time:
                        tau=randexp(1);
                    }
                    tau-=xi*Lambda;
                }
                // Stop if I=0:
                if(I==0)
                {
                    stopped++;
                    hist_R[R]++;
                    for(n=t; n<T_simulation; n++)
                    {
                        if(n % outputTimeResolution ==0){ sumR_t[n/outputTimeResolution]+=R; }
                    }
                   break;
                }
                // Read out I and R if t is divisible by outputTimeResolution
                if(t % outputTimeResolution ==0)
                {
                    if(t>=T_simulation) //stop if max simulation time-steps has been reached
                    {
                        break;
                    }
                    else
                    {
                        sumI_t[t/outputTimeResolution]+=I;
                        sumR_t[t/outputTimeResolution]+=R;
                    }
                }
                t++;
            }
            t_infectionStart=0;
        }
    }
    double t_simu = ( std::clock() - clockStart ) / (double) CLOCKS_PER_SEC;

    //-------------------------------------------------------------------------------------
    // Save epidemic data to disk:
    //-------------------------------------------------------------------------------------
    clockStart=std::clock();
    // Open output file:
    sprintf(outputname,"avg(I_t)-%s,N=%u,dt=%u,T=%u,beta=%.*f,mu=%.*f,Q=%u,res=%u.txt",datafile,N,dt,T_simulation,betaprec,beta,muprec,mu,ensembleSize,outputTimeResolution);
    output.open(outputname);
    // Write I_t to file:
    for(node_iterator=sumI_t.begin(); node_iterator!=sumI_t.end(); node_iterator++)
    {
        output << (double)*node_iterator/(double)ensembleSize << "\t";
    }
    output.close();

    // Open output file:
    sprintf(outputname,"avg(R_t)-%s,N=%u,dt=%u,T=%u,beta=%.*f,mu=%.*f,Q=%u,res=%u.txt",datafile,N,dt,T_simulation,betaprec,beta,muprec,mu,ensembleSize,outputTimeResolution);
    output.open(outputname);
    // Write R_t to file:
    for(node_iterator=sumR_t.begin(); node_iterator!=sumR_t.end(); node_iterator++)
    {
        output << (double)*node_iterator/(double)ensembleSize << "\t";
    }
    output << "\n";
    output.close();
    // Open output file:
    sprintf(outputname,"p(R)-%s,N=%u,dt=%u,T=%u,beta=%.*f,mu=%.*f,Q=%u,res=%u.txt",datafile,N,dt,T_simulation,betaprec,beta,muprec,mu,ensembleSize,outputTimeResolution);
    output.open(outputname);
    // Write histrogram of R, h(R) to file:
    for(node_iterator=hist_R.begin(); node_iterator!=hist_R.end(); node_iterator++)
    {
        output << (double)*node_iterator/(double)ensembleSize << "\t";
    }
    output.close();
    double t_write = ( std::clock() - clockStart ) / (double) CLOCKS_PER_SEC;

    std::cout << std::endl << "temporal Gillespie---homogeneous & Poissonian SIR w/ contact removal: N=" << N
              << ", T=" << T_data << ", beta=" << beta << ", mu=" << mu;
    std::cout << ", output time-resolution = " << outputTimeResolution << std::endl;
    std::cout << "Simulation time: " << t_simu << "s, Stopped simulations: " << stopped << "/" << ensembleSize << std::endl;
    std::cout << "Writing to file: " << t_write << "s" << std::endl;

    return 0;
}
开发者ID:CLVestergaard,项目名称:TemporalGillespieAlgorithm,代码行数:101,代码来源:SIR-Poisson-homogeneous-contactRemoval.cpp

示例8: setManipulator

GLUTMinimalCFR::~GLUTMinimalCFR()
{
  setManipulator( nullptr );
  file << "stop " << m_globalTimer.getTime() << "\n";
  file.close();
}
开发者ID:getov,项目名称:pipeline,代码行数:6,代码来源:main.cpp

示例9:

My3DEngine::~My3DEngine(void)
{
	delete renderer;
	logs.close();
}
开发者ID:nriviere,项目名称:Pathogen,代码行数:5,代码来源:My3DEngine.cpp

示例10: main

int main()
{
        if(getuid())
        {
                cerr << "Please run as root! exit..." << endl;
                exit(1);
        }

        if(to_daemon() == -1)
        {
                cerr << "Can't turn into daemon, exit..." << endl;
                exit(1);
        }

        logs.open(LOG_PATH, logs.out | logs.app);
        if(!logs.good())
        {
                cerr << "Can't open log, exit..." << endl;
                exit(1);
        }

        logs << std::unitbuf;
        logs << "++++++++  program started! ++++++++" << endl;

        if(add_group() == -1)
        {
                logs << "Can't add group, exit..." << endl;
                logs.close();
                exit(1);
        }

        if(drop_in() == -1)
        {
                logs << "Can't enbale `drop in` support, exit..."
                        << endl;
                logs.close();
                exit(1);
        }

        std::string msg;

        if(record_pid(msg) == -1)
        {
                logs << msg << endl;
                logs.close();
                exit(1);
        }

        if(install_handler(SIGHUP, hup_handler) == -1 || 
                install_handler(SIGTERM, term_handler) == -1)
        {
                logs << "Can't install signal handlers: " << strerror(errno)
                        << " exit..." << endl;
                logs.close();
                exit(1);
        }
        
        std::string qualified_dev;
        
        while(!exit_flag)
        {
                if(log_truncate() == -1)
                        break;
                while(!is_qualified_device(qualified_dev) && !exit_flag)
                        device_helper();

                if(!exit_flag)
                {
                        privilege(true);
                        logs << qualified_dev << " granted privilege!\n";
                }

                while(is_qualified_device(qualified_dev) && !exit_flag)
                        device_helper();

                privilege(false);

                logs << "Dropped privilege!\n";
        }

        time_t tm = time(NULL);
        logs << "Program exited: " << ctime(&tm) << endl;
        logs.close();

        unlink(PID_PATH);

        return 0;
}
开发者ID:abbycin,项目名称:sudodev,代码行数:88,代码来源:sdevd.cpp

示例11: Fini

VOID Fini(INT32 code, VOID *v)
{
    outFile.close();
}
开发者ID:LeeeWee,项目名称:wear-leveling,代码行数:4,代码来源:memtracker.cpp

示例12: closeFile

/** Closes an output file */
void RbFileManager::closeFile(std::ofstream& strm)
{
    
	strm.close();
}
开发者ID:vivianaayus,项目名称:revbayes,代码行数:6,代码来源:RbFileManager.cpp

示例13: do_it


//.........这里部分代码省略.........
    read_audio_fields->add(audio_length);

    Fields *segment_fields = new Fields();
    segment_fields->add(segment_offset);

    Fields *fft_fields = new Fields();
    fft_fields->add(fft);

    Fields *ifft_fields = new Fields();
    ifft_fields->add(clipped);

    FilterStageIR *filt = new FilterStageIR(filter, "filter", filter_fields);
    TransformStageIR *reader = new TransformStageIR(read_audio, "read_audio", filter_fields, read_audio_fields);
    PresegmentationStageIR *preseg = new PresegmentationStageIR(compute_num_segments, "compute_num_segments",
                                                                read_audio_fields);
    SegmentationStageIR *seg = new SegmentationStageIR(segment, compute_num_segments, "segment",
                                                       "compute_num_segments", read_audio_fields, segment_fields);
    TransformStageIR *fft_xform = new TransformStageIR(compute_fft, "compute_fft", segment_fields, fft_fields);
    BucketStageIR *bucketer = new BucketStageIR(bucket_fns, "bucket_fns", fft_fields, OUTER);
    ComparisonStageIR *ifft_xform = new ComparisonStageIR(compute_ifft, "compute_ifft", fft_fields, ifft_fields);

//    filt->merge_in(reader);
//    reader->merge_in(preseg);
//    seg->merge_in(fft_xform);
//    fft_xform->merge_in(bucketer);
//
// can't do filter parallel and tracking
//    filt->set_parallelizable(true);
    filt->parallelize();
    filt->set_compact(true); // don't do atomic update
    reader->set_parallelizable(true);
    reader->parallelize();
    bucketer->set_parallelizable(true);
    bucketer->parallelize();
    preseg->set_parallelizable(true);
    preseg->parallelize();
    preseg->set_compact(true);
    seg->set_parallelizable(true);
    seg->parallelize();
    fft_xform->set_parallelizable(true);
    fft_xform->parallelize();
    ifft_xform->set_parallelizable(true);
    ifft_xform->parallelize();
//    ifft_xform->set_track_progress(true);
//    ifft_xform->set_num_tracking_splits(3);
//    ifft_xform->set_time_loop(true);

    ifft_xform->set_tileable(true);
    ifft_xform->tile();

    PipelineIR *pipeline_full_data = new PipelineIR();
    pipeline_full_data->register_stage(filt);
    pipeline_full_data->register_stage(reader);
    pipeline_full_data->register_stage(preseg);
    pipeline_full_data->register_stage(seg);
    pipeline_full_data->register_stage(fft_xform);
    pipeline_full_data->register_stage(bucketer);

    PipelineIR *pipeline_exemplars = pipeline_full_data->duplicate();

    // full data has the comparison in it, so the left input becomes the exemplars output
    pipeline_full_data->register_stage(ifft_xform);
//    ifft_xform->force_commutative();
//    ifft_xform->set_left_input(pipeline_exemplars->get_stages().back());

//    pipeline_exemplars->merge(pipeline_full_data); // exemplars will run, then the data, then the comparison
    pipeline_full_data->build_pipeline();
//    pipeline_exemplars->build_pipeline();
    pipeline_full_data->dump();

    LLVM::LLVMCodeGenerator codegen(jit);
    codegen.visit(pipeline_full_data->get_pipeline());
//    codegen.visit(pipeline_exemplars->get_pipeline());
    jit->dump();

#ifdef AOT_COMPILE
    AOT::aot_compile(jit->get_module().get(), "MF.o");
#else
    jit->add_module();
    std::vector<Element *> elements = init_filepaths();
    std::chrono::time_point<std::chrono::system_clock> start = utils_get_time();
    IR::cleanup();
    MType::cleanup();
    run1(jit, elements, filter_filepath, audio, audio_length, segment_offset, fft, clipped);
//    run2(jit, elements, elements, filter_filepath, audio, audio_length, segment_offset, fft, clipped);
    std::chrono::time_point<std::chrono::system_clock> end = utils_get_time();
    utils_print_time_duration(start, end);
#endif
    fftwf_destroy_plan(*fft_plan);
    fftwf_destroy_plan(*ifft_plan);
    fftwf_free(fft_plan);
    fftwf_free(ifft_plan);
    output_file.close();
    delete(filter_filepath);
    delete(audio);
    delete(audio_length);
    delete(segment_offset);
    delete(fft);
    delete(clipped);
}
开发者ID:mitll,项目名称:MatchIT,代码行数:101,代码来源:MF.cpp

示例14: close_store

	void close_store() {
		if (owl_file.is_open()) {
			owl_file << "\n)\n";
		}
		owl_file.close();
	}
开发者ID:ian-bertolacci,项目名称:rose-develop,代码行数:6,代码来源:OntoGeneratorInterface.hpp

示例15: Fini

VOID Fini(INT32 code, VOID *v)
{
    TraceFile << "# eof" << endl;
    
    TraceFile.close();
}
开发者ID:alagenchev,项目名称:school_code,代码行数:6,代码来源:trace.cpp


注:本文中的std::ofstream::close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。