本文整理汇总了C++中setFunction函数的典型用法代码示例。如果您正苦于以下问题:C++ setFunction函数的具体用法?C++ setFunction怎么用?C++ setFunction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setFunction函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StateBase
CourseMenu::CourseMenu(fw::GameBase& game)
: StateBase(game)
, courseMenu_({ game.getWindow().getSize().x / 2.f, 90.f })
{
std::string coursesText = framework::loadTextFromFile("data/courses.txt");
std::vector<std::string> coursesLines = framework::getLinesFromText(coursesText);
for(const auto line : coursesLines)
{
auto button = std::make_unique<fw::gui::Button>();
button->setText(line);
button->setFunction([&] ()
{
// empty action
});
courseMenu_.addWidget(std::move(button));
}
auto bback = std::make_unique<fw::gui::Button>();
bback->setText("Back");
bback->setFunction([&]()
{
game_.popState();
});
courseMenu_.addWidget(std::move(bback));
}
示例2: if
void fitDialog::showExpression(int function)
{
if (categoryBox->currentItem() == 2)
{
explainBox->setText(myParser::explainFunction(function));
}
else if (categoryBox->currentItem() == 1)
{
explainBox->setText(builtInFunctions[function]);
setFunction(boxUseBuiltIn->isChecked());
}
else if (categoryBox->currentItem() == 0)
{
QStringList l = QStringList::split("=", userFunctions[function], true);
explainBox->setText(l[1]);
setFunction(boxUseBuiltIn->isChecked());
}
else if (categoryBox->currentItem() == 3)
{
if ((int)pluginFunctions.size() > 0)
{
explainBox->setText(pluginFunctions[function]);
setFunction(boxUseBuiltIn->isChecked());
}
else
explainBox->clear();
}
}
示例3: deviceAccelerometerGetInterface
int deviceAccelerometerGetInterface(unsigned char commandHeader, DeviceInterfaceMode mode, bool fillDeviceArgumentList) {
if (commandHeader == COMMAND_ACCELEROMETER_GET_SAMPLE_COUNT) {
if (fillDeviceArgumentList) {
setFunction("getSampleCount", 0, 1);
setResultUnsignedHex4(0, "Sample count");
}
return commandLengthValueForMode(mode, 0, 4);
}
else if (commandHeader == COMMAND_ACCELEROMETER_GET_SAMPLE_RAW_DATA) {
if (fillDeviceArgumentList) {
setFunction("Sample Raw Data", 0, 5);
setResultUnsignedHex4(0, "X Raw Data");
setResultSeparator(1);
setResultUnsignedHex4(2, "Y Raw Data");
setResultSeparator(3);
setResultUnsignedHex4(4, "Z Raw Data");
}
return commandLengthValueForMode(mode, 0, 14);
}
else if (commandHeader == COMMAND_ACCELEROMETER_GET_SAMPLE_DATA_MILLIG_G) {
if (fillDeviceArgumentList) {
setFunction("Sample Data MilliG", 0, 5);
setResultUnsignedHex4(0, "X (mG)");
setResultSeparator(1);
setResultUnsignedHex4(2, "Y (mG)");
setResultSeparator(3);
setResultUnsignedHex4(4, "Z (mG)");
}
return commandLengthValueForMode(mode, 0, 14);
}
// TRESHOLD
else if (commandHeader == COMMAND_ACCELEROMETER_GET_THRESHOLD) {
if (fillDeviceArgumentList) {
setFunction("Get Threshold", 0, 1);
setResultUnsignedHex4(0, "Threshold (milli G)");
}
return commandLengthValueForMode(mode, 0, 4);
}
else if (commandHeader == COMMAND_ACCELEROMETER_SET_THRESHOLD) {
if (fillDeviceArgumentList) {
setFunction("Set Threshold", 1, 0);
setArgumentUnsignedHex4(0, "Threshold (milliG)");
}
return commandLengthValueForMode(mode, 4, 0);
}
// DEBUG
else if (commandHeader == COMMAND_ACCELEROMETER_DEBUG_CONFIG) {
if (fillDeviceArgumentList) {
setFunctionNoArgumentAndNoResult("Debug Config");
}
return commandLengthValueForMode(mode, 0, 0);
}
else if (commandHeader == COMMAND_ACCELEROMETER_DEBUG_VALUES) {
if (fillDeviceArgumentList) {
setFunctionNoArgumentAndNoResult("Debug Values");
}
return commandLengthValueForMode(mode, 0, 0);
}
return DEVICE_HEADER_NOT_HANDLED;
}
示例4: deviceTestGetInterface
int deviceTestGetInterface(char commandHeader, DeviceInterfaceMode mode, bool fillDeviceArgumentList) {
if (commandHeader == COMMAND_TEST) {
if (fillDeviceArgumentList) {
setFunction("test", 2, 1);
setArgumentUnsignedHex2(0, "a");
setArgumentUnsignedHex2(1, "b");
setResultUnsignedHex2(0, "result");
}
return commandLengthValueForMode(mode, 4, 2);
}
else if (commandHeader == COMMAND_SIMPLE_TEST) {
if (fillDeviceArgumentList) {
setFunctionNoArgumentAndNoResult("simpleTest");
}
return commandLengthValueForMode(mode, 0, 0);
}
else if (commandHeader == COMMAND_HEAVY_TEST) {
if (fillDeviceArgumentList) {
setFunction("heavyTest", 10, 1);
setArgumentUnsignedHex2(0, "a");
setArgumentUnsignedHex2(1, "b");
setArgumentUnsignedHex4(2, "c");
setArgumentUnsignedHex4(3, "d");
setArgumentUnsignedHex2(4, "e");
setArgumentSeparator(5);
setArgumentUnsignedHex2(6, "f");
setArgumentUnsignedHex4(7, "g");
setArgument(8, DEVICE_ARG_UNSIGNED_HEX_6, "h");
setArgumentUnsignedHex2(9, "i");
setResult(0, DEVICE_ARG_UNSIGNED_HEX_6, "result");
}
return commandLengthValueForMode(mode, 29, 6);
}
// Debug Test
else if (commandHeader == COMMAND_DEBUG_TEST) {
if (fillDeviceArgumentList) {
setFunctionNoArgumentAndNoResult("debugTest");
}
return commandLengthValueForMode(mode, 0, 0);
}
else if (commandHeader == COMMAND_GENERATE_NOTIFY_TEST) {
if (fillDeviceArgumentList) {
setFunction("generateNotifyTest", 1, 0);
setArgumentUnsignedHex2(0, "notifyTestValue");
}
return commandLengthValueForMode(mode, 2, 0);
}
// Handle a notification test
else if (mode == DEVICE_MODE_NOTIFY) {
if (commandHeader == NOTIFY_TEST) {
if (fillDeviceArgumentList) {
setNotification("notifyTest", 1);
setArgumentUnsignedHex2(0, "notifyArg0");
}
return 2;
}
}
return DEVICE_HEADER_NOT_HANDLED;
}
示例5: deserialize_symbol
Item::e_sercode Item::deserialize_function( Stream *file, VMachine *vm )
{
if ( vm == 0 )
return sc_missvm;
Symbol *sym;
LiveModule *lmod;
e_sercode sc = deserialize_symbol( file, vm, &sym, &lmod );
if ( sc != sc_ok )
return sc;
// read the function called status
if ( ! sym->isFunction() ) {
// external function
setFunction( new CoreFunc( sym, lmod ) );
return sc_ok;
}
// internal function.
FuncDef *def = sym->getFuncDef();
// read the once status
uint32 itemId = def->onceItemId();
if( itemId != FuncDef::NO_STATE )
{
byte called;
file->read( &called, 1 );
if( called )
lmod->globals()[ itemId ].setInteger( 1 );
else
lmod->globals()[ itemId ].setNil();
}
CoreFunc* function = new CoreFunc( sym, lmod );
// read the closure state.
uint32 closlen;
file->read( &closlen, sizeof( closlen ) );
if( closlen != 0 )
{
ItemArray* closure = new ItemArray( closlen );
closure->resize( closlen );
// put the state in now, so we can destroy it in case of error.
function->closure( closure );
// deserialize all the items.
for( uint32 i = 0; i < closlen; i++ ) {
Item::e_sercode res = (*closure)[i].deserialize(file, vm );
if ( res != sc_ok )
return res;
}
}
setFunction( function );
return sc_ok;
}
示例6: if
void FitDialog::showExpression(int function)
{
if (function < 0)
return;
if (categoryBox->currentRow() == 2)
{
explainBox->setText(MyParser::explainFunction(function));
}
else if (categoryBox->currentRow() == 1)
{
polynomOrderLabel->show();
polynomOrderBox->show();
switch(funcBox->currentRow ()) {
case 6: // Gauss
polynomOrderLabel->setText(tr("Peaks"));
explainBox->setText(MultiPeakFit::generateFormula(polynomOrderBox->value(), MultiPeakFit::Gauss));
break;
case 7: // Lorentz
polynomOrderLabel->setText(tr("Peaks"));
explainBox->setText(MultiPeakFit::generateFormula(polynomOrderBox->value(), MultiPeakFit::Lorentz));
break;
case 8: // Polynomial
polynomOrderLabel->setText(tr("Polynomial Order"));
explainBox->setText(PolynomialFit::generateFormula(polynomOrderBox->value()));
break;
default:
polynomOrderLabel->hide();
polynomOrderBox->hide();
polynomOrderBox->setValue(1);
explainBox->setText(d_built_in_functions[function]);
}
setFunction(boxUseBuiltIn->isChecked());
}
else if (categoryBox->currentRow() == 0)
{
if (d_user_functions.size() > function) {
QStringList l = d_user_functions[function].split("=");
explainBox->setText(l[1]);
} else
explainBox->clear();
setFunction(boxUseBuiltIn->isChecked());
}
else if (categoryBox->currentRow() == 3)
{
if (d_plugin_functions.size() > 0)
{
explainBox->setText(d_plugin_functions[function]);
setFunction(boxUseBuiltIn->isChecked());
}
else
explainBox->clear();
}
}
示例7: deviceIOExpanderGetInterface
int deviceIOExpanderGetInterface(unsigned char commandHeader, DeviceInterfaceMode mode, bool fillDeviceArgumentList) {
if (commandHeader == COMMAND_IO_EXPANDER_WRITE_SINGLE_BIT) {
if (fillDeviceArgumentList) {
setFunction("Write Single Bit", 5, 0);
setArgumentUnsignedHex2(0, "IO Expander Index");
setArgumentSeparator(1);
setArgumentUnsignedHex2(2, "IO Index");
setArgumentSeparator(3);
setArgumentUnsignedChar1(4, "Value (bool)");
}
return commandLengthValueForMode(mode, 7, 0);
}
if (commandHeader == COMMAND_IO_EXPANDER_WRITE_VALUE) {
if (fillDeviceArgumentList) {
setFunction("Write Value", 3, 0);
setArgumentUnsignedHex2(0, "IO Expander Index");
setArgumentSeparator(1);
setArgumentUnsignedHex2(2, "Value");
}
return commandLengthValueForMode(mode, 5, 0);
}
else if (commandHeader == COMMAND_IO_EXPANDER_READ_SINGLE_BIT) {
if (fillDeviceArgumentList) {
setFunction("Read Single Bit", 3, 1);
setArgumentUnsignedHex2(0, "IO Expander Index");
setArgumentSeparator(1);
setArgumentUnsignedHex2(2, "IO Index");
setResultUnsignedChar1(0, "Value (bool)");
}
return commandLengthValueForMode(mode, 5, 1);
}
else if (commandHeader == COMMAND_IO_EXPANDER_READ_VALUE) {
if (fillDeviceArgumentList) {
setFunction("Read Value", 1, 1);
setArgumentUnsignedHex2(0, "IO Expander Index");
setResultUnsignedHex2(0, "Value");
}
return commandLengthValueForMode(mode, 2, 2);
}
else if (commandHeader == COMMAND_IO_EXPANDER_DEBUG) {
if (fillDeviceArgumentList) {
setFunctionNoArgumentAndNoResult("Debug as Table");
}
return commandLengthValueForMode(mode, 0, 0);
}
return DEVICE_HEADER_NOT_HANDLED;
}
示例8: deviceStrategy2018GetInterface
int deviceStrategy2018GetInterface(char commandHeader, DeviceInterfaceMode mode, bool fillDeviceArgumentList) {
if (commandHeader == STRATEGY_2018_DISTRIBUTOR_DEBUG_COMMAND) {
if (fillDeviceArgumentList) {
setFunctionNoArgumentAndNoResult("Strategy 2018 Distributor Debug");;
}
return commandLengthValueForMode(mode, 0, 0);
}
else if (commandHeader == STRATEGY_2018_GET_SCORE) {
if (fillDeviceArgumentList) {
setFunction("Strategy 2018 Distributor Debug", 0, 1);
setResultUnsignedHex2(0, "score");
}
return commandLengthValueForMode(mode, 0, 2);
}
else if (commandHeader == STRATEGY_2018_READ_BALL_COLOR_TYPE) {
if (fillDeviceArgumentList) {
setFunctionNoArgumentAndNoResult("Strategy 2018 Read Color Type");;
}
return commandLengthValueForMode(mode, 0, 0);
}
else if (commandHeader == STRATEGY_2018_UNICOLOR_COMMAND) {
if (fillDeviceArgumentList) {
setFunctionNoArgumentAndNoResult("Strategy 2018 Unicolor");;
}
return commandLengthValueForMode(mode, 0, 0);
}
return DEVICE_HEADER_NOT_HANDLED;
}
示例9: Expression
void Expression::fromParser(const Kernel::EParser& p)
{
m_op = p.operator_name();
bool special_case = p.name() == "+";
if (p.isFunct())
{
// create the arguments first
for(Kernel::EParser::iterator it=p.begin();it!= p.end();it++)
{
if (special_case &&((**it).name() == "-" && (**it).size() == 1))
{
special_case = false;
Expression* arg = new Expression(m_namespace,**((**it).begin()));
arg->m_op = "-";
m_terms.push_back(boost::shared_ptr<Expression>(arg));
}
else
{
Expression* arg = new Expression(m_namespace,**it);
m_terms.push_back(boost::shared_ptr<Expression>(arg));
}
}
// set the function object
setFunction(p.name());
}
else
{
setVariable(p.name());
}
}
示例10: miosStudio
//==============================================================================
MidiSlider::MidiSlider(MiosStudio *_miosStudio, int _num, String _functionName, int _functionArg, int _midiChannel, int initialValue, bool _vertical)
: miosStudio(_miosStudio)
, sliderNum(_num)
, vertical(_vertical)
{
addAndMakeVisible(slider = new MidiSliderComponent(T("Slider")));
slider->setSliderStyle(vertical ? MidiSliderComponent::LinearVertical : MidiSliderComponent::LinearHorizontal);
slider->addListener(this);
// only used for horizontal sliders
addAndMakeVisible(sliderFunction = new ComboBox(String::empty));
sliderFunction->addListener(this);
// restore settings
PropertiesFile *propertiesFile = MiosStudioProperties::getInstance()->getCommonSettings(true);
if( propertiesFile ) {
_functionName = propertiesFile->getValue("slider" + String(sliderNum) + "FunctionName", _functionName);
_functionArg = propertiesFile->getIntValue("slider" + String(sliderNum) + "FunctionArg", _functionArg);
_midiChannel = propertiesFile->getIntValue("slider" + String(sliderNum) + "MidiChannel", _midiChannel);
initialValue = propertiesFile->getIntValue("slider" + String(sliderNum) + "InitialValue", initialValue);
}
setFunction(_functionName, _functionArg, _midiChannel, initialValue);
if( vertical )
setSize(24, 18+80);
else
setSize(128, 24+18);
}
示例11: LineVertex
void SurfaceVisual::initialize()
{
m_VertexBuffer.resize( 4 );
m_VertexBuffer.allocHostMemory();
m_VertexBuffer[ 0 ] = LineVertex( 0.0f, 0.0f );
m_VertexBuffer[ 1 ] = LineVertex( 0.0f, 1.0f );
m_VertexBuffer[ 2 ] = LineVertex( 1.0f, 1.0f );
m_VertexBuffer[ 3 ] = LineVertex( 1.0f, 0.0f );
m_VertexBuffer.copyToDevice();
ShaderManager& shaders = engine.shaders;
m_pVertexShader =
shaders.getShader<Shader::Type::Vertex>( "line" );
m_pTessControlShader =
shaders.getShader<Shader::Type::TessellationControl>( "surface" );
m_pTessEvalShader =
Shader::fromName( Shader::Type::TessellationEvaluation, "surface" );
m_pFragmentShader =
shaders.getShader<Shader::Type::Fragment>( "line" );
// setFunction( GpuFunctionSource( 2, 3,
// "return vec3( v, 0.0 );" ) );
setFunction( GpuFunctionSource( 2, 3,
"float R = 2.0;\n"
"float rmin = 1.0;\n"
"float rmax = R;\n"
"float s = R - v.y * ( ( rmax - rmin ) * 0.5 * ( sin( t ) + 1.0 ) + rmin );\n"
"return vec3( 10.0 * v.x - sin( 0.5 * t ) * 2.0 * ( ( s / R - 1.0 ) * ( s / R - 1.0 ) ), s * 2.0 * sin( 1.0 * f_time + PERIODS * v.x * TWO_PI ), s * 2.0 * cos( 1.0 * f_time + PERIODS * v.x * TWO_PI ) );" ) );
}
示例12: commonBeaconDeviceGetInterface
int commonBeaconDeviceGetInterface(char commandHeader, DeviceInterfaceMode mode, bool fillDeviceArgumentList) {
// Redirection
if (commandHeader == COMMAND_REDIRECT_TO_JENNIC) {
// same output / input
if (fillDeviceArgumentList) {
setFunctionNoArgumentAndNoResult("redirectToJennic");
}
return commandLengthValueForMode(mode, 0, 0);
}
else if (commandHeader == COMMAND_LOCAL_LIGHT) {
if (fillDeviceArgumentList) {
setFunction("localLight", 1, 2);
setArgumentUnsignedHex2(2, "on/off");
}
return commandLengthValueForMode(mode, 2, 0);
}
else if (commandHeader == COMMAND_SHOW_DATA_FROM_JENNIC) {
// both input/output
if (fillDeviceArgumentList) {
setFunctionNoArgumentAndNoResult("showDataFromJennic");
}
return commandLengthValueForMode(mode, 0, 0);
}
else if (commandHeader == COMMAND_RESET_JENNIC) {
// both input/output
if (fillDeviceArgumentList) {
setFunctionNoArgumentAndNoResult("resetJennic");
}
return commandLengthValueForMode(mode, 0, 0);
}
return DEVICE_HEADER_NOT_HANDLED;
}
示例13: deviceCodersGetInterface
int deviceCodersGetInterface(char header, int mode, BOOL fillDeviceArgumentList) {
if (header == COMMAND_CLEAR_CODERS) {
// Same INPUT / OUTPUT
if (fillDeviceArgumentList) {
setFunctionNoArgument("clrCoders");
}
return 0;
} else if (header == COMMAND_GET_WHEEL_POSITION) {
if (mode == DEVICE_MODE_INPUT) {
if (fillDeviceArgumentList) {
setFunctionNoArgument("codersVal");
}
return 0;
} else if (mode == DEVICE_MODE_OUTPUT) {
if (fillDeviceArgumentList) {
setFunction("codersVal", 3);
setArgument(0, DEVICE_ARG_UNSIGNED_HEX_8, "left");
setArgumentSeparator(1);
setArgument(2, DEVICE_ARG_UNSIGNED_HEX_8, "right");
}
return 17;
}
} else if (header == COMMAND_DEBUG_GET_WHEEL_POSITION) {
// Same INPUT / OUTPUT
if (fillDeviceArgumentList) {
setFunctionNoArgument("dbgCodersVal");
}
return 0;
}
return DEVICE_HEADER_NOT_HANDLED;
}
示例14: OVRCreateDXGIFactory2
HRESULT APIENTRY OVRCreateDXGIFactory2(
__in UINT flags,
__in const IID &riid,
__out void **ppFactory
)
{
HRESULT result = E_FAIL;
restoreFunction( (PROC)oldCreateDXGIFactory2, oldCreateDXGIFactory2Data );
if (IN_COMPATIBILITY_MODE())
{
result = (*oldCreateDXGIFactory2)(flags, riid, ppFactory);
}
else
{
WinCreateDXGIFactory2 createFunction = (WinCreateDXGIFactory2)GetProcAddress(rtFilterModule, "CreateDXGIFactory2");
result = (*createFunction)(flags, riid, ppFactory);
}
setFunction( (PROC)oldCreateDXGIFactory2, (PROC)OVRCreateDXGIFactory2, oldCreateDXGIFactory2Data );
printf("%s result 0x%x\n", __FUNCTION__, result);
return result;
}
示例15: OVRCreateDXGIFactory1
HRESULT APIENTRY OVRCreateDXGIFactory1(
__in REFIID riid,
__out void **ppFactory
)
{
HRESULT result = E_FAIL;
restoreFunction( (PROC)oldCreateDXGIFactory1, oldCreateDXGIFactory1Data );
if (IN_COMPATIBILITY_MODE())
{
result = (*oldCreateDXGIFactory1)(riid, ppFactory);
}
else
{
WinCreateDXGIFactory1 createFunction = (WinCreateDXGIFactory1)GetProcAddress(rtFilterModule, "CreateDXGIFactory1");
result = (*createFunction)(riid, ppFactory);
}
setFunction( (PROC)oldCreateDXGIFactory1, (PROC)OVRCreateDXGIFactory1, oldCreateDXGIFactory1Data );
printf("%s result 0x%x\n", __FUNCTION__, result);
return result;
}