/**
 * \brief Constructor.
 */
tunnel::player_pending_action::player_pending_action( const std::string & str )
{
  std::vector<std::string> params;
  
  claw::text::split(params, str, '|');
  if ( params.size() == 5 ) 
    {
      size_t t;
      std::istringstream iss0(params[0]);
      iss0 >> t;
      if ( t == start_action ) 
	pending_type = start_action;
      else if ( t == stop_action ) 
	pending_type = stop_action;
      else
	pending_type = do_action;
      
      std::istringstream iss1(params[1]);
      iss1 >> date; 
      
      std::istringstream iss2(params[2]);
      iss2 >> player_index; 
      
      std::istringstream iss3(params[3]);
      iss3 >> action; 
      
      std::istringstream iss4(params[4]);
      iss4 >> duration;
    }
string* split_string(string temp_str, int &num_sub_strings)
{
	int ct = 0;
	istringstream iss1(temp_str);
	string sub;

	do
	{
	iss1 >> sub;
	ct++;
	} while (iss1);

	string* ptr_str = new string[ct];

	ct=0;
	istringstream iss2(temp_str);
	do
	{
	iss2 >> ptr_str[ct];
	ct++;
	} while (iss2);

	num_sub_strings = ct-1;
	return ptr_str;
}
Beispiel #3
0
	float* MCNeuronSim::readVtrace(std::string fileName, int nLines, bool deleteFile){
			float* vTrace = new float[nLines];

			std::ifstream infile(fileName.c_str());

			std::string file_line;
			std::string delimiter = ";";
			int i=0;
			while (std::getline(infile, file_line))
			{
				if(i>=nLines){
					break;
					//std::cout<<"More lines read than expected from "+patch::to_string(fileName)+"--nlines read:"+patch::to_string(i+1);
				}
			    std::istringstream iss1(file_line);
			    std::string line;
			    iss1 >> line;

			    //tokenize and convert to float
			    std::string token =line.substr(0, line.find(delimiter));
				std::istringstream iss2(token);
				iss2 >> vTrace[i++];
				//std::cout<<vTrace[i-1]<<"\n";
			}
			if(deleteFile)
				std::remove(fileName.c_str());
			return vTrace;
		}
Beispiel #4
0
void test2() {
    geryon::server::GUniformMemoryPool pool(BUF_SZ, 1, 0);
    std::vector<geryon::server::GBufferHandler> buffers;

    geryon::server::GIstreambuff buff1(buffers, 0, 0);
    std::istream iss1(&buff1);
}
Beispiel #5
0
void start(int &m, int &l, int &w, int &i, bool &c)
{
	string in;
	cout << "Algorytm ewolucyjny. Podaj wartosci parametrow." << endl;

	cout << "mi: " << endl;
	cin >> in;
	istringstream iss(in);
	iss >> m;

	cout << "lambda: " << endl;
	cin >> in;
	istringstream iss1(in);
	iss1 >> l;

	cout << "wymiar: " << endl;
	cin >> in;
	istringstream iss2(in);
	iss2 >> w;

	cout << "liczba iteracji: " << endl;
	cin >> in;
	istringstream iss3(in);
	iss3 >> i;

	cout << "czy drukowac wyniki czesciowe? (t/n): " << endl;
	cin >> in;
	if(in == "t")
		c = true;
	else 
		c = false;
}
void test_basic_with_assign_template(
  ForwardIterator first,ForwardIterator last
  BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Flyweight))
{
  typedef typename Flyweight::value_type value_type;

  ForwardIterator it;

  test_basic_template<Flyweight>(first,last);

  for(it=first;it!=last;++it){
    /* value construction */

    value_type v(*it);
    Flyweight  f1(v);
    Flyweight  f2(f1.get());
    BOOST_TEST(f1.get()==v);
    BOOST_TEST(f2.get()==v);
    BOOST_TEST(f1==f2);

#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
    value_type       v1(v);
    const value_type v2(v);
    Flyweight        fr1(std::move(v1));
    Flyweight        fr2(std::move(v2));
    BOOST_TEST(fr1==v);
    BOOST_TEST(fr2==v);
#endif

    /* value assignment */

    Flyweight f3,f4;
    f3=v;
    f4=f1.get();
    BOOST_TEST(f2.get()==v);
    BOOST_TEST(f3.get()==v);
    BOOST_TEST(f2==f3);

#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
    Flyweight fr3;
    fr3=value_type(*it);
    BOOST_TEST(fr3.get()==value_type(*it));
#endif

    /* specialized algorithms */

    std::ostringstream oss1;
    oss1<<f1;
    std::istringstream iss1(oss1.str());
    Flyweight f5;
    iss1>>f5;
    BOOST_TEST(f5==f1);
  }
}
Beispiel #7
0
bool PMCSQS_Scorer::read_sqs_models(Config *_config, char *file)
{
	config_ = _config;

	string path;
	path = config_->get_resource_dir() + "/" + string(file);


	ifstream in_stream(path.c_str(),ios::in);
	if (! in_stream.good())
	{
		cout << "Warning: couldn't open sqs model for reading: " << path << endl;
		return false;
	}

	int i;
	char buff[512];
	int num_sqs_charges=-1;

	in_stream.getline(buff,256);
	istringstream iss(buff);

	iss >> num_sqs_charges;
	
	in_stream.getline(buff,256);
	istringstream iss1(buff);
	int numSizes=0;
	iss1 >> numSizes;

	this->sqsMassThresholds_.resize(numSizes,POS_INF);
	for (i=0; i<numSizes; i++)
		iss1 >> sqsMassThresholds_[i];

	this->sqs_correction_factors.resize(num_sqs_charges);
	this->sqs_mult_factors.resize(num_sqs_charges);
	for (i=0; i<num_sqs_charges; i++)
	{
		in_stream.getline(buff,512);
		istringstream iss(buff);
		int num_threshes = 0;
		iss >> num_threshes;

		if (num_threshes>0)
		{
			sqs_correction_factors[i].resize(num_threshes+1,0);
			sqs_mult_factors[i].resize(num_threshes+1,1.0);
			int j;
			for (j=0; j<=num_threshes; j++)
				iss >> sqs_correction_factors[i][j] >> sqs_mult_factors[i][j];
		}
	}
Beispiel #8
0
Cube::Cube(Ogre::SceneManager& mSceneMgr, Ogre::Real x, Ogre::Real y, Ogre::Real z) {
    Ogre::SceneManager::MovableObjectIterator it= mSceneMgr.getMovableObjectIterator("Entity");
    Ogre::Real lowestY = 10;
    _mSceneMgr = &mSceneMgr;

    while (it.hasMoreElements())
    {
        std::string _name = it.getNext()->getName();

        if (_name != "GroundEntity" && _name != "RoboOgre") {
            try {
                std::vector<std::string> _temp = Cube::split(_name, ':');
                // 0:'Cube' 1:'x' 2:'y' 3:'z'
                if (_temp[0] == "Cube") {
                    int _tempX;
                    std::istringstream iss1(_temp[1]);
                    iss1 >> _tempX;
                    int _tempY;
                    std::istringstream iss2(_temp[2]);
                    iss2 >> _tempY;
                    int _tempZ;
                    std::istringstream iss3(_temp[3]);
                    iss3 >> _tempZ;
                    if (_tempX > (x - 25) && _tempX < (x + 25) && _tempZ > (z - 25) && _tempZ < (z + 25))
                    {
                        if (lowestY <= _tempY) lowestY = _tempY+25;
                    }
                }
            }
            catch (...) {    }
        }
    }
    _name = "Cube:"+Ogre::StringConverter::toString(x,6,0, '_',0) +":"+ Ogre::StringConverter::toString(lowestY,6,0, '_',0)+":"+Ogre::StringConverter::toString(z,6,0, '_',0);

    _cubeEntity = mSceneMgr.createEntity(_name, "cube.mesh");

    _cubeNode = mSceneMgr.getRootSceneNode()->createChildSceneNode();

    _cubeNode->attachObject(_cubeEntity);

    _cubeNode->showBoundingBox(true);

    _cubeEntity->setCastShadows(true);

    _cubeNode->setPosition(x, lowestY, z);

    _cubeNode->scale(CUBE_SCALE, CUBE_SCALE, CUBE_SCALE);

}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
size_t ChValidation::ReadDataFile(const std::string& filename,
                                  char               delim,
                                  Headers&           headers,
                                  Data&              data)
{
  std::ifstream ifile(filename.c_str());
  std::string   line;

  // Count the number of lines in the file then rewind the input file stream.
  size_t num_lines = std::count(std::istreambuf_iterator<char>(ifile),
                                std::istreambuf_iterator<char>(), '\n');
  ifile.seekg(0, ifile.beg);

  size_t num_data_points = num_lines - 3;

  // Skip the first two lines.
  std::getline(ifile, line);
  std::getline(ifile, line);

  // Read the line with column headers.
  std::getline(ifile, line);
  std::stringstream iss1(line);
  std::string col_header = "";

  while (std::getline(iss1, col_header, delim))
    headers.push_back(col_header);

  size_t num_cols = headers.size();

  // Resize data
  data.resize(num_cols);
  for (size_t col = 0; col < num_cols; col++)
    data[col].resize(num_data_points);

  // Read the actual data, one line at a time.
  size_t row = 0;
  while (std::getline(ifile, line)) {
    std::stringstream iss(line);
    for (size_t col = 0; col < num_cols; col++)
      iss >> data[col][row];
    row++;
  }

  return row;
}
Beispiel #10
0
RTC::ReturnCode_t ObjectRTC::onInitialize()
{
  // Registration: InPort/OutPort/Service
  // <rtc-template block="registration">
  // Set InPort buffers

  // Set OutPort buffer
  addOutPort("pose", m_poseOut);

  // Set service provider to Ports
  
  // Set service consumers to Ports
  
  // Set CORBA Service Ports
  
  // </rtc-template>

  // <rtc-template block="bind_config">
  // Bind variables and configuration variable
  bindParameter("objectName", m_objectName, "none");
  //bindParameter("geometry_offset", m_offsetStr, "0,0,0,0,0,0");
  //bindParameter("maxObject", m_maxObject, "30.0");
  //bindParameter("minObject", m_minObject, "0.3");
  // </rtc-template>


  std::cout << " - Initializing ObjectRTC: " << m_properties.getProperty("conf.default.objectName") << std::endl;

  /*
  std::string tubehandle = m_properties.getProperty("conf.__innerparam.tubeHandle");
  std::istringstream iss0(tubehandle);
  iss0 >> m_tubeHandle;
  std::cout << " -- TubeHandle = " << m_tubeHandle << std::endl;
  */
  std::string objhandle = m_properties.getProperty("conf.__innerparam.objectHandle");
  std::istringstream iss1(objhandle);
  iss1 >> m_objectHandle;
  /*
  std::string buflength = m_properties.getProperty("conf.__innerparam.bufSize");
  std::istringstream iss2(buflength);
  iss2 >> m_bufferSize;
  m_pBuffer = new uint8_t[m_bufferSize];
  */
  return RTC::RTC_OK;
}
void test_basic_with_assign_template(
  ForwardIterator first,ForwardIterator last
  BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Flyweight))
{
  typedef typename Flyweight::value_type value_type;

  ForwardIterator it;

  test_basic_template<Flyweight>(first,last);

  for(it=first;it!=last;++it){
    /* value construction */

    value_type v(*it);
    Flyweight  f1(v);
    Flyweight  f2(f1.get());
    BOOST_TEST(f1.get()==v);
    BOOST_TEST(f2.get()==v);
    BOOST_TEST(f1==f2);

    /* value assignment */

    Flyweight f3,f4;
    f3=v;
    f4=f1.get();
    BOOST_TEST(f2.get()==v);
    BOOST_TEST(f3.get()==v);
    BOOST_TEST(f2==f3);

    /* specialized algorithms */

    std::ostringstream oss1;
    oss1<<f1;
    std::istringstream iss1(oss1.str());
    Flyweight f5;
    iss1>>f5;
    BOOST_TEST(f5==f1);
  }
}
Beispiel #12
0
// -----------------------------------------------------------------------------
// ReadCheckpoint
//
//
// -----------------------------------------------------------------------------
void ReadCheckpoint(ChSystem*          system,
                    const std::string& filename)
{
  // Open input file stream
  std::ifstream      ifile(filename.c_str());
  std::string        line;

  while (std::getline(ifile, line)) {
    std::istringstream iss1(line);

    // Read body type, Id, flags
    int btype, bid, bfixed, bcollide;
    iss1 >> btype >> bid >> bfixed >> bcollide;

    // Read body mass and inertia
    double     mass;
    ChVector<> inertiaXX;
    iss1 >> mass >> inertiaXX.x >> inertiaXX.y >> inertiaXX.z;

    // Read body position, orientation, and their time derivatives
    ChVector<>     bpos, bpos_dt;
    ChQuaternion<> brot, brot_dt;
    iss1 >> bpos.x >> bpos.y >> bpos.z >> brot.e0 >> brot.e1 >> brot.e2 >> brot.e3;
    iss1 >> bpos_dt.x >> bpos_dt.y >> bpos_dt.z >> brot_dt.e0 >> brot_dt.e1 >> brot_dt.e2 >> brot_dt.e3;

    // Get the next line in the file (material properties)
    std::getline(ifile, line);
    std::istringstream iss2(line);

    // Create a body of the appropriate type, read and apply material properties
    ChBody* body;
    if (btype == 0) {
      body = new ChBody(ChBody::DVI);
      ChSharedPtr<ChMaterialSurface> mat = body->GetMaterialSurface();
      iss2 >> mat->static_friction >> mat->sliding_friction >> mat->rolling_friction >> mat->spinning_friction;
      iss2 >> mat->restitution >> mat->cohesion >> mat->dampingf;
      iss2 >> mat->compliance >> mat->complianceT >> mat->complianceRoll >> mat->complianceSpin;
    } else {
  int IntegerRangeListValidator<Integral>::breakRange(
    std::string &range, std::string &from, std::string &to)
{
  from.clear();
  to.clear();
  std::string::size_type loc = range.find(rangeDelim_);
  if (loc == std::string::npos){
    from = range;
  }
  else{
    from = range.substr(0, loc);
    to = range.substr(loc+1, range.size());
  }
  long a, b;
  std::istringstream iss1(from);
  iss1 >> a;
  b = a;
  if (to.size() > 0){
    std::istringstream iss2(to);
    iss2 >> b;
    if (b < a)
      std::swap(from,to);
  }
Beispiel #14
0
void define_data(IloEnv env) {
  string line("           ");
  ifstream myfile ("/home/DavidRC/data.txt");
  int i=0;
  int j=0;
  int x=0;
  int y=0;

  if (myfile.is_open())
  {
    i=0;
	  j=0;
    
	  getline(myfile,line);
	  n=atoi(line.c_str());
	  IloNumArray l(env,n);
	  NumMatrix w(env,n);
    
    for(i=0; i<n; i++)
    {
      w[i]=IloNumArray(env,n);
    }
	  
	  getline (myfile,line);
    
	  istringstream iss1(line);  
	  	while (iss1 && j<n) 
		{ 
			string subs; 
			iss1 >> subs; 
			string temp=subs;
			if(temp.compare("")==0)
			{
				continue;
			}
			else
			{

            l[j]=atoi(subs.c_str());
			}
			j++;
	    }
     exit(1);

     i=0;
	 j=0;
	 while ( getline (myfile,line) && i<n)
     {
	    istringstream iss2(line);
          j=0;

		while (iss2 && j<n) 
		{ 
			string subs; 
			iss2 >> subs; 
			string temp=subs;

			if(temp.compare("")==0)
			{
				continue;
                        j++;
			}
			else
			{

            w[i][j]=atoi(subs.c_str());
            			j++;
			}
	    }
		i++;
    }

	  m=atoi( line.c_str() );

    IloNumArray c(env,m);
	  NumMatrix d(env,m);
    
    for(i=0; i<m; i++)
    {
      d[i]=IloNumArray(env,m);
    } 
		  
  i=0;
  j=0;    
	getline (myfile,line);
	istringstream iss3(line);
	while (iss3 && j<m) 
	{ 
		string subs; 
		iss3 >> subs; 
		string temp=subs;
		if(temp.compare("")==0)
		{
			continue;
		}
		else
		{
           c[j]=atoi(subs.c_str());
		}
		j++;
	}
		
	i=0;
	j=0;
	while ( getline (myfile,line) && i<m)
    {
	    istringstream iss4(line);
          j=0;
		while (iss4 && j<m) 
		{ 
			string subs; 
			iss4 >> subs; 
			string temp=subs;
			if(temp.compare("")==0)
			{
				continue;
			}
			else
			{
            d[i][j]=atoi(subs.c_str());
			}
			j++;
	    }
		i++;
    }
    myfile.close();
  }
Beispiel #15
0
//NOTE: The file index starts at 1, but we'll subtract one
//      to match vector index.
void readInFromFile( vector<Node> &g, string fileName )
{
    //clear g
    g = {};
    
    Node emptyNode;
    
    ifstream inFile( fileName, ios::in );
    if ( !inFile )
    {
        cerr << endl << "File could not be opened." << endl << endl;
        exit(1);
    }
    
    string line;
    
    while( getline(inFile, line) )
    {
        istringstream iss1(line);
        string tab;
        
        string sindex;
        long index;
        getline(iss1, sindex, '\t');
        istringstream issIndex(sindex);
        issIndex >> index;
        //Make index match array index
        --index;
        //cout << "Index: " << index << endl;
        
        //Add a node
        g.push_back(emptyNode);

        
        
        while( getline(iss1, tab, '\t') )
        {
            //extra crap (like space or newline) in last iteration
            if( tab.length() >= 3 )
            {
                istringstream iss2(tab);
                
                string comma;
                
                int counter = 0;
                long iVert = -1000;
                long edgeDist = -1000;
                while( getline(iss2, comma, ',') )
                {
                    istringstream iss3(comma);
                    
                    if( counter == 0 )
                    {
                        iss3 >> iVert;
                        //Make vertex match array index
                        --iVert;
                        counter++;
                    }
                    else if( counter == 1 )
                    {
                        iss3 >> edgeDist;
                        counter++;
                    }
                    else
Beispiel #16
0
bool PMCSQS_Scorer::read_pmc_rank_models(Config *_config, char *file_name)
{
	config = _config;

	string path = config->get_resource_dir() + "/" + file_name;
	ifstream in_stream(path.c_str(),ios::in);
	if (! in_stream.good())
	{
		cout << "Warning: couldn't open pmc rank model for reading: " << path << endl;
		return false;
	}


	char buff[512];
	int num_charges=-1;

	in_stream.getline(buff,256);
	istringstream iss1(buff);

	frag_pair_sum_offset=NEG_INF;
	bin_increment=NEG_INF;
	iss1 >> bin_increment >> this->frag_pair_sum_offset;
	if (frag_pair_sum_offset==NEG_INF || bin_increment == NEG_INF)
	{
		cout << "Error in pmc model file!" << endl;
		exit(1);
	}

	in_stream.getline(buff,256);
	istringstream iss(buff);

	iss >> num_charges;
	max_model_charge=num_charges-1;
	
	pmc_rank_models.resize(num_charges);
	pmc_rank_mass_thresholds.resize(num_charges);
	pmc_charge_mz_biases.resize(num_charges);


	int i;
	for (i=0; i<num_charges; i++)
	{
		in_stream.getline(buff,256);
		istringstream iss(buff);
		int num_threshes=0;
		iss >> num_threshes;
		
		pmc_rank_mass_thresholds[i].resize(num_threshes,NEG_INF);
		int j;
		for (j=0; j<num_threshes; j++)
			iss >> pmc_rank_mass_thresholds[i][j];
	}

	for (i=0; i<num_charges; i++)
	{
		in_stream.getline(buff,256);
		istringstream iss(buff);
		int num_biases=0;
		iss >> num_biases;
		
		pmc_charge_mz_biases[i].resize(num_biases,NEG_INF);
		int j;
		for (j=0; j<num_biases; j++)
			iss >> pmc_charge_mz_biases[i][j];
	}
	
	// read Boost models
	for (i=0; i<num_charges; i++)
	{
		in_stream.getline(buff,256);
		istringstream iss(buff);

		int num_models=-1;
		iss >> num_models;

		if (num_models<0)
		{
			cout << "Error: bad parsing of PMCR model file!" << endl;
			exit(0);
		}
		pmc_rank_models[i].resize(num_models,NULL);

		int j;
		for (j=0; j<num_models; j++)
		{
			pmc_rank_models[i][j]=new RankBoostModel;
			pmc_rank_models[i][j]->read_rankboost_model(in_stream);
		}
		
	}
	in_stream.close();

//	this->write_pmc_rank_models("XXX.txt");

	this->ind_initialized_pmcr = true;
	return true;
}
void ComponentFactory::ParseType(Serializer& _ser, tinyxml2::XMLElement* _element)
{
	const natChar *type_str = _element->Attribute("type");
	ref_t type = Hash::Compute(type_str);

	if(type == s_type_ref_t)
	{
		const natChar* value = _element->Attribute("value");
		ref_t ref;
		if(strcmp(value, "") != 0)
		{
			ref = Hash::Compute(value);
		}
		else
		{
			ref = 0;
		}

		_ser << ref;
	}
	else if(type == s_type_tex_t)
	{
		const natChar* value = _element->Attribute("value");
		ref_t ref;
		if(strcmp(value, "") != 0)
		{
			ref = Hash::Compute(value);

			// add it to preload
			TextureManager* texturemanager = GetEntity()->GetKernel()->GetLayer(Layer::s_LayerManager)->GetRootEntity()->GetComponent<TextureManager>();
			texturemanager->Preload(value);
		}
		else
		{
			ref = 0;
		}

		_ser << ref;
	}
	else if(type == s_type_natBool)
	{
		natBool value = _element->BoolAttribute("value");
		_ser << value;
	}
	else if(type == s_type_natChar)
	{
		const natChar* value = _element->Attribute("value");
		natChar value0 = value[0];
		_ser << value0;
	}
	else if(type == s_type_natU8)
	{
		const natU8* value = reinterpret_cast<const natU8*>(_element->Attribute("value"));
		natU8 value0 = value[0];
		_ser << value0;
	}
	else if(type == s_type_natS8)
	{
		const natS8* value = reinterpret_cast<const natS8*>(_element->Attribute("value"));
		natS8 value0 = value[0];
		_ser << value0;
	}
	else if(type == s_type_natU16)
	{
		natU16 value = static_cast<natU16>(_element->IntAttribute("value"));
		_ser << value;
	}
	else if(type == s_type_natS16)
	{
		natS16 value = static_cast<natS16>(_element->IntAttribute("value"));
		_ser << value;
	}
	else if(type == s_type_natU32)
	{
		natU32 value = static_cast<natU32>(_element->IntAttribute("value"));
		_ser << value;
	}
	else if(type == s_type_natS32)
	{
		natS32 value = static_cast<natS32>(_element->IntAttribute("value"));
		_ser << value;
	}
	else if(type == s_type_natU64)
	{
		natU64 value = static_cast<natU64>(_element->IntAttribute("value"));
		_ser << value;
	}
	else if(type == s_type_natS64)
	{
		natS64 value = static_cast<natS64>(_element->IntAttribute("value"));
		_ser << value;
	}
	else if(type == s_type_natF32)
	{
		natF32 value = static_cast<natF32>(_element->FloatAttribute("value"));
		_ser << value;
	}
	else if(type == s_type_natF64)
	{
		natF64 value = static_cast<natF64>(_element->DoubleAttribute("value"));
		_ser << value;
	}
	else if(type == s_type_std_string)
	{
		const natChar* value = _element->Attribute("value");
		std::string str = value;
		_ser << str;
	}
	else if(type == s_type_glm_vec2)
	{
		// ugly stl
		const natChar* value = _element->Attribute("value");
		std::istringstream iss(value);

		std::string value0;
		std::string value1;

		glm::vec2 ret;
		std::getline(iss, value0, ' ');
		if(!std::getline(iss, value1, ' '))
		{
			value1 = "0";
		}

		std::istringstream iss0(value0);
		iss0 >> ret.x;

		std::istringstream iss1(value1);
		iss1 >> ret.y;

		_ser << ret;
	}
	else if(type == s_type_glm_vec3)
Beispiel #18
0
void test2Gaps() {
    geryon::server::GUniformMemoryPool pool(BUF_SZ, 1, 0);
    std::vector<geryon::server::GBufferHandler> buffers;

    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(0).get().buffer()[0] = 'a'; //0
    buffers.at(0).get().buffer()[1] = 'X'; //1
    buffers.at(0).get().buffer()[2] = 'a'; //2
    buffers.at(0).get().setMarker(3);

    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(1).get().buffer()[0] = 'b'; //3
    buffers.at(1).get().buffer()[1] = 'b'; //4
    buffers.at(1).get().buffer()[2] = 'X'; //5
    buffers.at(1).get().buffer()[3] = 'X'; //6
    buffers.at(1).get().buffer()[4] = 'b'; //7
    buffers.at(1).get().setMarker(5);

    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(2).get().buffer()[0] = 'c'; //8
    buffers.at(2).get().buffer()[1] = 'c'; //9
    buffers.at(2).get().buffer()[2] = 'c'; //10
    buffers.at(2).get().buffer()[3] = 'X'; //11
    buffers.at(2).get().setMarker(4);

    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(3).get().buffer()[0] = 'X'; //12
    buffers.at(3).get().buffer()[1] = 'd'; //13
    buffers.at(3).get().buffer()[2] = 'd'; //14
    buffers.at(3).get().buffer()[3] = 'X'; //15
    buffers.at(3).get().setMarker(4);

    //1st test : aabbbcccdd
    geryon::server::GIstreambuff buff1(buffers);
    buff1.addGap(1, 2);
    buff1.addGap(5, 7);
    buff1.addGap(11, 13);
    buff1.addGap(15, 16);
    buff1.setup(0, 16);
    std::istream iss1(&buff1);
    std::string s;
    iss1 >> s; //our stream
    if("aabbbcccdd" != s) {
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed test2Gaps (1)";
    }
    std::cout << "String 1 is >>" << s << "<<" << std::endl;

    //2nd test: putback stuff
    geryon::server::GIstreambuff buff2(buffers);
    buff2.addGap(1, 2);
    buff2.addGap(5, 7);
    buff2.addGap(11, 13);
    buff2.addGap(15, 16);
    buff2.setup(0, 16);

    std::istream iss2(&buff2);
    char c;
    iss2 >> c; //a 0
    if(c != 'a'){
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed test2Gaps (2.0) found:" << c;
    }
    iss2.putback(c); //0
    iss2 >> c; //a 0
    if(c != 'a'){
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed test2Gaps (2.1) found:" << c;
    }
    iss2 >> c; //a 2
    if(c != 'a'){
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed test2Gaps (2.2) found:" << c;
    }
    iss2.putback(c); //2
    iss2 >> c; //a 2
    if(c != 'a'){
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed test2Gaps (2.3) found:" << c;
    }
    iss2 >> c; //b 3
    if(c != 'b'){
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed test2Gaps (2.4) found:" << c;
    }
    iss2 >> c; //b 4
    iss2.putback(c); //4
    iss2 >> c; //b 4
    if(c != 'b'){
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed test2Gaps (2.5) found:" << c;
    }
    iss2 >> c; //b 7
    if(c != 'b'){
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed test2Gaps (2.6) found:" << c;
    }
    iss2 >> s;

    if("cccdd" != s) {
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed test2Gaps (3)";
    }
    std::cout << "String 2 is >>" << s << "<<" << std::endl;
}
Beispiel #19
0
void test1() {
    geryon::server::GUniformMemoryPool pool(BUF_SZ, 1, 0);
    std::vector<geryon::server::GBufferHandler> buffers;

    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(0).get().buffer()[0] = 'a'; //0
    buffers.at(0).get().buffer()[1] = 'a'; //1
    buffers.at(0).get().setMarker(2);

    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(1).get().buffer()[0] = 'b'; //2
    buffers.at(1).get().buffer()[1] = 'b'; //3
    buffers.at(1).get().buffer()[2] = 'b'; //4
    buffers.at(1).get().setMarker(3);

    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(2).get().buffer()[0] = 'c'; //5
    buffers.at(2).get().buffer()[1] = 'c'; //6
    buffers.at(2).get().buffer()[2] = 'c'; //7
    buffers.at(2).get().buffer()[3] = 'c'; //8
    buffers.at(2).get().setMarker(4);

    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(3).get().buffer()[0] = 'd'; //9
    buffers.at(3).get().setMarker(1);

    //1st test : abbbc
    geryon::server::GIstreambuff buff1(buffers, 1, 6);
    std::istream iss1(&buff1);
    std::string s;
    iss1 >> s; //our stream
    if("abbbc" != s) {
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed (1)";
    }
    std::cout << "String 1 is >>" << s << "<<" << std::endl;

    //2nd test: all aabbbccccd
    geryon::server::GIstreambuff buff2(buffers, 0, 10);
    std::istream iss2(&buff2);
    iss2 >> s; //our stream
    if("aabbbccccd" != s) {
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed (2)";
    }
    std::cout << "String 2 is >>" << s << "<<" << std::endl;

    //3rd test: reset the stream
    buff2.setup(1,9);
    std::istream iss2_1(&buff2); //our stream
    iss2_1 >> s;
    if("abbbcccc" != s) {
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed (3.1)";
    }
    std::cout << "String 3.1 is >>" << s << "<<" << std::endl;
    buff2.setup(2,8);
    iss2.rdbuf(&buff2);
    iss2 >> s;
    if("bbbccc" != s) {
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed (3.2)";
    }
    std::cout << "String 3.2 is >>" << s << "<<" << std::endl;


    //4th test: empty (EOF)
    geryon::server::GIstreambuff buff3(buffers, 0, 0);
    std::istream iss3(&buff3);
    if(iss3 >> s) { //yeap, this should return false
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed (4)";
    }
    std::cout << "String 4 is >>" << s << "<<" << std::endl; //unchanged
}
Beispiel #20
0
void test1Gaps() {
    geryon::server::GUniformMemoryPool pool(BUF_SZ, 1, 0);
    std::vector<geryon::server::GBufferHandler> buffers;
    
    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(0).get().buffer()[0] = 'a'; //0
    buffers.at(0).get().buffer()[1] = 'X'; //1
    buffers.at(0).get().buffer()[2] = 'a'; //2
    buffers.at(0).get().setMarker(3);
    
    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(1).get().buffer()[0] = 'b'; //3
    buffers.at(1).get().buffer()[1] = 'b'; //4
    buffers.at(1).get().buffer()[2] = 'X'; //5
    buffers.at(1).get().buffer()[3] = 'X'; //6
    buffers.at(1).get().buffer()[4] = 'b'; //7
    buffers.at(1).get().setMarker(5);
    
    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(2).get().buffer()[0] = 'c'; //8
    buffers.at(2).get().buffer()[1] = 'c'; //9
    buffers.at(2).get().buffer()[2] = 'c'; //10
    buffers.at(2).get().buffer()[3] = 'X'; //11
    buffers.at(2).get().setMarker(4);
    
    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(3).get().buffer()[0] = 'X'; //12
    buffers.at(3).get().buffer()[1] = 'd'; //13
    buffers.at(3).get().buffer()[2] = 'd'; //14
    buffers.at(3).get().buffer()[3] = 'X'; //15
    buffers.at(3).get().setMarker(4);
    
    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(4).get().buffer()[0] = 'X'; //16
    buffers.at(4).get().buffer()[1] = 'e'; //17
    buffers.at(4).get().buffer()[2] = 'e'; //18
    buffers.at(4).get().buffer()[3] = 'X'; //19
    buffers.at(4).get().setMarker(4);
    
    
    buffers.push_back(std::move(geryon::server::GBufferHandler(&pool)));
    buffers.at(5).get().buffer()[0] = 'X'; //19
    buffers.at(5).get().setMarker(1);
    
    //1st test : abb
    geryon::server::GIstreambuff buff1(buffers);
    buff1.addGap(1, 2);
    buff1.setup(1, 5);
    std::istream iss1(&buff1);
    std::string s;
    iss1 >> s; //our stream
    if("abb" != s) {
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed test1Gaps (1)";
    }
    std::cout << "String 1 is >>" << s << "<<" << std::endl;
    
    //2nd test: all abbbcccddee
    geryon::server::GIstreambuff buff2(buffers);
    buff2.addGap(1, 2);
    buff2.addGap(5, 7);
    buff2.addGap(11, 13);
    buff2.addGap(15, 17);
    buff2.addGap(19, 20);
    buff2.setup(1, 20);
    std::istream iss2(&buff2);
    iss2 >> s; //our stream
    if("abbbcccddee" != s) {
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed test1Gaps (2)";
    }
    std::cout << "String 2 is >>" << s << "<<" << std::endl;
    
    //3rd test: reset the stream
    buff2.setup(2,4);
    std::istream iss2_1(&buff2); //our stream
    iss2_1 >> s;
    if("ab" != s) {
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed test1Gaps (3.1)";
    }
    std::cout << "String 3.1 is >>" << s << "<<" << std::endl;
    buff2.addGap(11, 13);
    buff2.addGap(15, 17);
    buff2.setup(11,18);
    iss2.rdbuf(&buff2);
    iss2 >> s;
    if("dde" != s) {
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed test1Gaps (3.2)";
    }
    std::cout << "String 3.2 is >>" << s << "<<" << std::endl;
    
    
    //4th test: empty (EOF)
    geryon::server::GIstreambuff buff3(buffers);
    buff3.addGap(11, 13);
    buff2.setup(11,13);
    std::istream iss3(&buff3);
    if(iss3 >> s) { //yeap, this should return false
        LOG(geryon::util::Log::ERROR) << "ERROR: Failed test1Gaps (4)";
    }
    std::cout << "String 4 is >>" << s << "<<" << std::endl; //unchanged
}
Beispiel #21
0
void Correlation::getParameters(string filename, int start, int stop)
{
  chainName=filename;
  double tmp;
  string strtmp;
  try {
    burnin=start;
    nbsample = stop-start;
    if(nbsample<=0)
      {
	cerr << "ERROR: in Correlation::getParameters, asking sampling from point " << start << " to point "<< stop <<", exiting\n";
	cerr.flush();
	throw(0);
      }
    ifstream *is=new ifstream;
    is->open(filename.c_str(), ifstream::in);

    char line[100000];
    string strline;
    is->getline(line,100000);
    strline=line;
    istringstream iss1(strline);

    nbparameter=0;

	/*ALL*/
    iss1 >> strtmp;
    iss1 >> strtmp;
    iss1 >> strtmp;
	/*ALL*/

    strtmp="null";

    while(iss1.good())
      {
	iss1 >> strtmp;
	nbparameter++;
      }
    init();
    istringstream iss2(strline);

	/*ALL*/
    iss2 >> strtmp;
    iss2 >> strtmp;
    iss2 >> strtmp;
	/*ALL*/

    for(int j=0;j<nbparameter;j++)
      iss2 >> parameterName[j];

    createParameterBuffer();
    createWeight();

    for(int i=0;i<stop;i++)
      {

	/*ALL*/
	*is >> tmp;
	*is >> tmp;
	*is >> tmp;
	/*ALL*/

	for(int j=0;j<nbparameter;j++)
	  {
	    *is >> tmp;

	    if(i>=burnin)
	      {
		parameters[j][i-burnin]=tmp;
	      }
	  }
      }
    delete is;
  } catch(...) {
    cerr << "ERROR while reading " << filename << "\n";
    cerr.flush();
    exit(0);
  }
}