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


C++ Observations::get_data_vec方法代码示例

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


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

示例1: update_run

void RunStorage::update_run(int run_id, const Parameters &pars, const Observations &obs)
{
	//set run status flage to complete
	std::int8_t r_status = 1;
	check_rec_id(run_id);
	vector<double> par_data(pars.get_data_vec(par_names));
	vector<double> obs_data(obs.get_data_vec(obs_names));
	//write data to buffer at end of file and set buffer flag to 1
	std::int8_t buf_status = 0;
	std::int32_t buf_run_id = run_id;
	int end_of_runs = get_nruns();
	buf_stream.seekp(get_stream_pos(end_of_runs), ios_base::beg);
	buf_stream.write(reinterpret_cast<char*>(&buf_status), sizeof(buf_status));
	buf_stream.write(reinterpret_cast<char*>(&buf_run_id), sizeof(buf_run_id));
	buf_stream.write(reinterpret_cast<char*>(&r_status), sizeof(r_status));
	buf_stream.write(reinterpret_cast<char*>(par_data.data()), par_data.size() * sizeof(double));
	buf_stream.write(reinterpret_cast<char*>(obs_data.data()), obs_data.size() * sizeof(double));
	buf_status = 1;
	buf_stream.seekp(get_stream_pos(end_of_runs), ios_base::beg);
	buf_stream.write(reinterpret_cast<char*>(&buf_status), sizeof(buf_status));
	buf_stream.flush();
	//write data
	buf_stream.seekp(get_stream_pos(run_id), ios_base::beg);
	buf_stream.write(reinterpret_cast<char*>(&r_status), sizeof(r_status));
	//skip over info_txt and info_value fields
	buf_stream.seekp(sizeof(char)*info_txt_length+sizeof(double), ios_base::cur);
	buf_stream.write(reinterpret_cast<char*>(par_data.data()), par_data.size() * sizeof(double));
	buf_stream.write(reinterpret_cast<char*>(obs_data.data()), obs_data.size() * sizeof(double));
	buf_stream.flush();
	//reset flag for buffer at end of file to 0 to signal it is no longer relavent
	buf_status = 0;
	buf_stream.seekp(get_stream_pos(end_of_runs), ios_base::beg);
	buf_stream.write(reinterpret_cast<char*>(&buf_status), sizeof(buf_status));
	buf_stream.flush();
}
开发者ID:smwesten-usgs,项目名称:pestpp,代码行数:35,代码来源:RunStorage.cpp

示例2: sizeof

vector<char> Serialization::serialize(const Parameters &pars, const vector<string> &par_names_vec, const Observations &obs, const vector<string> &obs_names_vec)
{

	assert(pars.size() == par_names_vec.size());
	assert(obs.size() == obs_names_vec.size());
	vector<char> serial_data;
	size_t npar = par_names_vec.size();
	size_t nobs = obs_names_vec.size();
	size_t par_buf_sz = npar * sizeof(double);
	size_t obs_buf_sz = nobs * sizeof(double);
	serial_data.resize(par_buf_sz + obs_buf_sz, Parameters::no_data);

	char *buf = &serial_data[0];
	vector<double> par_data = pars.get_data_vec(par_names_vec);
	w_memcpy_s(buf, par_buf_sz, &par_data[0], par_data.size() * sizeof(double));

	vector<double> obs_data = obs.get_data_vec(obs_names_vec);
	w_memcpy_s(buf+par_buf_sz, obs_buf_sz, &obs_data[0], obs_data.size() * sizeof(double));
	return serial_data;
}
开发者ID:odellus,项目名称:pestpp,代码行数:20,代码来源:Serializeation.cpp


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