本文整理汇总了C++中callback_函数的典型用法代码示例。如果您正苦于以下问题:C++ callback_函数的具体用法?C++ callback_怎么用?C++ callback_使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了callback_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ELOG
void CreateDiscussionsHandler::handleIqID( const IQ& iq, int context )
{
json::jobject jobj;
if (iq.m_subtype != gloox::IQ::Result)
{
universal_resource error_desc;
ELOG("app")->error(WCOOL(L"创建讨论组时服务端返回错误。") + boost::shared_ptr<gloox::Tag>(iq.tag())->xml());
error_desc = XL("biz.CreateDiscussions.fail");
callback_(true, error_desc, jobj);
}else{
if(iq.findExtension(kExtUser_iq_filter_creatediscussions))
{
boost::shared_ptr<gloox::Tag> tag(iq.findExtension(kExtUser_iq_filter_creatediscussions)->tag());
if (tag)
{
gloox::Tag* tag2 = tag->findChild("item");
if (tag)
{
jobj["session_id"] = gWrapInterface::instance().append_discussions_domain(tag2->findAttribute("id"));
jobj["group_name"] = tag2->findAttribute("topic");
callback_(false,XL(""),jobj);
return;
}
}
}
ELOG("app")->error(WCOOL(L"创建讨论组时服务端返回的数据格式错误。") + boost::shared_ptr<gloox::Tag>(iq.tag())->xml());
callback_(true, XL("biz.CreateDiscussions.fail"), jobj);
}
}
示例2: callback_
void GroupsAdminManageMemberHandler::handleIqID( const IQ& iq, int context )
{
json::jobject jobj;
if (iq.m_subtype != gloox::IQ::Result)
{
const Error* e = iq.error();
if (!e)
{
callback_(true,XL("biz.GroupsAdminManageMember.fail"));
return;
}
if ( e->error() == StanzaErrorBadRequest)
{
ELOG("app")->error(WCOOL(L"管理员审批成员加入时,请求协议错误!。"));
callback_(true,XL("biz.crwod.iq_error.bad-request"));
}
else if (e->error() == StanzaErrorInternalServerError)
{
ELOG("app")->error(WCOOL(L"管理员审批成员加入时,处理错误(服务器处理错误)。"));
callback_(true,XL("biz.crwod.iq_error.internal-server-error"));
}
else if (e->error() == StanzaErrorGone)
{
universal_resource err;
err.res_key="biz.crwod.iq_error.answer_apply_gone";
ELOG("app")->error(WCOOL(L"管理员审批成员加入时,消息已过期!"));
callback_(false,err);
}
else if (e->error() == StanzaErrorForbidden)
{
ELOG("app")->error(WCOOL(L"管理员审批成员加入时,自己不是管理员"));
callback_(true,XL("biz.crwod.iq_error.admin_forbidden"));
}
else if (e->error() == StanzaErrorResourceConstraint)
{
ELOG("app")->error(WCOOL(L"管理员审批成员加入时,群成员已经满"));
callback_(true,XL("biz.crwod.iq_error.admin_resource-constraint"));
}
else if (e->error() == StanzaErrorConflict)
{
universal_resource err;
err.res_key="biz.crwod.iq_error.admin_Conflict";
ELOG("app")->error(WCOOL(L"管理员审批成员加入时,该成员已加入群"));
callback_(false,err);
}
else if (e->error() == StanzaErrorItemNotFound)
{
ELOG("app")->error(WCOOL(L"管理员审批成员加入时,找不到此群。"));
callback_(true,XL("biz.crwod.iq_error.item-not-found"));
}else
{
ELOG("app")->error(WCOOL(L"管理员审批成员加入时,服务器返回未知错误类型!") + boost::shared_ptr<gloox::Tag>(iq.tag())->xml());
callback_(true,XL("biz.GroupsAdminManageMember.fail"));
}
}else{
callback_(false,XL(""));
}
}
示例3: ELOG
void ChangeDiscussionsNameHandler::handleIqID( const IQ& iq, int context )
{
json::jobject jobj;
if (iq.m_subtype != gloox::IQ::Result)
{
universal_resource error_desc;
ELOG("app")->error(WCOOL(L"讨论组改名时服务端返回错误。") + boost::shared_ptr<gloox::Tag>(iq.tag())->xml());
error_desc = XL("biz.ChangeDiscussionsName.fail");
callback_(true, error_desc);
}
else
{
callback_(false, XL(""));
}
}
示例4: sizeof
// StatusMgr
bool StatusMgr::Get(bool bLockFile) {
if (!m_statusFile.IsOpen()) {
m_statusFile.SetName(datadir_, STATUS_DAT);
int nLockMode = (bLockFile) ? (File::modeReadWrite | File::modeBinary) : (File::modeReadOnly | File::modeBinary);
m_statusFile.Open(nLockMode);
} else {
m_statusFile.Seek(0L, File::seekBegin);
}
if (!m_statusFile.IsOpen()) {
return false;
} else {
char oldFileChangeFlags[7];
for (int nFcIndex = 0; nFcIndex < 7; nFcIndex++) {
oldFileChangeFlags[nFcIndex] = statusrec.filechange[nFcIndex];
}
m_statusFile.Read(&statusrec, sizeof(statusrec_t));
if (!bLockFile) {
m_statusFile.Close();
}
for (int i = 0; i < 7; i++) {
if (oldFileChangeFlags[i] != statusrec.filechange[i]) {
// Invoke callback on changes.
callback_(i);
}
}
}
return true;
}
示例5: callback_
void DiskWriteTask::Cancel()
{
if (callback_)
{
callback_(ErrorCodes::ServiceBusy, this->resource_identifier_);
}
}
示例6: assert
void AudioRecorder::ProcessSLCallback(SLAndroidSimpleBufferQueueItf bq) {
#ifdef ENABLE_LOG
recLog_->logTime();
#endif
assert(bq == recBufQueueItf_);
sample_buf *dataBuf = NULL;
devShadowQueue_->front(&dataBuf);
devShadowQueue_->pop();
dataBuf->size_ = dataBuf->cap_; //device only calls us when it is really full
recQueue_->push(dataBuf);
sample_buf* freeBuf;
while (freeQueue_->front(&freeBuf) && devShadowQueue_->push(freeBuf)) {
freeQueue_->pop();
SLresult result = (*bq)->Enqueue(bq, freeBuf->buf_, freeBuf->cap_);
SLASSERT(result);
}
/*
* PLAY_KICKSTART_BUFFER_COUNT: # of buffers cached in the queue before
* STARTING player. it is defined in audio_common.h. Whatever buffered
* here is the part of the audio LATENCY! adjust to fit your bill [ until
* it busts ]
*/
if(++audioBufCount == PLAY_KICKSTART_BUFFER_COUNT && callback_) {
callback_(ctx_, ENGINE_SERVICE_MSG_KICKSTART_PLAYER, NULL);
}
// should leave the device to sleep to save power if no buffers
if (devShadowQueue_->size() == 0) {
(*recItf_)->SetRecordState(recItf_, SL_RECORDSTATE_STOPPED);
}
}
示例7: callback_
// When On Expiration, Run Callback Function, And Reset next_ member
int Timer::ActivateCb(void *data) {
tick_times_++;
// Invoke Callback
int ret = callback_(data);
// Refresh The Remaining Amount Time Util Next Expiration
return ret;
}
示例8: callback_
void PrimeSieve::doSmallPrime(const SmallPrime& sp)
{
if (sp.firstPrime >= start_ && sp.lastPrime <= stop_)
{
// callback prime numbers
if (sp.index == 0)
{
if (isFlag(CALLBACK_PRIMES_OBJ))
cb_->callback(sp.firstPrime);
if (isFlag(CALLBACK_PRIMES_OBJ_TN))
cb_tn_->callback(sp.firstPrime, threadNum_);
if (isFlag(CALLBACK_PRIMES))
callback_(sp.firstPrime);
if (isFlag(CALLBACK_PRIMES_TN))
callback_tn_(sp.firstPrime, threadNum_);
if (isFlag(CALLBACK_PRIMES_C))
reinterpret_cast<callback_c_t>(callback_)(sp.firstPrime);
if (isFlag(CALLBACK_PRIMES_C_TN))
reinterpret_cast<callback_c_tn_t>(callback_tn_)(sp.firstPrime, threadNum_);
}
if (isCount(sp.index))
counts_[sp.index]++;
if (isPrint(sp.index))
std::cout << sp.str << '\n';
}
}
示例9: nIn
void CallbackFunctionInternal::evalD(const double** arg,
double** res, int* iw, double* w) {
// Number of inputs and outputs
int num_in = nIn();
int num_out = nOut();
std::vector<DMatrix> inputs(num_in);
// Pass the inputs to the function
for (int i=0; i<num_in; ++i) {
inputs[i] = DMatrix::zeros(input(i).sparsity());
if (arg[i] != 0) {
inputs[i].setNZ(arg[i]);
} else {
inputs[i].set(0.);
}
}
std::vector<DMatrix> outputs = callback_(inputs);
// Get the outputs
for (int i=0; i<num_out; ++i) {
if (res[i] != 0) outputs[i].getNZ(res[i]);
}
}
示例10: assert
void v1_3::Request::HandleContent(const std::string & url,
const mf::http::Headers & headers,
const std::string & content)
{
assert(callback_);
if (!callback_)
return;
ResponseType response;
response.InitializeWithContent(url, "", headers, content);
// These could possibly be available when an error occurs or on success.
GetIfExists(response.pt, "response.pkey", &response.pkey);
GetIfExists(response.pt, "response.secret_key", &response.secret_key);
GetIfExists(response.pt, "response.time", &response.time);
if (!response.error_code)
{
if (!GetIfExists(response.pt, "response.session_token",
&response.session_token))
{
response.error_code
= make_error_code(mf::api::api_code::ContentInvalidData);
response.error_string = "missing session token";
}
if (!GetIfExists(response.pt, "response.ekey", &response.ekey))
{
response.error_code
= make_error_code(mf::api::api_code::ContentInvalidData);
response.error_string = "missing \"response.ekey\"";
}
}
callback_(response);
}
示例11: handle_message
/**
* Handle a new order message.
*
* New orders are added to the list of known orders and their qty is
* added to the right book at the order's price level.
*
* @param recvts the timestamp when the message was received
* @param msgcnt the number of messages received before this message
* @param msgoffset the number of bytes received before this message
* @param msg the message describing a new order
*/
void handle_message(
time_point recvts, long msgcnt, std::size_t msgoffset,
add_order_message const& msg) {
JB_LOG(trace) << " " << msgcnt << ":" << msgoffset << " " << msg;
auto insert = orders_.emplace(
msg.order_reference_number,
order_data{msg.stock, msg.buy_sell_indicator, msg.price, msg.shares});
if (insert.second == false) {
// ... ooops, this should not happen, we got a duplicate order
// id. There is a problem with the feed, because we are working
// with simple command-line utilities we are just going to log the
// error, in a more complex system we would want to raise an
// exception and let the caller decide what to do ...
order_data const& data = insert.first->second;
JB_LOG(warning) << "duplicate order in handle_message(add_order_message)"
<< ", id=" << msg.order_reference_number
<< ", location=" << msgcnt << ":" << msgoffset
<< ", existing data=" << data << ", msg=" << msg;
return;
}
// ... find the right book for this order, create one if necessary ...
auto& book = books_[msg.stock];
(void)book.handle_add_order(msg.buy_sell_indicator, msg.price, msg.shares);
callback_(
msg.header, book, book_update{recvts, msg.stock, msg.buy_sell_indicator,
msg.price, msg.shares});
}
示例12: callback_
void
Closure::Invoked() {
if ( callback_ )
{
callback_();
}
else
{
// Only invoke the closure if the receiver still exists
// Hint: If parent was destroyed, this closure would also be destroyed
if ( parent() || !outOfThreadReceiver_.isNull() )
{
slot_.invoke(
parent() ? parent() : outOfThreadReceiver_.data(),
val0_ ? val0_->arg() : QGenericArgument(),
val1_ ? val1_->arg() : QGenericArgument(),
val2_ ? val2_->arg() : QGenericArgument(),
val3_ ? val3_->arg() : QGenericArgument());
}
}
if ( autoDelete_ )
{
deleteLater();
}
}
示例13: readline
void Poll_t::handle_data()
{
for(int i = 1; i <= maxi_; ++i)
{
int peerfd = client_[i].fd;
if(client_[i].fd == -1)
continue;
if(client_[i].revents & POLLIN)
{
char buf[1024] = {0};
int ret = readline(peerfd, buf, 1024);
if(ret == -1)
{
ERR_EXIT("readline");
}
else if(ret == 0)
{
std::cout << "client close " << std::endl;
del_fd(i);
continue;
}
printf("%s\n",buf);
callback_(peerfd, buf);
}
}
}
示例14: handleDBusMessageReply
inline CallStatus handleDBusMessageReply(
const CallStatus dbusMessageCallStatus,
const DBusMessage& dbusMessage,
index_sequence<ArgIndices_...>,
std::tuple<ArgTypes_...> argTuple) const {
(void)argTuple; // this suppresses warning "set but not used" in case of empty _ArgTypes
// Looks like: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57560 - Bug 57650
CallStatus callStatus = dbusMessageCallStatus;
if (dbusMessageCallStatus == CallStatus::SUCCESS) {
if (!dbusMessage.isErrorType()) {
DBusInputStream dbusInputStream(dbusMessage);
const bool success
= DBusSerializableArguments<ArgTypes_...>::deserialize(
dbusInputStream,
std::get<ArgIndices_>(argTuple)...);
if (!success)
callStatus = CallStatus::REMOTE_ERROR;
} else {
callStatus = CallStatus::REMOTE_ERROR;
}
}
callback_(callStatus, std::move(std::get<ArgIndices_>(argTuple))...);
return callStatus;
}
示例15: lock
void AudioPlayer::ProcessSLCallback(SLAndroidSimpleBufferQueueItf bq) {
#ifdef ENABLE_LOG
logFile_->logTime();
#endif
std::lock_guard<std::mutex> lock(stopMutex_);
// retrieve the finished device buf and put onto the free queue
// so recorder could re-use it
sample_buf *buf;
if(!devShadowQueue_->front(&buf)) {
/*
* This should not happen: we got a callback,
* but we have no buffer in deviceShadowedQueue
* we lost buffers this way...(ERROR)
*/
if(callback_) {
uint32_t count;
callback_(ctx_, ENGINE_SERVICE_MSG_RETRIEVE_DUMP_BUFS, &count);
}
return;
}
devShadowQueue_->pop();
if( buf != &silentBuf_) {
buf->size_ = 0;
freeQueue_->push(buf);
if (!playQueue_->front(&buf)) {
#ifdef ENABLE_LOG
logFile->log("%s", "====Warning: running out of the Audio buffers")
#endif
return;
}