本文整理汇总了C++中CommandArgs类的典型用法代码示例。如果您正苦于以下问题:C++ CommandArgs类的具体用法?C++ CommandArgs怎么用?C++ CommandArgs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CommandArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: container_main
int container_main(void* arg)
{
// no need to delete it because we execv finally.
CommandArgs* args = reinterpret_cast<CommandArgs*>(arg);
printf("Container [%d] - inside the container!\n", getpid());
printf("Container: eUID = %ld; eGID = %ld, UID=%ld, GID=%ld\n",
(long) geteuid(), (long) getegid(), (long) getuid(), (long) getgid());
char ch;
close(pipefd[1]);
int ret = read(pipefd[0], &ch, 1);
if (ret < 0) {
printf("Error: read failed: %d, %s\n", errno, strerror(errno));
return 1;
}
close(pipefd[0]);
printf("Container: eUID = %ld; eGID = %ld, UID=%ld, GID=%ld\n",
(long) geteuid(), (long) getegid(), (long) getuid(), (long) getgid());
mount("proc", "/proc", "proc", 0, NULL);
char** argv = args->GetExecArgs();
execv(argv[0], argv);
printf("Something's wrong!\n");
return 1;
}
示例2: OnCommandReceived
void RGBLed::OnCommandReceived(CommandArgs *args)
{
if(args->Get_Type() == Get && (args->Get_Command() == All | args->Get_Command() == RGBLedCommand))
{
CommandArgs sendArgs;
sendArgs.Set_Type(Set);
sendArgs.Set_Command(RGBLedCommand);
byte values[3];
values[0] = Get_Red();
values[1] = Get_Green();
values[2] = Get_Blue();
sendArgs.Set_Length(3);
sendArgs.Set_Value(values);
SendCommand(&sendArgs);
}
else if(args->Get_Type() == Set && args->Get_Command() == RGBLedCommand)
{
byte* values = args->Get_Value();
if(values != null)
{
if(args->Get_Length() == 3)
{
Set_Red(values[0]);
Set_Green(values[1]);
Set_Blue(values[2]);
}
}
}
}
示例3: error
void ProxyScheduler::error(SchedulerDriver* driver, const std::string& message)
{
CommandArgs args;
args.push_back(CommandArg(message));
dispatcher_->send( MesosCommand("error", args) );
}
示例4: main
int main(int argc, char** argv)
{
QApplication qapp(argc, argv);
#ifdef G2O_HAVE_GLUT
glutInit(&argc, argv);
#endif
string dummy;
string inputFilename;
CommandArgs arg;
arg.param("solverlib", dummy, "", "specify a solver library which will be loaded");
arg.param("typeslib", dummy, "", "specify a types library which will be loaded");
arg.paramLeftOver("graph-input", inputFilename, "", "graph file which will be processed", true);
arg.parseArgs(argc, argv);
// loading the standard solver / types
DlWrapper dlTypesWrapper;
loadStandardTypes(dlTypesWrapper, argc, argv);
// register all the solvers
DlWrapper dlSolverWrapper;
loadStandardSolver(dlSolverWrapper, argc, argv);
MainWindow mw;
mw.updateDisplayedSolvers();
mw.show();
// redirect the output that normally goes to cerr to the textedit in the viewer
StreamRedirect redirect(cerr, mw.plainTextEdit);
// setting up the optimizer
SparseOptimizer* optimizer = new SparseOptimizer();
mw.viewer->graph = optimizer;
// set up the GUI action
GuiHyperGraphAction guiHyperGraphAction;
guiHyperGraphAction.viewer = mw.viewer;
optimizer->addPostIterationAction(&guiHyperGraphAction);
if (inputFilename.size() > 0) {
mw.loadFromFile(QString::fromStdString(inputFilename));
}
while (mw.isVisible()) {
guiHyperGraphAction.dumpScreenshots = mw.actionDump_Images->isChecked();
qapp.processEvents();
SleepThread::msleep(10);
}
delete optimizer;
// destroy all the singletons
//Factory::destroy();
//OptimizationAlgorithmFactory::destroy();
//HyperGraphActionLibrary::destroy();
return 0;
}
示例5: messageToCommandArgs
static CommandArgs messageToCommandArgs(const ofxOscMessage& message) {
CommandArgs args;
for (int i = 0; i < message.getNumArgs(); ++i) {
auto arg = messageArgToCommandArg(message, i);
args.add(arg);
}
return args;
}
示例6: frameworkMessage
void ProxyScheduler::frameworkMessage(SchedulerDriver* driver,
const ExecutorID& executorId,
const SlaveID& slaveId,
const std::string& data)
{
CommandArgs args;
PUSH_MSG(args, executorId, "ExecutorID");
PUSH_MSG(args, slaveId, "SlaveID");
args.push_back(CommandArg(data));
dispatcher_->send( MesosCommand("frameworkMessage", args) );
}
示例7: executorLost
void ProxyScheduler::executorLost(SchedulerDriver* driver,
const ExecutorID& executorId,
const SlaveID& slaveId,
int status)
{
CommandArgs args;
PUSH_MSG(args, executorId, "ExecutorID");
PUSH_MSG(args, slaveId, "SlaveID");
args.push_back(CommandArg(std::to_string(status)));
dispatcher_->send( MesosCommand("executorLost", args) );
}
示例8: resourceOffers
void ProxyScheduler::resourceOffers(SchedulerDriver* driver,
const std::vector<Offer>& offers)
{
CommandArgs args;
std::vector<std::string> strings;
for (std::vector<Offer>::const_iterator it = offers.begin(); it != offers.end(); ++it) {
strings.push_back(it->SerializeAsString());
}
args.push_back( CommandArg(strings, "Offer") );
dispatcher_->send( MesosCommand("resourceOffers", args) );
}
示例9: main
int main(int argc, char** argv) {
CommandArgs arg;
std::string outputFilename;
std::string inputFilename;
arg.param("o", outputFilename, "", "output file name");
arg.paramLeftOver("input-filename ", inputFilename, "", "graph file to read", true);
arg.parseArgs(argc, argv);
OptimizableGraph graph;
if (!graph.load(inputFilename.c_str())){
cerr << "Error: cannot load a file from \"" << inputFilename << "\", aborting." << endl;
return 0;
}
HyperGraph::EdgeSet removedEdges;
HyperGraph::VertexSet removedVertices;
for (HyperGraph::EdgeSet::iterator it = graph.edges().begin(); it!=graph.edges().end(); it++) {
HyperGraph::Edge* e = *it;
EdgeSE2PointXY* edgePointXY = dynamic_cast<EdgeSE2PointXY*>(e);
if (edgePointXY) {
VertexSE2* pose = dynamic_cast<VertexSE2*>(edgePointXY->vertex(0));
VertexPointXY* landmark = dynamic_cast<VertexPointXY*>(edgePointXY->vertex(1));
FeaturePointXYData * feature = new FeaturePointXYData();
feature->setPositionMeasurement(edgePointXY->measurement());
feature->setPositionInformation(edgePointXY->information());
pose->addUserData(feature);
removedEdges.insert(edgePointXY);
removedVertices.insert(landmark);
}
}
for (HyperGraph::EdgeSet::iterator it = removedEdges.begin(); it!=removedEdges.end(); it++){
OptimizableGraph::Edge* e = dynamic_cast<OptimizableGraph::Edge*>(*it);
graph.removeEdge(e);
}
for (HyperGraph::VertexSet::iterator it = removedVertices.begin(); it!=removedVertices.end(); it++){
OptimizableGraph::Vertex* v = dynamic_cast<OptimizableGraph::Vertex*>(*it);
graph.removeVertex(v);
}
if (outputFilename.length()){
graph.save(outputFilename.c_str());
}
}
示例10: Run
virtual bool Run(P4Task& task, const CommandArgs& args)
{
if (!task.IsConnected()) // Cannot login without being connected
{
Conn().Log().Info() << "Cannot login when not connected" << Endl;
return false;
}
ClearStatus();
m_LoggedIn = false;
m_Password = task.GetP4Password();
m_CheckingForLoggedIn = args.size() > 1;
const string cmd = string("login") + (m_CheckingForLoggedIn ? string(" " ) + args[1] : string());
if (!task.CommandRun(cmd, this) && !m_CheckingForLoggedIn)
{
string errorMessage = GetStatusMessage();
Conn().Log().Notice() << "ERROR: " << errorMessage << Endl;
}
if (m_CheckingForLoggedIn)
Conn().Log().Debug() << "Is logged in: " << (m_LoggedIn ? "yes" : "no") << Endl;
else
Conn().Log().Info() << "Login " << (m_LoggedIn ? "succeeded" : "failed") << Endl;
m_CheckingForLoggedIn = false;
return m_LoggedIn;
}
示例11: GetStatus
bool P4StatusCommand::Run(P4Task& task, const CommandArgs& args)
{
// Since the status command is use to check for online state we start out by
// forcing online state to true and check if it has been set to false in the
// end to determine if we should send online notifications.
bool wasOnline = P4Task::IsOnline();
P4Task::SetOnline(true);
ClearStatus();
bool recursive = args.size() > 1;
Pipe().Log().Info() << "StatusCommand::Run()" << unityplugin::Endl;
VersionedAssetList assetList;
Pipe() >> assetList;
RunAndSend(task, assetList, recursive);
Pipe() << GetStatus();
if (P4Task::IsOnline() && !wasOnline)
{
// If set to online already we cannot notify as online so we fake an offline state.
P4Task::SetOnline(false);
P4Task::NotifyOnline();
}
Pipe().EndResponse();
return true;
}
示例12: stringWriter_
const StringWriterPtr RandomService::commandRandom(const CommandArgs& nCommandArgs)
{
StringWriterPtr stringWriter_(new StringWriter());
nCommandArgs.runStringWriter(stringWriter_);
stringWriter_->startClass("result");
const string& strMin_ = nCommandArgs.getCommandArg(1);
const string& strMax_ = nCommandArgs.getCommandArg(2);
const __i32 minValue_ = __convert<string, __i32>(strMin_);
const __i32 maxValue_ = __convert<string, __i32>(strMax_);
stringWriter_->runString(strMin_, "strMin");
stringWriter_->runInt32(minValue_, "minValue");
stringWriter_->runString(strMax_, "strMax");
stringWriter_->runInt32(maxValue_, "maxValue");
stringWriter_->finishClass();
stringWriter_->runClose();
return stringWriter_;
}
示例13: main
int main(int argc, char** argv)
{
OptimizableGraph::initMultiThreading();
QApplication qapp(argc, argv);
CommandArgs arg;
#ifndef G2O_DISABLE_DYNAMIC_LOADING_OF_LIBRARIES
string dummy;
arg.param("solverlib", dummy, "", "specify a solver library which will be loaded");
arg.param("typeslib", dummy, "", "specify a types library which will be loaded");
// loading the standard solver / types
DlWrapper dlTypesWrapper;
loadStandardTypes(dlTypesWrapper, argc, argv);
// register all the solvers
DlWrapper dlSolverWrapper;
loadStandardSolver(dlSolverWrapper, argc, argv);
#endif
// run the viewer
return RunG2OViewer::run(argc, argv, arg);
}
示例14: main
int main(int argc, char** argv)
{
bool pcg;
int updateEachN;
bool vis;
bool verbose;
// command line parsing
CommandArgs arg;
arg.param("update", updateEachN, 10, "update the graph after inserting N nodes");
arg.param("pcg", pcg, false, "use PCG instead of Cholesky");
arg.param("v", verbose, false, "verbose output of the optimization process");
arg.param("g", vis, false, "gnuplot visualization");
arg.parseArgs(argc, argv);
SparseOptimizerOnline optimizer(pcg);
//SparseOptimizer optimizer;
optimizer.setVerbose(verbose);
optimizer.setForceStopFlag(&hasToStop);
optimizer.vizWithGnuplot = vis;
G2oSlamInterface slamInterface(&optimizer);
slamInterface.setUpdateGraphEachN(updateEachN);
SlamParser::ParserInterface parserInterface(&slamInterface);
while (parserInterface.parseCommand(cin))
{
// do something additional if needed
}
return 0;
}
示例15:
bool P4EditCommand::Run(P4Task &task)
{
CommandArgs myArgs;
// Append changelist if available
if(!m_changelist.empty())
{
myArgs.emplace_back("-c");
myArgs.emplace_back(m_changelist);
}
// Append custom arguments
std::copy(m_customArgs.begin(), m_customArgs.end(), std::back_inserter(myArgs));
// Append paths
for(auto &path : m_paths)
{
myArgs.emplace_back(path);
}
return task.runP4Command("edit", myArgs, this);
}