本文整理汇总了C++中Switch函数的典型用法代码示例。如果您正苦于以下问题:C++ Switch函数的具体用法?C++ Switch怎么用?C++ Switch使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Switch函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: coeffsDict_
Foam::automatic::automatic
(
const dictionary& cellSizeCalcTypeDict,
const triSurfaceMesh& surface,
const scalar& defaultCellSize
)
:
cellSizeCalculationType
(
typeName,
cellSizeCalcTypeDict,
surface,
defaultCellSize
),
coeffsDict_(cellSizeCalcTypeDict.subDict(typeName + "Coeffs")),
surfaceName_(surface.searchableSurface::name()),
readCurvature_(Switch(coeffsDict_.lookup("curvature"))),
curvatureFile_(coeffsDict_.lookup("curvatureFile")),
readFeatureProximity_(Switch(coeffsDict_.lookup("featureProximity"))),
featureProximityFile_(coeffsDict_.lookup("featureProximityFile")),
readInternalCloseness_(Switch(coeffsDict_.lookup("internalCloseness"))),
internalClosenessFile_(coeffsDict_.lookup("internalClosenessFile")),
curvatureCellSizeCoeff_
(
readScalar(coeffsDict_.lookup("curvatureCellSizeCoeff"))
),
maximumCellSize_
(
readScalar(coeffsDict_.lookup("maximumCellSizeCoeff"))*defaultCellSize
)
{}
示例2: Partition
int Partition(int a[], int low, int high) {
int pk = a[low];
while (low < high) {
while (low<high && (a[high]>pk))high--;
Switch(&a[low], &a[high]);
while (low < high && (a[low] < pk))low++;
Switch(&a[low], &a[high]);
}
return low;
}
示例3: SetState
//------------------------------------------------------------------------------------------------
bool Person::PickUp(GunObject* gunobject)
{
if (gunobject->mGun->mType == PRIMARY) {
if (mGuns[PRIMARY] == NULL) {
mGuns[PRIMARY] = gunobject;
gunobject->mOnGround = false;
/*if (mState == RELOADING) {
SetState(NORMAL);
if (mSoundId != -1) {
mSoundSystem->StopSample(mSoundId);
mSoundId = -1;
}
}
mGunIndex = PRIMARY;*/
Switch(PRIMARY);
gSfxManager->PlaySample(gPickUpSound, mX, mY);
return true;
}
}
else if (gunobject->mGun->mType == SECONDARY) {
if (mGuns[SECONDARY] == NULL) {
mGuns[SECONDARY] = gunobject;
gunobject->mOnGround = false;
if (mGuns[PRIMARY] == NULL) {
//mGunIndex = SECONDARY;
Switch(SECONDARY);
}
gSfxManager->PlaySample(gPickUpSound, mX, mY);
return true;
}
}
else if (gunobject->mGun->mType == KNIFE) {
if (mGuns[KNIFE] == NULL) {
mGuns[KNIFE] = gunobject;
gunobject->mOnGround = false;
return true;
}
}
else if (gunobject->mGun->mType == GRENADE) {
if (mGuns[GRENADE] == NULL) {
mGuns[GRENADE] = gunobject;
gunobject->mOnGround = false;
if (mGuns[PRIMARY] == NULL && mGuns[SECONDARY] == NULL) {
//mGunIndex = GRENADE;
Switch(GRENADE);
}
gSfxManager->PlaySample(gPickUpSound, mX, mY);
return true;
}
}
return false;
}
示例4: simnet
void simnet()
{
Signal a, b, c, d, F; // Switch and output objects
Switch ( SD("1a"), a, 'a' ); // Switch a controlled by 'a' key
Switch ( SD("2a"), b, 'b' ); // Switch b controlled by 'b' key
Switch ( SD("3a"), c, 'c' ); // Switch c controlled by 'c' key
Switch ( SD("4a"), d, 'd' ); // Switch d controlled by 'd' key
circuit( SD("1c-4c"), a, b, c, d, F );
Probe ( (SD("2e"), "F"), F ); // Probe
}
示例5: liggghtsCommandModel
// Construct from components
writeLiggghts::writeLiggghts
(
const dictionary& dict,
cfdemCloud& sm,
int i
)
:
liggghtsCommandModel(dict,sm,i),
propsDict_(dict),
command_("write_restart"),
path_(word("..")/word("DEM")),
writeName_("liggghts.restartCFDEM"),
writeLast_(true),
overwrite_(true)
{
if (dict.found(typeName + "Props"))
{
propsDict_=dictionary(dict.subDict(typeName + "Props"));
// check if verbose
if (propsDict_.found("verbose")) verbose_=true;
if(propsDict_.found("writeLast"))
{
writeLast_=Switch(propsDict_.lookup("writeLast"));
}
if (!writeLast_ && propsDict_.found("overwrite"))
{
overwrite_=Switch(propsDict_.lookup("overwrite"));
}
}
if(writeLast_)
runLast_=true;
else
{
//Warning << "Using invalid options of writeLiggghts, please use 'writeLast' option." << endl;
runEveryWriteStep_=true;
}
command_ += " " + path_ + "/" + writeName_;
if(overwrite_)
strCommand_=string(command_);
else
command_ += "_";
Info << "writeLiggghts: A restart file writeName_"<< command_ <<" is written." << endl;
checkTimeSettings(dict_);
}
示例6: mesh_
// Construct from components
polyStateController::polyStateController
(
Time& t,
polyMoleculeCloud& molCloud,
const dictionary& dict
)
:
mesh_(refCast<const fvMesh>(molCloud.mesh())),
molCloud_(molCloud),
// controllerDict_(dict.subDict("controllerProperties")),
time_(t),
regionName_(dict.lookup("zoneName")),
regionId_(-1),
control_(true),
controlInterForces_(false),
writeInTimeDir_(true),
writeInCase_(true)
{
const cellZoneMesh& cellZones = mesh_.cellZones();
regionId_ = cellZones.findZoneID(regionName_);
if(regionId_ == -1)
{
FatalErrorIn("polyStateController::polyStateController()")
<< "Cannot find region: " << regionName_ << nl << "in: "
<< time_.time().system()/"controllersDict"
<< exit(FatalError);
}
if(dict.found("control"))
{
control_ = Switch(dict.lookup("control"));
}
// readStateFromFile_ = Switch(dict.lookup("readStateFromFile"));
}
示例7: main
int main (void)
{
uint8_t no = 0;
// wait(10);
setMU2PutFunc(uart0Put);
setMU2GetFunc(uart0Get);
initUART(
UART0,
StopBitIs1Bit|NonParity,
ReceiverEnable|TransmiterEnable|ReceiveCompleteInteruptEnable,
UARTBAUD(19200)
);
initLED();
initSwitch();
initRCRx();
no = Switch() & 0x03;
mu2Command("EI",EI[no]);
mu2Command("DI",DI[no]);
mu2Command("GI",GI[no]);
mu2Command("CH",CH[no]);
sei();
userMain();
return 0;
}
示例8: isPressed
bool CTabBarClass::OnKeyboard(UINT messg, WPARAM wParam, LPARAM lParam)
{
//if (!IsShown()) return FALSE; -- всегда. Табы теперь есть в памяти
BOOL lbAltPressed = isPressed(VK_MENU);
if (messg == WM_KEYDOWN && wParam == VK_TAB)
{
if (!isPressed(VK_SHIFT))
SwitchNext(lbAltPressed);
else
SwitchPrev(lbAltPressed);
return true;
}
else if (mb_InKeySwitching && messg == WM_KEYDOWN && !lbAltPressed
&& (wParam == VK_UP || wParam == VK_DOWN || wParam == VK_LEFT || wParam == VK_RIGHT))
{
bool bRecent = gpSet->isTabRecent;
gpSet->isTabRecent = false;
BOOL bForward = (wParam == VK_RIGHT || wParam == VK_DOWN);
Switch(bForward);
gpSet->isTabRecent = bRecent;
return true;
}
return false;
}
示例9: switch
eOSState cMenuAnnounceList::ProcessKey(eKeys Key)
{
eOSState state = cMenuSearchResultsForList::ProcessKey(Key);
if (state == osUnknown)
{
switch (Key) {
case kBlue:
{
cMenuSearchResultsItem *item = (cMenuSearchResultsItem *)Get(Current());
if (item)
{
if (!HasSubMenu())
return AddSubMenu(new cMenuAnnounceDetails(item->event, item->search));
else if (!showsDetails)
return Switch();
else
return osContinue;
}
}
break;
default:
break;
}
}
return state;
}
示例10: Switch
CString CCommandLineParameters::GetSwitchStr(const char *sz,
const char *szDefault, /* = "" */
const BOOL bCase /* = FALSE */
)
{
int idx = Switch(sz,bCase);
if (idx > 0) {
CString s = ParamStr(idx);
int n = s.Find(':');
if (n > -1) {
CString ts = s.Mid(n + 1);
ts.Replace("\"", "");
return ts;
// return s.Mid(n+1);
}
// else {
// if ((idx+1) < paramcount) {
// if (!IsSwitch(parms[idx+1])) {
// return parms[idx+1];
// }
// }
// }
//return szDefault;
}
return szDefault;
}
示例11: useEquivalentSize_
Foam::LambertWall<CloudType>::LambertWall
(
const dictionary& dict,
CloudType& cloud,
const scalar& surfaceTension,
const scalar& contactAngle,
const scalar& liqFrac,
const scalar& viscosity,
const scalar& minSep
)
:
PendularWallModel<CloudType>
(
dict,
cloud,
typeName,
surfaceTension,
contactAngle,
liqFrac,
viscosity,
minSep
),
useEquivalentSize_(Switch(this->coeffDict().lookup("useEquivalentSize")))
{
if (useEquivalentSize_)
{
volumeFactor_ = readScalar(this->coeffDict().lookup("volumeFactor"));
}
}
示例12: ClonePolicy
virtual ResultExpr ClonePolicy() const {
// Allow use for simple thread creation (pthread_create) only.
// WARNING: s390 and cris pass the flags in the second arg -- see
// CLONE_BACKWARDS2 in arch/Kconfig in the kernel source -- but we
// don't support seccomp-bpf on those archs yet.
Arg<int> flags(0);
// The glibc source hasn't changed the thread creation clone flags
// since 2004, so this *should* be safe to hard-code. Bionic's
// value has changed a few times, and has converged on the same one
// as glibc; allow any of them.
static const int flags_common = CLONE_VM | CLONE_FS | CLONE_FILES |
CLONE_SIGHAND | CLONE_THREAD | CLONE_SYSVSEM;
static const int flags_modern = flags_common | CLONE_SETTLS |
CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID;
// Can't use CASES here because its decltype magic infers const
// int instead of regular int and bizarre voluminous errors issue
// forth from the depths of the standard library implementation.
return Switch(flags)
#ifdef ANDROID
.Case(flags_common | CLONE_DETACHED, Allow()) // <= JB 4.2
.Case(flags_common, Allow()) // JB 4.3 or KK 4.4
#endif
.Case(flags_modern, Allow()) // Android L or glibc
.Default(InvalidSyscall());
}
示例13: Switch
// updated current script
bool Scripts::Update(Controller& ctrl, float elapsedTime)
{
// if script is done, switch script
if (! _scripts[_current]->Update(ctrl, elapsedTime))
return Switch();
return true;
}
示例14: switch
eOSState cMenuSearchResultsForBlacklist::ProcessKey(eKeys Key)
{
eOSState state = cMenuSearchResults::ProcessKey(Key);
if (state == osUnknown) {
switch (Key) {
case k1...k9:
state = HasSubMenu()?osContinue:Commands(Key);
break;
case kRecord:
case kRed:
state = OnRed();
break;
case kBlue:
if (HasSubMenu())
state = Switch();
else
state = osContinue;
break;
default:
break;
}
}
return state;
}
示例15: dictionary
initialPointsMethod::initialPointsMethod
(
const word& type,
const dictionary& initialPointsDict,
const Time& runTime,
Random& rndGen,
const conformationSurfaces& geometryToConformTo,
const cellShapeControl& cellShapeControls,
const autoPtr<backgroundMeshDecomposition>& decomposition
)
:
dictionary(initialPointsDict),
runTime_(runTime),
rndGen_(rndGen),
geometryToConformTo_(geometryToConformTo),
cellShapeControls_(cellShapeControls),
decomposition_(decomposition),
detailsDict_(subDict(type + "Coeffs")),
minimumSurfaceDistanceCoeffSqr_
(
sqr
(
readScalar
(
initialPointsDict.lookup("minimumSurfaceDistanceCoeff")
)
)
),
fixInitialPoints_(Switch(initialPointsDict.lookup("fixInitialPoints")))
{}