本文整理汇总了C++中Params类的典型用法代码示例。如果您正苦于以下问题:C++ Params类的具体用法?C++ Params怎么用?C++ Params使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Params类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setAllPWM
Blob CCanPWMActor::setAllPWM(SDeviceDescription device, Blob params) {
Params values = params[BLOB_ACTION_PARAMETER].get<Params>();
Blob b;
string response;
CCanBuffer buffer;
if (values.size() == 0) {
response = "PWMActor->setAllPWM->Incorrect params";
log->error(response);
b[BLOB_TXT_RESPONSE_RESULT].put<string>(response);
return b;
}
buffer.insertCommand(CMD_SET_PWM_ALL);
buffer.insertId((unsigned char) getDeviceCategory());
buffer << (unsigned char) getAddress(device);
for (unsigned char val : values) {
buffer << (unsigned char) (val);
}
buffer.buildBuffer();
response = (getProtocol()->send(buffer)) ? "OK" : "PWMActor->setAllPWM->Sending CAN frame failed";
b[BLOB_TXT_RESPONSE_RESULT].put<string>(response);
return b;
}
示例2: onLoadParams
void SetInkTypeCommand::onLoadParams(const Params& params)
{
std::string typeStr = params.get("type");
if (typeStr == "simple")
m_type = tools::InkType::SIMPLE;
else if (typeStr == "alpha-compositing")
m_type = tools::InkType::ALPHA_COMPOSITING;
else if (typeStr == "copy-color")
m_type = tools::InkType::COPY_COLOR;
else if (typeStr == "lock-alpha")
m_type = tools::InkType::LOCK_ALPHA;
else if (typeStr == "shading")
m_type = tools::InkType::SHADING;
else
m_type = tools::InkType::DEFAULT;
}
示例3: drawConfidenceEllipse
void drawConfidenceEllipse(const double &cx, const double &cy,
const double &sxx, const double &sxy, const double &syy,
const double &K, Params params)
{
Vec2d vc = {cx, cy};
Vec4d vcov = { sxx, sxy, sxy, syy };
Params msg;
msg["action"] = "draw";
msg["figure"] = params.pop("figure",current_fig);
msg["shape"] = (params, "type", "ellipse",
"center", vc,
"covariance", vcov,
"sigma", K);
fputs(Value(msg).toJSONString().append("\n\n").c_str(), channel);
fflush(channel);
}
示例4: Handle
/** Handle /MODULES
*/
CmdResult CommandModules::Handle(User* user, const Params& parameters)
{
// Don't ask remote servers about their modules unless the local user asking is an oper
// 2.0 asks anyway, so let's handle that the same way
bool for_us = (parameters.empty() || irc::equals(parameters[0], ServerInstance->Config->ServerName));
if ((!for_us) || (!IS_LOCAL(user)))
{
if (!user->IsOper())
{
user->WriteNotice("*** You cannot check what modules other servers have loaded.");
return CMD_FAILURE;
}
// From an oper and not for us, forward
if (!for_us)
return CMD_SUCCESS;
}
const ModuleManager::ModuleMap& mods = ServerInstance->Modules.GetModules();
for (ModuleManager::ModuleMap::const_iterator i = mods.begin(); i != mods.end(); ++i)
{
Module* m = i->second;
Version V = m->GetVersion();
if (IS_LOCAL(user) && user->HasPrivPermission("servers/auspex"))
{
std::string flags("VCO");
size_t pos = 0;
for (int mult = 2; mult <= VF_OPTCOMMON; mult *= 2, ++pos)
if (!(V.Flags & mult))
flags[pos] = '-';
std::string srcrev = m->ModuleDLLManager->GetVersion();
user->WriteRemoteNumeric(RPL_MODLIST, m->ModuleSourceFile, srcrev.empty() ? "*" : srcrev, flags, V.description);
}
else
{
user->WriteRemoteNumeric(RPL_MODLIST, m->ModuleSourceFile, '*', '*', V.description);
}
}
user->WriteRemoteNumeric(RPL_ENDOFMODLIST, "End of MODULES list");
return CMD_SUCCESS;
}
示例5: drawPie
void drawPie(const double &cx, const double &cy, const double &r_min, const double &r_max,
const double &theta_min, const double &theta_max, Params params)
{
// Angle need to be in degree
Params msg;
Vec2d cxy = { cx, cy };
Vec2d rMinMax = { r_min, r_max };
Vec2d thetaMinMax = { theta_min, theta_max };
msg["action"] = "draw";
msg["figure"] = params.pop("figure",current_fig);
msg["shape"] = (params, "type", "pie",
"center", cxy,
"rho", rMinMax,
"theta", thetaMinMax);
fputs(Value(msg).toJSONString().append("\n\n").c_str(), channel);
fflush(channel);
}
示例6: sendJson
void JsonApiHandlerHttp::sendJson(const Json &json)
{
string data = json.dump();
Params headers;
headers.Add("Connection", "Close");
headers.Add("Cache-Control", "no-cache, must-revalidate");
headers.Add("Expires", "Mon, 26 Jul 1997 05:00:00 GMT");
headers.Add("Content-Type", "application/json");
headers.Add("Content-Length", Utils::to_string(data.size()));
string res = httpClient->buildHttpResponse(HTTP_200, headers, data);
sendData.emit(res);
}
示例7: drawSector
void drawSector(const double &cx, const double &cy, const double &a, const double &b,
const double &startAngle, const double &endAngle, Params params)
{
// Angle need to be in degree
Params msg;
Vec2d cxy={ cx, cy };
Vec2d cab = { a, b };
Vec2d startEnd = { startAngle, endAngle };
msg["action"] = "draw";
msg["figure"] = params.pop("figure",current_fig);
msg["shape"] = (params, "type", "ellipse",
"center", cxy,
"axis", cab,
"orientation", 0,
"angles", startEnd);
fputs(Value(msg).toJSONString().append("\n\n").c_str(), channel);
fflush(channel);
}
示例8: pbrtShape
void pbrtShape(std::string const& name, Params const& params) {
if (name == "plymesh") {
auto filename = params.getString("string filename");
auto cached = PBRTState::cachedShapes.find(pbrtPath + filename);
std::shared_ptr<Shape const> shape;
if (cached != PBRTState::cachedShapes.end()) {
shape = cached->second;
} else {
shape = readply(pbrtPath + filename);
PBRTState::cachedShapes[pbrtPath + filename] = shape;
}
PBRTState::objectStack.top().second.instances.push_back(
Instance{shape, PBRTState::materialStack.top(),
PBRTState::transforms.top().start});
} else {
std::cout << "Unrecognized Shape: " << name << std::endl;
}
}
示例9: GetParameters
bool CGUIIncludes::GetParameters(const TiXmlElement *include, const char *valueAttribute, Params& params)
{
bool foundAny = false;
// collect parameters from include tag
// <include name="MyControl">
// <param name="posx" value="225" /> <!-- comments and other tags are ignored here -->
// <param name="posy">150</param>
// ...
// </include>
if (include)
{
const TiXmlElement *param = include->FirstChildElement("param");
foundAny = param != NULL; // doesn't matter if param isn't entirely valid
while (param)
{
std::string paramName = XMLUtils::GetAttribute(param, "name");
if (!paramName.empty())
{
std::string paramValue;
// <param name="posx" value="120" />
const char *value = param->Attribute(valueAttribute); // try attribute first
if (value)
paramValue = value;
else
{
// <param name="posx">120</param>
const TiXmlNode *child = param->FirstChild();
if (child && child->Type() == TiXmlNode::TINYXML_TEXT)
paramValue = child->ValueStr(); // and then tag value
}
params.insert({ paramName, paramValue }); // no overwrites
}
param = param->NextSiblingElement("param");
}
}
return foundAny;
}
示例10: drawArrow
void drawArrow(const double &xA, const double &yA, const double &xB, const double &yB, const double &tip_length, Params params)
{
// Reshape A and B into a vector of points
std::vector<Value> points;
Vec2d va = { xA, yA };
Vec2d vb = { xB, yB };
points.push_back(va);
points.push_back(vb);
// Send message
Params msg;
msg["action"] = "draw";
msg["figure"] = params.pop("figure",current_fig);
msg["shape"] = (params, "type", "arrow",
"points", points,
"tip_length", tip_length);
fputs(Value(msg).toJSONString().append("\n\n").c_str(), channel);
fflush(channel);
}
示例11: Handle
CmdResult Handle(User* user, const Params& parameters) override
{
User* dest = ServerInstance->FindNick(parameters[1]);
Channel* channel = ServerInstance->FindChan(parameters[0]);
if ((dest) && (dest->registered == REG_ALL) && (channel))
{
const std::string& reason = (parameters.size() > 2) ? parameters[2] : dest->nick;
if (dest->server->IsULine())
{
user->WriteNumeric(ERR_NOPRIVILEGES, "Cannot use an SA command on a U-lined client");
return CMD_FAILURE;
}
if (!channel->HasUser(dest))
{
user->WriteNotice("*** " + dest->nick + " is not on " + channel->name);
return CMD_FAILURE;
}
/* For local clients, directly kick them. For remote clients,
* just return CMD_SUCCESS knowing the protocol module will route the SAKICK to the user's
* local server and that will kick them instead.
*/
if (IS_LOCAL(dest))
{
// Target is on this server, kick them and send the snotice
channel->KickUser(ServerInstance->FakeClient, dest, reason);
ServerInstance->SNO.WriteGlobalSno('a', user->nick + " SAKICKed " + dest->nick + " on " + channel->name);
}
return CMD_SUCCESS;
}
else
{
user->WriteNotice("*** Invalid nickname or channel");
}
return CMD_FAILURE;
}
示例12: llmax
LLNetMap::LLNetMap (const Params & p)
: LLUICtrl (p),
mBackgroundColor (p.bg_color()),
mScale( MAP_SCALE_MID ),
mPixelsPerMeter( MAP_SCALE_MID / REGION_WIDTH_METERS ),
mObjectMapTPM(0.f),
mObjectMapPixels(0.f),
mTargetPanX(0.f),
mTargetPanY(0.f),
mCurPanX(0.f),
mCurPanY(0.f),
mUpdateNow(FALSE),
mObjectImageCenterGlobal( gAgent.getCameraPositionGlobal() ),
mObjectRawImagep(),
mObjectImagep(),
mClosestAgentToCursor(),
mClosestAgentAtLastRightClick(),
mToolTipMsg()
{
mDotRadius = llmax(DOT_SCALE * mPixelsPerMeter, MIN_DOT_RADIUS);
}
示例13: _AddParam
void CFunctionConfig::_AddParam(ParserEnv* e, const Params& params)
{
for (euint i = 0; i < params.size(); i++)
{
const xhn::pair<xhn::string, ValueType>& p = params[i];
SymbolValue type;
switch (p.second)
{
case IntValue:
type = IntTypeSym();
break;
case FloatValue:
type = FloatTypeSym();
break;
default:
return;
}
SymbolValue* sv = ParserEnv_new_unknown_symbol(e, p.first.c_str());
AddParam(e, *sv, type);
}
}
示例14: saveFile
void DefaultCliDelegate::saveFile(Context* ctx, const CliOpenFile& cof)
{
Command* saveAsCommand = Commands::instance()->byId(CommandId::SaveFileCopyAs());
Params params;
params.set("filename", cof.filename.c_str());
params.set("filename-format", cof.filenameFormat.c_str());
if (cof.hasFrameTag()) {
params.set("frame-tag", cof.frameTag.c_str());
}
if (cof.hasFrameRange()) {
params.set("from-frame", base::convert_to<std::string>(cof.fromFrame).c_str());
params.set("to-frame", base::convert_to<std::string>(cof.toFrame).c_str());
}
if (cof.hasSlice()) {
params.set("slice", cof.slice.c_str());
}
if (cof.ignoreEmpty)
params.set("ignoreEmpty", "true");
ctx->executeCommand(saveAsCommand, params);
}
示例15: onLoadParams
void SaveFileBaseCommand::onLoadParams(const Params& params)
{
m_filename = params.get("filename");
m_filenameFormat = params.get("filename-format");
m_frameTag = params.get("frame-tag");
m_aniDir = params.get("ani-dir");
m_slice = params.get("slice");
if (params.has_param("from-frame") ||
params.has_param("to-frame")) {
doc::frame_t fromFrame = params.get_as<doc::frame_t>("from-frame");
doc::frame_t toFrame = params.get_as<doc::frame_t>("to-frame");
m_selFrames.insert(fromFrame, toFrame);
m_adjustFramesByFrameTag = true;
}
else {
m_selFrames.clear();
m_adjustFramesByFrameTag = false;
}
}