本文整理汇总了C++中delegate函数的典型用法代码示例。如果您正苦于以下问题:C++ delegate函数的具体用法?C++ delegate怎么用?C++ delegate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delegate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: delegate
void GatherInfoThread::doRun()
{
auto wildc = gcRefPtr<WildcardManager>::create();
wildc->onNeedSpecialEvent += delegate(&onNeedWCEvent);
uint32 prog = 0;
onProgUpdateEvent(prog);
getUserCore()->getItemManager()->retrieveItemInfo(getItemId(), 0, wildc, MCFBranch::BranchFromInt(getMcfBranch()), MCFBuild::BuildFromInt(getMcfBuild()));
if (isStopped())
return;
auto item = getItemInfo();
if (!item)
throw gcException(ERR_INVALIDDATA, "The item handle was null (gather info failed)");
uint32 itemId = item->getId().getItem();
onCompleteEvent(itemId);
}
示例2: REG_FUNCTION_VOID
void IPCUninstallBranch::registerFunctions()
{
#ifndef DESURA_CLIENT
REG_FUNCTION_VOID( IPCUninstallBranch, pause );
REG_FUNCTION_VOID( IPCUninstallBranch, unpause );
REG_FUNCTION_VOID( IPCUninstallBranch, stop );
REG_FUNCTION_VOID( IPCUninstallBranch, start );
LINK_EVENT( onProgressIPCEvent, uint64 );
LINK_EVENT( onErrorEvent, gcException );
LINK_EVENT_VOID( onCompleteEvent );
#else
REG_EVENT( onProgressIPCEvent );
REG_EVENT( onErrorEvent );
REG_EVENT_VOID( onCompleteEvent );
onProgressIPCEvent += delegate(this, &IPCUninstallBranch::onProgress);
#endif
}
示例3: int
void Entry::recalcCharBoxes(const std::string& text)
{
int lastTextIndex = int(text.size());
CalcBoxesTextDelegate delegate(lastTextIndex);
os::draw_text(nullptr, font(),
base::utf8_const_iterator(text.begin()),
base::utf8_const_iterator(text.end()),
gfx::ColorNone, gfx::ColorNone, 0, 0, &delegate);
m_boxes = delegate.boxes();
if (!m_boxes.empty()) {
m_boxes.back().to = lastTextIndex;
}
// A last box for the last position
CharBox box;
box.codepoint = 0;
box.from = box.to = lastTextIndex;
m_boxes.push_back(box);
}
示例4: delegate
void MedianFilter::applyToGrayscale(FilterManager* filterMgr)
{
const Image* src = filterMgr->getSourceImage();
uint16_t* dst_address = (uint16_t*)filterMgr->getDestinationAddress();
Target target = filterMgr->getTarget();
int color, k, a;
GetPixelsDelegateGrayscale delegate(m_channel);
int x = filterMgr->getX();
int x2 = x+filterMgr->getWidth();
int y = filterMgr->getY();
for (; x<x2; ++x) {
// Avoid the non-selected region
if (filterMgr->skipPixel()) {
++dst_address;
continue;
}
delegate.reset();
get_neighboring_pixels<GrayscaleTraits>(src, x, y, m_width, m_height, m_width/2, m_height/2,
m_tiledMode, delegate);
color = image_getpixel_fast<GrayscaleTraits>(src, x, y);
if (target & TARGET_GRAY_CHANNEL) {
std::sort(m_channel[0].begin(), m_channel[0].end());
k = m_channel[0][m_ncolors/2];
}
else
k = _graya_getv(color);
if (target & TARGET_ALPHA_CHANNEL) {
std::sort(m_channel[1].begin(), m_channel[1].end());
a = m_channel[1][m_ncolors/2];
}
else
a = _graya_geta(color);
*(dst_address++) = _graya(k, a);
}
}
示例5: Font
// constructor
DlgFatal::DlgFatal(const std::vector<std::string>& callstack, const std::string& message)
{
Font().set("arial");
m_pTex = D3D().loadTextureFromResource("Skull", RT_BITMAP);
m_pBox = new UITextBox;
m_pBox->setSize(Point2(0.85f, 0.375f));
m_pBox->setPos(Point2(0.075f, 0.1875f));
m_pBox->setInputEnabled(false);
m_pBox->setAlign(UITextBox::CENTER);
m_pBox->setVAlign(UITextBox::VCENTER);
m_pBox->setWrap(true);
m_pBox->setFont("smallarial");
m_pBox->setText(join(callstack, " <- ") + message);
m_pButton = new UIButton;
m_pButton->onClick = delegate(&DlgFatal::onExit);
m_pButton->setText("Exit And Cry");
m_pButton->setPos(Point2(m_pBox->pos().x + ((m_pBox->size().x - m_pButton->size().x) * 0.5f), 0.75f - m_pButton->size().y - 0.025f));
}
示例6: setupCurTask
bool VerifyServiceTask::installMissingFiles()
{
bool res = false;
VSInstallMissing task;
m_pCurTask = &task;
setupCurTask();
task.onProgressEvent += delegate(this, &VerifyServiceTask::onProgress);
try
{
res = task.doTask();
}
catch (gcException)
{
}
m_pCurTask = NULL;
return res;
}
示例7: delegate
void AssignNameOverlay::updatePosition()
{
if (!index().isValid())
{
return;
}
QRect rect = delegate()->pixmapRect();
if (rect.width() < m_widget->minimumSizeHint().width())
{
int offset = (m_widget->minimumSizeHint().width() - rect.width()) / 2;
rect.adjust(-offset, 0, offset, 0);
}
QRect visualRect = m_view->visualRect(index());
rect.translate(visualRect.topLeft());
m_widget->setFixedSize(rect.width(), rect.height());
m_widget->move(rect.topLeft());
}
示例8: main
/*----------------------------------------------------------------------
| main
+---------------------------------------------------------------------*/
int
main(int argc, char** argv)
{
// setup Neptune logging
NPT_LogManager::GetDefault().Configure("plist:.level=FINE;.handlers=ConsoleHandler;.ConsoleHandler.colors=off;.ConsoleHandler.filter=63");
NPT_COMPILER_UNUSED(argc);
// parse command line
ParseCommandLine(argv);
// setup device
PLT_MediaConnect* connect(
new PLT_MediaConnect("Platinum"));
connect->SetByeByeFirst(false);
// setup delegate
NPT_Reference<PLT_FileMediaConnectDelegate> delegate(
new PLT_FileMediaConnectDelegate("/", Options.path));
connect->SetDelegate((PLT_MediaServerDelegate*)delegate.AsPointer());
PLT_UPnP upnp;
PLT_DeviceHostReference device(connect);
upnp.AddDevice(device);
if (NPT_FAILED(upnp.Start()))
return 1;
char buf[256];
while (gets(buf))
{
if (*buf == 'q')
{
break;
}
}
upnp.Stop();
return 0;
}
示例9: delegate
bool VSDownloadMissing::doTask()
{
m_hMcf->getNewProvider() += delegate(this, &VSDownloadMissing::onNewProvider);
try
{
MCFCore::Misc::UserCookies uc;
getWebCore()->setMCFCookies(&uc);
m_hMcf->getDownloadProviders(getWebCore()->getMCFDownloadUrl(), &uc);
m_hMcf->dlFilesFromWeb();
}
catch (gcException &except)
{
onErrorEvent(except);
return false;
}
if (isStopped())
return false;
return checkComplex();
}
示例10: gcTrace
void MainApp::logIn(const char* user, const char* pass)
{
gcTrace("User: {0}", user);
std::lock_guard<std::mutex> a(m_UserLock);
safe_delete(g_pUserHandle);
gcString path = UTIL::OS::getAppDataPath();
g_pUserHandle = (UserCore::UserI*)UserCore::FactoryBuilderUC(USERCORE);
g_pUserHandle->init(path.c_str(), m_strServiceProvider.c_str());
try
{
//need to do this here as news items will be passed onlogin
g_pUserHandle->getNewsUpdateEvent() += delegate(this, &MainApp::onNewsUpdate);
g_pUserHandle->getGiftUpdateEvent() += delegate((MainAppNoUI*)this, &MainAppNoUI::onGiftUpdate);
g_pUserHandle->getNeedCvarEvent() += delegate(this, &MainApp::onNeedCvar);
g_pUserHandle->lockDelete();
g_pUserHandle->logIn(user, pass);
g_pUserHandle->unlockDelete();
#ifndef DEBUG
if (gc_enable_api_debugging.getBool())
g_pUserHandle->getWebCore()->enableDebugging();
#endif
}
catch (gcException)
{
g_pUserHandle->logOut();
g_pUserHandle->getNewsUpdateEvent() -= delegate(this, &MainApp::onNewsUpdate);
g_pUserHandle->getGiftUpdateEvent() -= delegate((MainAppNoUI*)this, &MainAppNoUI::onGiftUpdate);
g_pUserHandle->getNeedCvarEvent() -= delegate(this, &MainApp::onNeedCvar);
g_pUserHandle->unlockDelete();
g_pUserHandle->logOut(false, false);
safe_delete(g_pUserHandle);
throw;
}
}
示例11: Invalidate
void SrtmTile::Init(string const & dir, ms::LatLon const & coord)
{
Invalidate();
string const base = GetBase(coord);
string const cont = dir + base + ".SRTMGL1.hgt.zip";
string file = base + ".hgt";
UnzipMemDelegate delegate(m_data);
try
{
ZipFileReader::UnzipFile(cont, file, delegate);
}
catch (ZipFileReader::LocateZipException const & e)
{
// Sometimes packed file has different name. See N39E051 measure.
file = base + ".SRTMGL1.hgt";
ZipFileReader::UnzipFile(cont, file, delegate);
}
if (!delegate.m_completed)
{
LOG(LWARNING, ("Can't decompress SRTM file:", cont));
Invalidate();
return;
}
if (m_data.size() != kSrtmTileSize)
{
LOG(LWARNING, ("Bad decompressed SRTM file size:", cont, m_data.size()));
Invalidate();
return;
}
m_valid = true;
}
示例12: wc
void HGTController::doDownload()
{
//header should be saved all ready so appened to it
m_hFile.open(m_szFile, UTIL::FS::FILE_APPEND);
m_hFile.seek(0);
HttpHandle wc(m_szUrl.c_str());
//wc->getProgressEvent() += delegate(this, &HGTController::onProgress);
wc->getWriteEvent() += delegate(this, &HGTController::onWriteMemory);
for (size_t x=0; x<m_vSuperBlockList.size(); x++)
{
m_pCurBlock = m_vSuperBlockList[x];
wc->cleanUp();
wc->setDownloadRange(m_pCurBlock->offset, m_pCurBlock->size);
try
{
m_hFile.seek(m_pCurBlock->vBlockList[0]->fileOffset);
wc->getWeb();
}
catch (gcException &e)
{
onErrorEvent(e);
nonBlockStop();
}
}
size_t fsSize = m_rvFileList.size();
for (size_t x=0; x<fsSize; x++)
{
if (!HasAllFlags(m_rvFileList[x]->getFlags(), MCFFileI::FLAG_CANUSEDIFF))
m_rvFileList[x]->addFlag(MCFFileI::FLAG_COMPLETE);
}
}
示例13: EAW_ASSERT
bool ViewNavigationDelegate::ClickElementsByClass(const char* className)
{
EAW_ASSERT(className);
if(!className || !className[0])
return false;
IOverlayInputClient* pOverlayInputClient = mView->GetOverlayInputClient();
if(pOverlayInputClient)
pOverlayInputClient->OnFocusChangeEvent(false);
bool elementClicked = false;
WebCore::Frame* pFrame = mView->GetFrame();
while(pFrame)
{
WebCore::Document* document = pFrame->document();
EAW_ASSERT(document);
ClickElementsByIdOrClassDelegate delegate(className, false);
if (document)
{
DOMWalker<ClickElementsByIdOrClassDelegate> walker(document, delegate);
}
elementClicked = delegate.GetReturnValue();
if(elementClicked)
break;
pFrame = pFrame->tree()->traverseNext();
}
return elementClicked;
}
示例14: TraceS
void Connection::replaceAdapter(net::SocketAdapter* adapter)
{
TraceS(this) << "Replace adapter: " << adapter << endl;
if (_adapter) {
TraceS(this) << "Replace adapter: Delete existing: " << _adapter << endl;
Outgoing.emitter.detach(_adapter);
_socket->removeReceiver(_adapter);
_adapter->removeReceiver(this);
_adapter->setSender(nullptr);
deleteLater<net::SocketAdapter>(_adapter);
// delete _adapter;
_adapter = nullptr;
}
if (adapter) {
// Attach ourselves to the given ConnectionAdapter (should already be set)
//assert(adapter->recvAdapter() == this);
//assert(adapter->sendAdapter() == _socket.get());
adapter->addReceiver(this);
// ConnectionAdapter output goes to the Socket
adapter->setSender(_socket.get());
// Attach the ConnectionAdapter to receive Socket callbacks
// The adapter will process raw packets into HTTP or WebSocket
// frames depending on the adapter rype.
_socket->addReceiver(adapter);
// The Outgoing stream pumps data into the ConnectionAdapter,
// which in turn proxies to the output Socket
Outgoing.emitter += delegate(adapter, &net::SocketAdapter::sendPacket);
_adapter = adapter;
}
}
示例15: delegate
void TagsLineEditOverlay::updatePosition()
{
if (!m_index.isValid() || !m_widget)
{
return;
}
QRect thumbrect = delegate()->ratingRect();
//kDebug() << "updatePosition called, probably a mouseover : " << thumbrect;
QRect rect = thumbrect;
if (rect.width() > addTagsLineEdit()->width() )
{
int offset = (rect.width() - addTagsLineEdit()->width()) / 2;
rect.adjust(offset, 0, -offset, 0);
}
QRect visualRect = m_view->visualRect(m_index);
rect.translate(visualRect.topLeft());
m_widget->setFixedSize(rect.width() + 2, rect.height() + 5);
m_widget->move(rect.topLeft());
m_widget->setFocus();
}