25static std::map<AppID, Instance *>
26buildIndex(
const std::vector<std::unique_ptr<Instance>> &insts) {
27 std::map<AppID, Instance *> index;
28 for (
auto &item : insts)
29 index[item->getID()] = item.get();
34static std::map<AppID, BundlePort &>
35buildIndex(
const std::vector<std::unique_ptr<BundlePort>> &ports) {
36 std::map<AppID, BundlePort &> index;
37 for (
auto &item : ports)
38 index.emplace(item->getID(), *item);
43 std::vector<std::unique_ptr<Instance>> children,
44 std::vector<services::Service *> services,
45 std::vector<std::unique_ptr<BundlePort>> &ports)
46 : info(info), children(std::move(children)),
47 childIndex(
buildIndex(this->children)), services(services),
48 ports(std::move(ports)), portIndex(
buildIndex(this->ports)) {}
52 for (
auto &port :
ports)
53 result |= port->poll();
55 result |= child->poll();
62 for (
auto &
id : path) {
63 lastLookup.push_back(
id);
64 auto childIter = hwmodule->
childIndex.find(
id);
67 hwmodule = childIter->second;
74 AppID portID = path.back();
78 lastLookup.push_back(portID);
82 const auto &portIter =
ports.find(portID);
83 if (portIter ==
ports.end())
85 return &portIter->second;
Services provide connections to 'bundles' – collections of named, unidirectional communication channe...
Represents either the top level or an instance of a hardware module.
BundlePort * resolvePort(const AppIDPath &path, AppIDPath &lastLookup) const
Attempt to resolve a path to a port.
bool poll()
Master poll method.
const std::vector< std::unique_ptr< BundlePort > > ports
const std::vector< std::unique_ptr< Instance > > children
HWModule(std::optional< ModuleInfo > info, std::vector< std::unique_ptr< Instance > > children, std::vector< services::Service * > services, std::vector< std::unique_ptr< BundlePort > > &ports)
const std::map< AppID, Instance * > childIndex
const HWModule * resolveInst(const AppIDPath &path, AppIDPath &lastLookup) const
Attempt to resolve a path to a module instance.
const std::map< AppID, BundlePort & > & getPorts() const
Access the module's ports by ID.
static std::map< AppID, Instance * > buildIndex(const std::vector< std::unique_ptr< Instance > > &insts)
Build an index of children by AppID.