本文整理汇总了C++中ola::STLDeleteValues方法的典型用法代码示例。如果您正苦于以下问题:C++ ola::STLDeleteValues方法的具体用法?C++ ola::STLDeleteValues怎么用?C++ ola::STLDeleteValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ola
的用法示例。
在下文中一共展示了ola::STLDeleteValues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ApplyOffset
/**
* Build a vector of Slot from the global_slots map with the
* offset applied.
*
* The clears the global_slots map.
* @returns true if the offset was applied correctly, false otherwise.
*/
bool ApplyOffset(uint16_t offset, SlotList *all_slots) {
bool ok = true;
all_slots->reserve(global_slots.size());
SlotActionMap::const_iterator iter = global_slots.begin();
for (; iter != global_slots.end(); ++iter) {
Slot *slots = iter->second;
if (slots->SlotOffset() + offset >= ola::DMX_UNIVERSE_SIZE) {
OLA_FATAL << "Slot " << slots->SlotOffset() << " + offset " <<
offset << " is greater than " << ola::DMX_UNIVERSE_SIZE - 1;
ok = false;
break;
}
slots->SetSlotOffset(slots->SlotOffset() + offset);
all_slots->push_back(slots);
}
if (!ok) {
all_slots->clear();
STLDeleteValues(&global_slots);
}
global_slots.clear();
return ok;
}
示例2: main
/*
* Main
*/
int main(int argc, char *argv[]) {
ola::AppInit(&argc,
argv,
"[options] <config_file>",
"Run programs based on the values in a DMX stream.");
if (FLAGS_offset >= ola::DMX_UNIVERSE_SIZE) {
std::cerr << "Invalid slot offset: " << FLAGS_offset << std::endl;
exit(ola::EXIT_USAGE);
}
if (argc != 2)
ola::DisplayUsageAndExit();
// setup the default context
global_context = new Context();
OLA_INFO << "Loading config from " << argv[1];
// open the config file
if (freopen(argv[1], "r", stdin) == NULL) {
OLA_FATAL << "File " << argv[1] << " cannot be opened.\n";
exit(ola::EXIT_DATAERR);
}
yyparse();
if (FLAGS_validate) {
std::cout << "File " << argv[1] << " is valid." << std::endl;
// TODO(Peter): Print some stats here, validate the offset if supplied
STLDeleteValues(&global_slots);
exit(ola::EXIT_OK);
}
// if we got to this stage the config is ok and we want to run it, setup the
// client
ola::OlaCallbackClientWrapper wrapper;
if (!wrapper.Setup())
exit(ola::EXIT_UNAVAILABLE);
ss = wrapper.GetSelectServer();
if (!InstallSignals())
exit(ola::EXIT_OSERR);
// create the vector of Slot
SlotList slots;
if (ApplyOffset(FLAGS_offset, &slots)) {
// setup the trigger
DMXTrigger trigger(global_context, slots);
// register for DMX
ola::OlaCallbackClient *client = wrapper.GetClient();
client->SetDmxCallback(
ola::NewCallback(&NewDmx,
static_cast<unsigned int>(FLAGS_universe),
&trigger));
client->RegisterUniverse(FLAGS_universe, ola::REGISTER, NULL);
// start the client
wrapper.GetSelectServer()->Run();
}
// cleanup
STLDeleteElements(&slots);
}