本文整理汇总了C++中perform函数的典型用法代码示例。如果您正苦于以下问题:C++ perform函数的具体用法?C++ perform怎么用?C++ perform使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了perform函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
ndk::event::result
input_handler::pimpl::on_kbd_common (ndk::keyboard const &ev)
{
switch (ev.code ())
{
case ndk::key::error:
throw std::runtime_error ("ERR");
// control actions
case ndk::key::ctrl_d:
case ndk::key::q:
perform (ev.sender (), action::quit);
return ndk::event::accepted;
case ndk::key::ctrl_l:
perform (ev.sender (), action::redraw);
return ndk::event::accepted;
case ndk::key::resize:
perform (ev.sender (), action::resize);
return ndk::event::accepted;
case ndk::key::F10:
perform (ev.sender (), action::maximise);
return ndk::event::accepted;
default:
return ndk::event::ignored;
}
}
示例2: msg
void Trade::agree(Character *c)
{
// No player agreed
if (mState == TRADE_CONFIRMED)
{
// One player agreed, if it's the player 2, make it player 1
if (c == mChar2)
{
std::swap(mChar1, mChar2);
std::swap(mItems1, mItems2);
std::swap(mMoney1, mMoney2);
}
// First player agrees.
mState = TRADE_CONFIRM_WAIT;
// Send the other player that the first player has confirmed
MessageOut msg(GPMSG_TRADE_AGREED);
mChar2->getClient()->send(msg);
return;
}
if (mState == TRADE_AGREE_WAIT && c == mChar1)
{
// We don't care about the first player, he already agreed
return;
}
// The second player has agreed
// Check if both player has the objects in their inventories
// and enouth money, then swap them.
Inventory v1(mChar1, true), v2(mChar2, true);
if (mChar1->getAttribute(mCurrencyId) >= mMoney1 - mMoney2 &&
mChar2->getAttribute(mCurrencyId) >= mMoney2 - mMoney1 &&
perform(mItems1, v1, v2) &&
perform(mItems2, v2, v1))
{
mChar1->setAttribute(mCurrencyId, mChar1->getAttribute(mCurrencyId)
- mMoney1 + mMoney2);
mChar2->setAttribute(mCurrencyId, mChar2->getAttribute(mCurrencyId)
- mMoney2 + mMoney1);
}
else
{
v1.cancel();
v2.cancel();
cancel();
return;
}
MessageOut msg(GPMSG_TRADE_COMPLETE);
mChar1->getClient()->send(msg);
mChar2->getClient()->send(msg);
delete this;
}
示例3: dashboard_conn_check
void dashboard_conn_check(std::string cloud_name) {
if(!msattrs) {
APIDictionary result(perform("cldshow", cloud_name, "metricstore"));
host = APIString(result["hostname"]);
port = APIString(result["port"]);
msci.connect(host + ":" + port + "/metrics");
result = APIDictionary(perform("cldshow", cloud_name, "time"));
username = APIString(result["username"]);
msattrs = 1;
}
}
示例4: test
int test(char *URL)
{
CURLM *multi;
CURL *easy;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
if ((multi = curl_multi_init()) == NULL) {
fprintf(stderr, "curl_multi_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
if ((easy = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_multi_cleanup(multi);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
curl_multi_setopt(multi, CURLMOPT_PIPELINING, 1);
curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION, fwrite);
curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1);
curl_easy_setopt(easy, CURLOPT_URL, URL);
curl_multi_add_handle(multi, easy);
if (perform(multi) != CURLM_OK)
printf("retrieve 1 failed\n");
curl_multi_remove_handle(multi, easy);
curl_easy_reset(easy);
curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1);
curl_easy_setopt(easy, CURLOPT_URL, arg2);
curl_multi_add_handle(multi, easy);
if (perform(multi) != CURLM_OK)
printf("retrieve 2 failed\n");
curl_multi_remove_handle(multi, easy);
curl_easy_cleanup(easy);
curl_multi_cleanup(multi);
curl_global_cleanup();
printf("Finished!\n");
return 0;
}
示例5: config_
LoaderDatabaseConnection::LoaderDatabaseConnection(const LoaderConfiguration & config)
: pqxx::connection(config.database().pqDatabaseConnection()), config_(new LoaderConfiguration(config))
{
if ( config.loading().nameSpace.empty() )
perform ( BeginWci(config.database().user) );
else if (config.loading().nameSpace == "test" )
perform ( BeginWci(config.database().user, 999, 999, 999) );
else if (config.loading().nameSpace == "default" )
perform ( BeginWci(config.database().user, 0, 0, 0) );
else
throw std::logic_error("Unknown name space specification: " + config.loading().nameSpace );
setup_();
}
示例6: assert
DBI::Error Transaction::truncate(const AnyString& tablename)
{
if (YUNI_UNLIKELY(not IsValidIdentifier(tablename)))
return errInvalidIdentifier;
assert(!(!pChannel));
// the adapter
::yn_dbi_adapter& adapter = pChannel->adapter;
// The DBI interface should provide the most appropriate way for
// truncating a table (autoincrement / cascade...)
if (YUNI_LIKELY(adapter.truncate))
{
return (DBI::Error) adapter.truncate(adapter.dbh, tablename.c_str(), tablename.size());
}
else
{
// Fallback to a failsafe method
// -- stmt << "TRUNCATE " << tablename << ';';
// The SQL command Truncate is not supported by all databases. `DELETE FROM`
// is not the most efficient way for truncating a table
// but it should work almost everywhere
String stmt;
stmt << "DELETE FROM " << tablename << ';';
return perform(stmt);
}
}
示例7: main
int main(int argc, char *argv[])
{
toxdump_args_t args = TOXDUMP_INIT_ARGS;
parse_args(argc, argv, &args);
int ret = perform(&args);
return ret;
}
示例8: perform
DisplayWindow *FourierDCT::invert(ComplexArray *ca, QString title, QImage::Format format, QWidget *p)
{
int w = ca->shape()[1];
int h = ca->shape()[2];
perform(ca, true);
ColorParser cp(format);
QImage result(w, h, format);
result.fill(Qt::black);
if (format == QImage::Format_Indexed8) {
QVector<QRgb> colors;
colors.reserve(256);
for (int i = 0; i < 256; i++) {
colors << qRgb(i, i, i);
}
result.setColorTable(colors);
}
for (unsigned int i = 1; i < ca->shape()[0]; i += 2) {
qreal min = 0;
qreal max = 0;
for (unsigned int j = 0; j < ca->shape()[1]; j++) {
for (unsigned int k = 0; k < ca->shape()[2]; k++) {
Complex c = (*ca)[i][j][k];
qreal real = c.real();
if (real > max) {
max = real;
} else if (real < min) {
min = real;
}
}
}
for (unsigned int j = 0; j < ca->shape()[1]; j++) {
for (unsigned int k = 0; k < ca->shape()[2]; k++) {
Complex c = (*ca)[i][j][k];
qreal p = (c.real() - min) / (max - min) * 255.0;
{
QVector3D oldPixel = cp.pixel(k, j, result);
QVector3D newPixel;
switch (i / 2) {
case 0:
newPixel.setX(p);
break;
case 1:
newPixel.setY(p);
break;
case 2:
newPixel.setZ(p);
break;
default:
break;
}
cp.setPixel(k, j, result, cp.merge(oldPixel, newPixel));
}
}
}
}
result = result.rgbSwapped();
PhotoWindow *pw = new PhotoWindow(result, title + ", IFDCT", p);
return pw;
}
示例9: initRequest
bool HttpCurl::post(string url, string content)
{
CURLcode result;
initRequest(url);
m_sendBuffer.initialize(content);
// set request type to post
if ((result = curl_easy_setopt(m_curl, CURLOPT_POST, 1L)) != 0)
{
CurlException ex(result, m_message);
throw ex;
}
if ((result = curl_easy_setopt(m_curl, CURLOPT_POSTFIELDSIZE, content.length())) != 0)
{
CurlException ex(result, m_message);
throw ex;
}
perform();
return true;
}
示例10: BinaryImage
// Default constructor
UltimateErodedBinaryImage::UltimateErodedBinaryImage(BinaryImage& img)
: BinaryImage(img)
{
perform(this);
}
示例11: newPoint
//==============================================================================
void PaintElementPath::movePoint (int index, int pointNumber,
double newX, double newY,
const Rectangle<int>& parentArea,
const bool undoable)
{
if (PathPoint* const p = points [index])
{
PathPoint newPoint (*p);
jassert (pointNumber < 3 || p->type == Path::Iterator::cubicTo);
jassert (pointNumber < 2 || p->type == Path::Iterator::cubicTo || p->type == Path::Iterator::quadraticTo);
RelativePositionedRectangle& pr = newPoint.pos [pointNumber];
double x, y, w, h;
pr.getRectangleDouble (x, y, w, h, parentArea, getDocument()->getComponentLayout());
pr.updateFrom (newX, newY, w, h, parentArea, getDocument()->getComponentLayout());
if (undoable)
{
perform (new ChangePointAction (p, index, newPoint), "Move path point");
}
else
{
*p = newPoint;
changed();
}
}
}
示例12: GreyLevelImage
// Default constructor
RegionalMinImage::RegionalMinImage(GreyLevelImage& img)
: GreyLevelImage(img)
{
perform(this);
}
示例13: perform
bool RegistrationOperation::performSafely( const RegistrationArguments& args
, RegistrationController& controller
, QWidget* dialogParent )
{
const QString msgBoxTitle = QString::fromStdString( name );
QApplication::setOverrideCursor( Qt::WaitCursor );
try
{
perform( args, controller, dialogParent );
QApplication::restoreOverrideCursor();
return true;
}
catch( const std::exception& ex )
{
QMessageBox::critical( dialogParent, msgBoxTitle, QString::fromStdString( ex.what() ) );
}
catch( ... )
{
QMessageBox::critical( dialogParent, msgBoxTitle, "Unknown error" );
}
QApplication::restoreOverrideCursor();
return false;
}
示例14: throw
OpenBinaryImage::OpenBinaryImage(const BinaryImage& anImg,
unsigned int anOpenSize)
throw(QgarErrorDomain)
: BinaryImage(anImg)
{
int sqsize = (2 * anOpenSize) + 1; // Effective mask size
if ((sqsize > anImg.width()) || (sqsize > anImg.height()))
{
std::ostringstream os;
os << "Opening size ["
<< sqsize
<< " X "
<< sqsize
<< "] too large for image ["
<< anImg.width()
<< " X "
<< anImg.height()
<< "]";
throw QgarErrorDomain(__FILE__, __LINE__,
"void qgar::OpenBinaryImage::OpenBinaryImage(const qgar::BinaryImage&, unsigned int)",
os.str());
}
perform(this, anOpenSize);
}
示例15: BinaryImage
// Default constructor
RegionalMaxBinaryImage::RegionalMaxBinaryImage(BinaryImage& anImg)
: BinaryImage(anImg)
{
perform(this);
}