本文整理汇总了C++中boost::circular_buffer::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ circular_buffer::push_back方法的具体用法?C++ circular_buffer::push_back怎么用?C++ circular_buffer::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::circular_buffer
的用法示例。
在下文中一共展示了circular_buffer::push_back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_buffer_loader
void set_buffer_loader(EASYRPG_SHARED_PTR<buffer_loader> const &l) {
SET_CONTEXT(ctx_);
alSourceStop(src_);
alSourcei(src_, AL_BUFFER, AL_NONE);
if (not l) {
loader_.reset();
return;
}
ALint unqueuing_count;
alGetSourceiv(src_, AL_BUFFERS_QUEUED, &unqueuing_count);
std::vector<ALuint> unqueued(unqueuing_count);
alSourceUnqueueBuffers(src_, unqueuing_count, &unqueued.front());
loader_ = l;
int queuing_count = 0;
BOOST_ASSERT(not l->is_end());
ticks_.push_back(0);
for (; queuing_count < BUFFER_NUMBER; ++queuing_count) {
buf_sizes_.push_back(loader_->load_buffer(buffers_[queuing_count]));
ticks_.push_back(loader_->midi_ticks());
if (loader_->is_end()) {
queuing_count++;
break;
}
}
alSourceQueueBuffers(src_, queuing_count, buffers_.data());
alSourcePlay(src_);
}
示例2: controlCallback
void WaypointVelocityVisualizer::controlCallback(const geometry_msgs::PoseStamped::ConstPtr& current_pose_msg,
const geometry_msgs::TwistStamped::ConstPtr& current_twist_msg,
const geometry_msgs::TwistStamped::ConstPtr& command_twist_msg)
{
// buffers are reset when time goes back, e.g. playback rosbag
ros::Time current_time = ros::Time::now();
if (previous_time_ > current_time)
{
ROS_WARN("Detected jump back in time of %.3fs. Clearing markers and buffers.",
(previous_time_ - current_time).toSec());
deleteMarkers(); // call 'DELETEALL'
resetBuffers(); // clear circular buffers
}
previous_time_ = current_time;
// if plot_metric_interval <= 0, velocity is plotted by each callback.
if (plot_metric_interval_ > 0 && current_pose_buf_.size() > 0)
{
tf::Vector3 p1, p2;
tf::pointMsgToTF(current_pose_buf_.back().pose.position, p1);
tf::pointMsgToTF(current_pose_msg->pose.position, p2);
if (!(p1.distance(p2) > plot_metric_interval_))
return; // skipping plot
}
current_pose_buf_.push_back(*current_pose_msg);
current_twist_buf_.push_back(*current_twist_msg);
command_twist_buf_.push_back(*command_twist_msg);
current_twist_marker_array_.markers.clear();
command_twist_marker_array_.markers.clear();
createVelocityMarker(current_pose_buf_, current_twist_buf_, "current_velocity", current_twist_color_,
current_twist_marker_array_);
createVelocityMarker(current_pose_buf_, command_twist_buf_, "twist_cmd", command_twist_color_,
command_twist_marker_array_);
publishVelocityMarker();
}
示例3: update
void update() {
ALint processed;
alGetSourceiv(src_, AL_BUFFERS_PROCESSED, &processed);
std::vector<ALuint> unqueued(processed);
alSourceUnqueueBuffers(src_, processed, &unqueued.front());
int queuing_count = 0;
for (; queuing_count < processed; ++queuing_count) {
if (not loop_play_ and loader_->is_end()) {
loader_.reset();
++queuing_count;
break;
}
if (loader_->is_end()) {
ticks_.push_back(0);
}
buf_sizes_.push_back(loader_->load_buffer(unqueued[queuing_count]));
ticks_.push_back(loader_->midi_ticks());
}
alSourceQueueBuffers(src_, queuing_count, &unqueued.front());
if (fade_milli_ != 0) {
SET_CONTEXT(ctx_);
loop_count_++;
if (fade_ended()) {
alSourceStop(src_);
} else {
alSourcef(src_, AL_GAIN, current_volume());
}
}
}
示例4: write
/** Try to write a value to the pipe
\param[in] value is what we want to write
\param[in] blocking specify if the call wait for the operation
to succeed
\return true on success
\todo provide a && version
*/
bool write(const T &value, bool blocking = false) {
// Lock the pipe to avoid being disturbed
std::unique_lock<std::mutex> ul { cb_mutex };
TRISYCL_DUMP_T("Write pipe full = " << full()
<< " value = " << value);
if (blocking)
/* If in blocking mode, wait for the not full condition, that
may be changed when a read is done */
read_done.wait(ul, [&] { return !full(); });
else if (full())
return false;
cb.push_back(value);
TRISYCL_DUMP_T("Write pipe front = " << cb.front()
<< " back = " << cb.back()
<< " cb.begin() = " << (void *)&*cb.begin()
<< " cb.size() = " << cb.size()
<< " cb.end() = " << (void *)&*cb.end()
<< " reserved_for_reading() = " << reserved_for_reading()
<< " reserved_for_writing() = " << reserved_for_writing());
// Notify the clients waiting to read something from the pipe
write_done.notify_all();
return true;
}
示例5: LoadChatHistory
bool PythonServer::LoadChatHistory(boost::circular_buffer<ChatHistoryEntity>& chat_history) {
boost::python::object chat_provider = m_python_module_chat.attr("__dict__")["chat_history_provider"];
if (!chat_provider) {
ErrorLogger() << "Unable to get Python object chat_history_provider";
return false;
}
boost::python::object f = chat_provider.attr("load_history");
if (!f) {
ErrorLogger() << "Unable to call Python method load_history";
return false;
}
boost::python::object r = f();
boost::python::extract<list> py_history(r);
if (py_history.check()) {
boost::python::stl_input_iterator<boost::python::tuple> entity_begin(py_history), entity_end;
for (auto& it = entity_begin; it != entity_end; ++ it) {
ChatHistoryEntity e;
e.m_timestamp = boost::posix_time::from_time_t(boost::python::extract<time_t>((*it)[0]));;
e.m_player_name = boost::python::extract<std::string>((*it)[1]);
e.m_text = boost::python::extract<std::string>((*it)[2]);
e.m_text_color = boost::python::extract<GG::Clr>((*it)[3]);
chat_history.push_back(e);
}
}
return true;
}
示例6: render
void render(sf::RenderTarget& target)
{
float dx = 1.0f/static_cast<float>(line_data_.capacity());
float x = static_cast<float>(line_data_.capacity()-line_data_.size())*dx;
line_data_.push_back(std::make_pair(tick_data_, tick_tag_));
tick_tag_ = false;
glBegin(GL_LINE_STRIP);
auto c = color(color_);
glColor4f(std::get<0>(c), std::get<1>(c), std::get<2>(c), 0.8f);
for(size_t n = 0; n < line_data_.size(); ++n)
if(line_data_[n].first > -0.5)
glVertex3d(x+n*dx, std::max(0.05, std::min(0.95, (1.0f-line_data_[n].first)*0.8 + 0.1f)), 0.0);
glEnd();
glEnable(GL_LINE_STIPPLE);
glLineStipple(3, 0xAAAA);
for(size_t n = 0; n < line_data_.size(); ++n)
{
if(line_data_[n].second)
{
glBegin(GL_LINE_STRIP);
glVertex3f(x+n*dx, 0.0f, 0.0f);
glVertex3f(x+n*dx, 1.0f, 0.0f);
glEnd();
}
}
glDisable(GL_LINE_STIPPLE);
}
示例7: odomCallback
void odomCallback (nav_msgs::Odometry odomPoseMsg)
{
pair<geometry_msgs::Pose, ros::Time> next;
next.first = odomPoseMsg.pose.pose;
next.second = odomPoseMsg.header.stamp;
cb.push_back (next);
current = next;
}
示例8:
line(size_t res = 1200)
: line_data_(res)
{
tick_data_ = -1.0f;
color_ = 0xFFFFFFFF;
tick_tag_ = false;
line_data_.push_back(std::make_pair(-1.0f, false));
}
示例9: return
bool
MapsBuffer::pushBack(boost::shared_ptr<const MapsRgb> maps_rgb )
{
bool retVal = false;
{
boost::mutex::scoped_lock buff_lock (bmutex_);
if (!buffer_.full ())
retVal = true;
buffer_.push_back (maps_rgb);
}
buff_empty_.notify_one ();
return (retVal);
}
示例10: scan
void scan(std::istream& stream, std::function<void (const std::string &, int, size_t)> fun) {
auto line_number = 0;
for (std::string line; std::getline(stream, line);) {
line_number++;
metrics.lines_scanned++;
if (line.length() > 0) {
buffer.push_back(line);
if (buffer.full()) {
emit_block(line_number, fun);
}
}
}
}
示例11: put
void put(int x) {
for(auto i=0;i<x;i++) {
unique_lock<mutex> locker(m_mutex);
while(Q.full())
empty.wait(locker);
assert(!Q.full());
Q.push_back(i);
cout << "@ "<< i <<endl;
full.notify_all();
}
flag = false;
}
示例12:
bool
PCDBuffer::pushBack (pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr cloud)
{
bool retVal = false;
{
boost::mutex::scoped_lock buff_lock (bmutex_);
if (!buffer_.full ())
retVal = true;
buffer_.push_back (cloud);
}
buff_empty_.notify_one ();
return (retVal);
}
示例13: fillOne
bool fillOne()
{
int ch = super_t::read();
if (ch<0) {
// EOF reached --> cannot be filled
//m_bReady = false;
m_bEOF = true;
return false;
}
if (!checkMatch(ch))
return false;
m_cbuf.push_back((unsigned char)ch);
return true;
}
示例14: main
int main(int argc, char* argv[])
{
v_circular_buffer_2.push_back(1);
v_circular_buffer_2.push_back(4);
MyClass tmp(x);
v_intrusive_set_2.insert(tmp);
MyClass_list tmp_list(x);
v_intrusive_list_2.push_front(tmp_list);
int r = done(); // break here
r += argc + (char)argv[0][0];
return r % 2;
}
示例15: updateGyroState
//TODO: change this a lot!
void updateGyroState(sensor_msgs::Imu& imuMsg, packet_t rxPkt, boost::circular_buffer<float>& calibration)
{
uint8_t gyro_adc = rxPkt.payload[0];
double current_time = ros::Time::now().toSec();
double last_time = imuMsg.header.stamp.toSec();
if (!isMoving) {
calibration.push_back(float(gyro_adc));
double total = 0;
BOOST_FOREACH( float reading, calibration )
{
total += reading;
}
cal_offset = total / calibration.size();
}