本文整理汇总了C++中INVARIANT函数的典型用法代码示例。如果您正苦于以下问题:C++ INVARIANT函数的具体用法?C++ INVARIANT怎么用?C++ INVARIANT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了INVARIANT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: INVARIANT
service::~service()
{
INVARIANT(_thread);
INVARIANT(_mail);
if(!_done) stop();
}
示例2: INVARIANT
chat_app::~chat_app()
{
INVARIANT(_conversation_service);
INVARIANT(_conversation);
INVARIANT(_mail_service);
_mail_service->done();
}
示例3: stream_write
void stream_write(stream_content& content, index const begin, byte const* const data_begin, size const num_bytes)
{
index num_output_bytes = 0ULL;
index page_begin = begin & ~(stream_page_size - 1ULL);
index page_offset = begin - page_begin;
while (num_output_bytes < num_bytes)
{
size const num_bytes_to_copy = std::min(stream_page_size - page_offset,num_bytes - num_output_bytes);
stream_page& page = content[page_begin];
INVARIANT(num_bytes_to_copy > 0ULL);
INVARIANT(page_offset + num_bytes_to_copy <= stream_page_size);
std::copy(data_begin + num_output_bytes,
data_begin + num_output_bytes + num_bytes_to_copy,
page.data() + page_offset
);
page_begin += stream_page_size;
page_offset = 0ULL;
num_output_bytes += num_bytes_to_copy;
}
INVARIANT(num_output_bytes == num_bytes);
}
示例4: INVARIANT
void script_app::clone_app()
{
INVARIANT(_app_service);
INVARIANT(_app);
install_app_gui(*_app, *_app_service, this);
}
示例5: INVARIANT
void session_widget::update_contact_select()
{
INVARIANT(_contact_select);
INVARIANT(_session_service);
INVARIANT(_session);
INVARIANT(_add_contact);
INVARIANT(_session_service->user_service());
_contact_select->clear();
for(auto p : _session_service->user_service()->user().contacts().list())
{
CHECK(p);
//skip contact already in session
if(_session->contacts().by_id(p->id())) continue;
//skip contact which is disconnected
if(!_session_service->user_service()->contact_available(p->id())) continue;
_contact_select->addItem(p->name().c_str(), p->id().c_str());
}
bool enabled = _contact_select->count() > 0;
_contact_select->setEnabled(enabled);
_add_contact->setEnabled(enabled);
}
示例6: REQUIRE
script_app::script_app(
app_ptr app,
app_service_ptr as,
s::conversation_service_ptr conversation_s,
s::conversation_ptr conversation) :
generic_app{},
_from_id{conversation->user_service()->user().info().id()},
_id{u::uuid()},
_conversation_service{conversation_s},
_conversation{conversation},
_app{app},
_app_service{as}
{
REQUIRE(conversation_s);
REQUIRE(conversation);
REQUIRE(app);
REQUIRE(as);
init();
INVARIANT(_api);
INVARIANT(_conversation_service);
INVARIANT(_conversation);
INVARIANT(_app);
INVARIANT(_app_service);
INVARIANT_FALSE(_id.empty());
}
示例7: INVARIANT
void queue_debug::update_graph()
{
INVARIANT(_in_graph);
INVARIANT(_out_graph);
auto px = _x;
_x+=GRAPH_STEP;
m::mailbox_stats* stats = nullptr;
if(_mailbox_stats) stats = _mailbox_stats;
else
{
auto mb = _mailbox.lock();
if(!mb) return;
stats = &(mb->stats());
}
CHECK(stats);
auto in_push = stats->in_push_count;
auto in_pop = stats->in_pop_count;
auto out_push = stats->out_push_count;
auto out_pop = stats->out_pop_count;
stats->reset();
draw_graph(*_in_graph, px, _prev_in_push+2, _x, in_push+2, _in_max, QPen{QBrush{QColor{"red"}}, 0.5});
draw_graph(*_in_graph, px, _prev_in_pop, _x, in_pop, _in_max, QPen{QBrush{QColor{"orange"}}, 0.5});
draw_graph(*_out_graph, px, _prev_out_push+2, _x, out_push+2, _out_max, QPen{QBrush{QColor{"green"}}, 0.5});
draw_graph(*_out_graph, px, _prev_out_pop, _x, out_pop, _out_max, QPen{QBrush{QColor{"blue"}}, 0.5});
_prev_in_push = in_push;
_prev_in_pop = in_pop;
_prev_out_push = out_push;
_prev_out_pop = out_pop;
}
示例8: memory_havoc
void memory_havoc(memory_content& content, address const begin, size const num_bytes, byte const value)
{
index num_output_bytes = 0ULL;
address page_begin = begin & ~(memory_page_size - 1ULL);
index page_offset = begin - page_begin;
while (num_output_bytes < num_bytes)
{
size const num_bytes_to_copy = std::min(memory_page_size - page_offset,num_bytes - num_output_bytes);
memory_page& page = content[page_begin];
INVARIANT(num_bytes_to_copy > 0ULL);
INVARIANT(page_offset + num_bytes_to_copy <= memory_page_size);
std::fill(page.data() + page_offset,
page.data() + page_offset + num_bytes_to_copy,
value
);
page_begin += memory_page_size;
page_offset = 0ULL;
num_output_bytes += num_bytes_to_copy;
}
INVARIANT(num_output_bytes == num_bytes);
}
示例9: stream_read
void stream_read(stream_content const& content, index const begin, byte* const data_begin, size const num_bytes)
{
index num_output_bytes = 0ULL;
index page_begin = begin & ~(stream_page_size - 1ULL);
index page_offset = begin - page_begin;
while (num_output_bytes < num_bytes)
{
size const num_bytes_to_copy = std::min(stream_page_size - page_offset,num_bytes - num_output_bytes);
stream_page& page = const_cast<stream_content&>(content)[page_begin]; //!< The const_cast is used to automatically create
//!< a page with uninitialised data, if it is not in
//!< the map yet.
INVARIANT(num_bytes_to_copy > 0ULL);
INVARIANT(page_offset + num_bytes_to_copy <= stream_page_size);
std::copy(page.data() + page_offset,
page.data() + page_offset + num_bytes_to_copy,
data_begin + num_output_bytes);
page_begin += stream_page_size;
page_offset = 0ULL;
num_output_bytes += num_bytes_to_copy;
}
INVARIANT(num_output_bytes == num_bytes);
}
示例10: ASSUMPTION
scene_record_id_reverse_builder scene_record_id_reverse_builder::run(
tree_widget_item const* tree_item,
tree_widget_item** const coord_system_item)
{
ASSUMPTION(tree_item != nullptr);
scene_record_id_reverse_builder id_builder;
if (represents_record(tree_item))
{
id_builder.m_record_name = get_tree_widget_item_name(tree_item);
tree_item = as_tree_widget_item(tree_item->parent());
}
if (represents_folder(tree_item))
{
id_builder.m_folder_name = get_tree_widget_item_name(tree_item);
tree_item = as_tree_widget_item(tree_item->parent());
}
INVARIANT(represents_coord_system(tree_item));
if (coord_system_item != nullptr)
*coord_system_item = const_cast<tree_widget_item*>(tree_item);
for ( ; tree_item != nullptr; tree_item = as_tree_widget_item(tree_item->parent()))
{
INVARIANT(represents_coord_system(tree_item));
id_builder.m_node_path.push_back(get_tree_widget_item_name(tree_item));
}
std::reverse(id_builder.m_node_path.begin(), id_builder.m_node_path.end());
INVARIANT(!id_builder.m_node_path.empty());
return id_builder;
}
示例11: INVARIANT
void contact_list_dialog::update_contacts()
{
INVARIANT(_list);
INVARIANT(_service);
_list->clear();
_ui.clear();
for(auto u : _service->user().contacts().list())
{
auto rm = make_x_button();
std::stringstream ss;
ss << "Remove `" << u->name() << "'";
rm->setToolTip(ss.str().c_str());
auto mapper = new QSignalMapper{this};
mapper->setMapping(rm, QString(u->id().c_str()));
connect(rm, SIGNAL(clicked()), mapper, SLOT(map()));
connect(mapper, SIGNAL(mapped(QString)), this, SLOT(remove(QString)));
auto ui = new user_info{u, _service, rm, false};
_list->add(ui);
_ui.push_back(ui);
}
_prev_contacts = _service->user().contacts().size();
}
示例12: l
void conversation_service::quit_conversation(const std::string& id)
{
u::mutex_scoped_lock l(_mutex);
INVARIANT(_sender);
INVARIANT(_post);
//find conversation
auto s = _conversations.find(id);
if(s == _conversations.end()) return;
CHECK(s->second);
//send quit message to contacts in the conversation
quit_conversation_msg ns;
ns.conversation_id = s->second->id();
auto m = ns.to_message();
for(auto c : s->second->contacts().list())
{
CHECK(c);
_sender->send(c->id(), m);
}
//remove conversation from map
_conversations.erase(s);
fire_quit_conversation_event(id);
}
示例13: REQUIRE
speaker::speaker(api::backend* back, qt_frontend* front, const std::string& codec) : _back{back}, _front{front}
{
REQUIRE(back);
REQUIRE(front);
INVARIANT(_back);
INVARIANT(_front);
_f.setSampleRate(SAMPLE_RATE);
_f.setChannelCount(CHANNELS);
_f.setSampleSize(SAMPLE_SIZE);
_f.setSampleType(QAudioFormat::SignedInt);
_f.setByteOrder(QAudioFormat::LittleEndian);
_f.setCodec(Q_CODEC.c_str());
_t = parse_codec(codec);
QAudioDeviceInfo i{QAudioDeviceInfo::defaultOutputDevice()};
if (!i.isFormatSupported(_f)) _f = i.nearestFormat(_f);
LOG << "using speaker device: " << convert(i.deviceName()) << std::endl;
_o = new QAudioOutput{i, _f, _front};
CHECK_GREATER_EQUAL(static_cast<size_t>(_f.sampleRate()), SAMPLE_RATE);
_rep = _f.sampleRate() / SAMPLE_RATE;
_channels = _f.channelCount();
if(_t == codec_type::opus) _opus = std::make_shared<u::opus_decoder>();
}
示例14: INVARIANT
void app_area::add_chat_app()
{
INVARIANT(_conversation);
INVARIANT(_conversation_service);
//create chat app
auto t = new a::chat_app{_conversation_service, _conversation};
add(t, nullptr, "");
}
示例15: INVARIANT
master_post_office::~master_post_office()
{
INVARIANT(_in_thread);
INVARIANT(_out_thread);
_done = true;
_out.done();
_in_thread->join();
_out_thread->join();
}