本文整理汇总了C++中callback_函数的典型用法代码示例。如果您正苦于以下问题:C++ callback_函数的具体用法?C++ callback_怎么用?C++ callback_使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了callback_函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:iVideo,项目名称:weishao,代码行数:31,代码来源:create_discussions_handler.cpp
示例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(""));
}
}
开发者ID:iVideo,项目名称:weishao,代码行数:59,代码来源:groups_amdin_manage_member_handler.cpp
示例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(""));
}
}
开发者ID:iVideo,项目名称:weishao,代码行数:15,代码来源:change_discussions_name_handler.cpp
示例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;
}
开发者ID:TRI0N,项目名称:wwiv,代码行数:31,代码来源:status.cpp
示例5: callback_
void DiskWriteTask::Cancel()
{
if (callback_)
{
callback_(ErrorCodes::ServiceBusy, this->resource_identifier_);
}
}
开发者ID:huangyt,项目名称:MyProjects,代码行数:7,代码来源:DiskWriteTask.cpp
示例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);
}
}
开发者ID:4fath,项目名称:android-ndk,代码行数:33,代码来源:audio_recorder.cpp
示例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;
}
开发者ID:CrazyTeaFs,项目名称:spider,代码行数:8,代码来源:timer.cpp
示例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';
}
}
开发者ID:bhavyakamboj,项目名称:primesieve,代码行数:26,代码来源:PrimeSieve.cpp
示例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]);
}
}
开发者ID:wuyou33,项目名称:casadi,代码行数:25,代码来源:callback.cpp
示例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);
}
开发者ID:herbertjones,项目名称:mediafire-cpp-sdk,代码行数:35,代码来源:v1_3.cpp
示例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});
}
开发者ID:coryan,项目名称:jaybeams,代码行数:38,代码来源:compute_book.hpp
示例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();
}
}
开发者ID:Nskif,项目名称:tomahawk,代码行数:26,代码来源:Closure.cpp
示例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);
}
}
}
开发者ID:Andrew-liu,项目名称:learn_cplusplus,代码行数:26,代码来源:Poll_t.cpp
示例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;
}
开发者ID:vishnumadduri,项目名称:common-api-dbus-runtime,代码行数:27,代码来源:DBusProxyAsyncCallbackHandler.hpp
示例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;
}
开发者ID:bgeetika,项目名称:anc,代码行数:33,代码来源:audio_player.cpp
示例16: assert
void v0::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);
# ifdef OUTPUT_DEBUG // Debug code
std::cout << "Got content:\n" << content << std::endl;
std::wostringstream ss;
boost::property_tree::write_json( ss, response.pt );
std::cout << "Got JSON:\n" << mf::utils::wide_to_bytes(ss.str()) << std::endl;
# endif
if ( ! response.error_code )
{
GetIfExists( response.pt, "response.pkey", &response.pkey );
if ( ! GetIfExists( response.pt, "response.login_token",
&response.login_token ) )
{
response.error_code = make_error_code(
mf::api::api_code::ContentInvalidData );
response.error_string = "missing session token";
}
}
callback_(response);
}
开发者ID:dazw666,项目名称:mediafire-cpp-sdk,代码行数:35,代码来源:get_login_token.cpp
示例17: format
void Self::log(const LogLevel& level, std::string formatString,
std::va_list args) const {
if (enabled_ && callback_) {
auto message = format(formatString, args);
callback_(level, tag_, message);
}
}
开发者ID:enrevol,项目名称:ee-x,代码行数:7,代码来源:Logger.cpp
示例18: l
void SampleAudioSource::getNextAudioBlock(const AudioSourceChannelInfo& buf) {
ScopedLock l(lock_);
if (not (source_ and isRunning_)) {
buf.clearActiveBufferRegion();
return;
}
currentTime_ += buf.numSamples;
SampleTime overrun(currentTime_ - length_);
if (overrun < 0) {
source_->getNextAudioBlock(buf);
panGainPlayer_->apply(buf);
return;
}
AudioSourceChannelInfo b = buf;
b.numSamples -= overrun;
source_->getNextAudioBlock(b);
panGainPlayer_->apply(b);
b.startSample += b.numSamples;
b.numSamples = overrun;
b.clearActiveBufferRegion();
isRunning_ = false;
callback_(callbackData_);
// Might block - perhaps we should do this in another thread?
}
开发者ID:TopRamenGod,项目名称:echomesh,代码行数:26,代码来源:SampleAudioSource.cpp
示例19: while
void C64::start()
{
/* main emulator loop */
while(true)
{
#ifdef DEBUGGER_SUPPORT
if(!debugger_->emulate())
break;
#endif
/* CIA1 */
if(!cia1_->emulate())
break;
/* CIA2 */
if(!cia2_->emulate())
break;
/* CPU */
if(!cpu_->emulate())
break;
/* VIC-II */
if(!vic_->emulate())
break;
/* IO */
if(!io_->emulate())
break;
/* callback */
if(callback_ && !callback_())
break;
}
}
开发者ID:gregsimon,项目名称:emudore,代码行数:29,代码来源:c64.cpp
示例20: executorLoop
void executorLoop()
{
TTimePoint call_end = nanos();
while (started_) {
TTimePoint period_start = nanos();
TTimeDelta since_last_call = period_start - call_end;
//is this first loop?
if (period_count_ > 0) {
//when we are doing work, don't let other thread to cause contention
std::lock_guard<std::mutex> locker(mutex_);
bool result = callback_(since_last_call);
if (!result) {
started_ = result;
}
}
call_end = nanos();
TTimeDelta elapsed_period = nanos() - period_start;
//prevent underflow: https://github.com/Microsoft/AirSim/issues/617
TTimeDelta delay_nanos = period_nanos_ > elapsed_period ? period_nanos_ - elapsed_period : 0;
//moving average of how much we are sleeping
sleep_time_avg_ = 0.25f * sleep_time_avg_ + 0.75f * delay_nanos;
++period_count_;
if (delay_nanos > 0 && started_)
sleep_for(delay_nanos);
}
}
开发者ID:manadmishra,项目名称:AirSim,代码行数:30,代码来源:ScheduledExecutor.hpp
注:本文中的callback_函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论