pmt: improve PureTuple class and improve function manager.
This commit is contained in:
@@ -66,61 +66,4 @@ void processCommandLine(std::vector<std::string> &vec1,
|
||||
if (vec1.empty() && !s1.empty()) vec1.push_back(s1);
|
||||
if (vec2.empty() && !s2.empty()) vec2.push_back(s2);
|
||||
}
|
||||
|
||||
void basic_function_manager::registerFunction(
|
||||
std::unique_ptr<basic_function> _func, CLI::App &_app) {
|
||||
LOGN(PMTF, INFO) << "registering function: " << _func->name() << std::endl;
|
||||
for (const auto &f : _functions) {
|
||||
if (std::string(_func->name()) == std::string(f->name())) {
|
||||
LOGN(PMTF, INFO) << "Function is already registered: " << _func->name()
|
||||
<< ". Skipping." << std::endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!_func->init(_app))
|
||||
throw Error("Cannot init function: %s", _func->name());
|
||||
_functions.push_back(std::move(_func));
|
||||
LOGN(PMTF, INFO) << _functions.back()->name() << " successfully registered."
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
bool basic_function_manager::isUsed(const std::string &name) const {
|
||||
if (_functions.empty()) return false;
|
||||
for (const auto &func : _functions) {
|
||||
if (func->name() == name) return func->isUsed();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool basic_function_manager::hasFlagOnUsedFunction(const int flag) const {
|
||||
for (const auto &func : _functions) {
|
||||
if (func->isUsed()) {
|
||||
std::for_each(func->flags.begin(), func->flags.end(), [&](const int x) {
|
||||
LOGN(PMTF, INFO) << "Used flag " << x << " on " << func->name()
|
||||
<< std::endl;
|
||||
});
|
||||
return std::find(func->flags.begin(), func->flags.end(), flag) !=
|
||||
func->flags.end();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool basic_function_manager::handleAll() const {
|
||||
LOGN(PMTF, INFO) << "running caught function commands in command-line."
|
||||
<< std::endl;
|
||||
for (const auto &func : _functions) {
|
||||
if (func->isUsed()) {
|
||||
LOGN(PMTF, INFO) << func->name()
|
||||
<< " is calling because used in command-line."
|
||||
<< std::endl;
|
||||
return func->run();
|
||||
}
|
||||
}
|
||||
|
||||
LOGN(PMTF, INFO) << "not found any used function from command-line."
|
||||
<< std::endl;
|
||||
println("Target progress is not specified. Specify a progress.");
|
||||
return false;
|
||||
}
|
||||
} // namespace PartitionManager
|
||||
|
||||
@@ -18,6 +18,5 @@
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
// Call integrated main function in library
|
||||
Helper::LoggingProperties::setProgramName(PMTE);
|
||||
return PartitionManager::Main(argc, argv);
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ basic_variables::basic_variables()
|
||||
}
|
||||
|
||||
__attribute__((constructor)) void init() {
|
||||
Helper::LoggingProperties::setProgramName(PMTE);
|
||||
Helper::LoggingProperties::setLogFile("/sdcard/Documents/last_pmt_logs.log");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user