Loading cmds/lshal/ListCommand.cpp +20 −34 Original line number Diff line number Diff line Loading @@ -287,33 +287,32 @@ bool ListCommand::shouldReportHalType(const HalType &type) const { return (std::find(mListTypes.begin(), mListTypes.end(), type) != mListTypes.end()); } void ListCommand::forEachTable(const std::function<void(Table &)> &f) { for (const auto& type : mListTypes) { Table* ListCommand::tableForType(HalType type) { switch (type) { case HalType::BINDERIZED_SERVICES: f(mServicesTable); break; return &mServicesTable; case HalType::PASSTHROUGH_CLIENTS: f(mPassthroughRefTable); break; return &mPassthroughRefTable; case HalType::PASSTHROUGH_LIBRARIES: f(mImplementationsTable); break; return &mImplementationsTable; default: LOG(FATAL) << __func__ << "Unknown HAL type."; LOG(FATAL) << "Unknown HAL type " << static_cast<int64_t>(type); return nullptr; } } const Table* ListCommand::tableForType(HalType type) const { return const_cast<ListCommand*>(this)->tableForType(type); } void ListCommand::forEachTable(const std::function<void(const Table &)> &f) const { void ListCommand::forEachTable(const std::function<void(Table &)> &f) { for (const auto& type : mListTypes) { switch (type) { case HalType::BINDERIZED_SERVICES: f(mServicesTable); break; case HalType::PASSTHROUGH_CLIENTS: f(mPassthroughRefTable); break; case HalType::PASSTHROUGH_LIBRARIES: f(mImplementationsTable); break; default: LOG(FATAL) << __func__ << "Unknown HAL type."; f(*tableForType(type)); } } void ListCommand::forEachTable(const std::function<void(const Table &)> &f) const { for (const auto& type : mListTypes) { f(*tableForType(type)); } } void ListCommand::postprocess() { Loading Loading @@ -553,20 +552,7 @@ Status ListCommand::dump() { } void ListCommand::putEntry(HalType type, TableEntry &&entry) { Table *table = nullptr; switch (type) { case HalType::BINDERIZED_SERVICES : table = &mServicesTable; break; case HalType::PASSTHROUGH_CLIENTS : table = &mPassthroughRefTable; break; case HalType::PASSTHROUGH_LIBRARIES : table = &mImplementationsTable; break; default: err() << "Error: Unknown type of entry " << static_cast<int64_t>(type) << std::endl; } if (table) { table->add(std::forward<TableEntry>(entry)); } tableForType(type)->add(std::forward<TableEntry>(entry)); } Status ListCommand::fetchAllLibraries(const sp<IServiceManager> &manager) { Loading cmds/lshal/ListCommand.h +2 −0 Original line number Diff line number Diff line Loading @@ -134,6 +134,8 @@ protected: void forEachTable(const std::function<void(Table &)> &f); void forEachTable(const std::function<void(const Table &)> &f) const; Table* tableForType(HalType type); const Table* tableForType(HalType type) const; NullableOStream<std::ostream> err() const; NullableOStream<std::ostream> out() const; Loading Loading
cmds/lshal/ListCommand.cpp +20 −34 Original line number Diff line number Diff line Loading @@ -287,33 +287,32 @@ bool ListCommand::shouldReportHalType(const HalType &type) const { return (std::find(mListTypes.begin(), mListTypes.end(), type) != mListTypes.end()); } void ListCommand::forEachTable(const std::function<void(Table &)> &f) { for (const auto& type : mListTypes) { Table* ListCommand::tableForType(HalType type) { switch (type) { case HalType::BINDERIZED_SERVICES: f(mServicesTable); break; return &mServicesTable; case HalType::PASSTHROUGH_CLIENTS: f(mPassthroughRefTable); break; return &mPassthroughRefTable; case HalType::PASSTHROUGH_LIBRARIES: f(mImplementationsTable); break; return &mImplementationsTable; default: LOG(FATAL) << __func__ << "Unknown HAL type."; LOG(FATAL) << "Unknown HAL type " << static_cast<int64_t>(type); return nullptr; } } const Table* ListCommand::tableForType(HalType type) const { return const_cast<ListCommand*>(this)->tableForType(type); } void ListCommand::forEachTable(const std::function<void(const Table &)> &f) const { void ListCommand::forEachTable(const std::function<void(Table &)> &f) { for (const auto& type : mListTypes) { switch (type) { case HalType::BINDERIZED_SERVICES: f(mServicesTable); break; case HalType::PASSTHROUGH_CLIENTS: f(mPassthroughRefTable); break; case HalType::PASSTHROUGH_LIBRARIES: f(mImplementationsTable); break; default: LOG(FATAL) << __func__ << "Unknown HAL type."; f(*tableForType(type)); } } void ListCommand::forEachTable(const std::function<void(const Table &)> &f) const { for (const auto& type : mListTypes) { f(*tableForType(type)); } } void ListCommand::postprocess() { Loading Loading @@ -553,20 +552,7 @@ Status ListCommand::dump() { } void ListCommand::putEntry(HalType type, TableEntry &&entry) { Table *table = nullptr; switch (type) { case HalType::BINDERIZED_SERVICES : table = &mServicesTable; break; case HalType::PASSTHROUGH_CLIENTS : table = &mPassthroughRefTable; break; case HalType::PASSTHROUGH_LIBRARIES : table = &mImplementationsTable; break; default: err() << "Error: Unknown type of entry " << static_cast<int64_t>(type) << std::endl; } if (table) { table->add(std::forward<TableEntry>(entry)); } tableForType(type)->add(std::forward<TableEntry>(entry)); } Status ListCommand::fetchAllLibraries(const sp<IServiceManager> &manager) { Loading
cmds/lshal/ListCommand.h +2 −0 Original line number Diff line number Diff line Loading @@ -134,6 +134,8 @@ protected: void forEachTable(const std::function<void(Table &)> &f); void forEachTable(const std::function<void(const Table &)> &f) const; Table* tableForType(HalType type); const Table* tableForType(HalType type) const; NullableOStream<std::ostream> err() const; NullableOStream<std::ostream> out() const; Loading