See More

// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #include "CharacterObject.h" #include "QueryData.h" namespace graphql::learn { Query::Query(std::map&& heroes, std::map<:idtype std::shared_ptr>>&& humans, std::map<:idtype std::shared_ptr>>&& droids) noexcept : heroes_ { std::move(heroes) } , humans_ { std::move(humans) } , droids_ { std::move(droids) } { } std::shared_ptr<:character> Query::getHero(std::optional episodeArg) const noexcept { std::shared_ptr<:character> result; const auto episode = episodeArg ? *episodeArg : Episode::NEW_HOPE; if (const auto itr = heroes_.find(episode); itr != heroes_.end()) { result = make_hero(itr->second); } return result; } std::shared_ptr<:human> Query::getHuman(const response::IdType& idArg) const noexcept { std::shared_ptr<:human> result; if (const auto itr = humans_.find(idArg); itr != humans_.end()) { result = std::make_shared<:human>(itr->second); } return result; } std::shared_ptr<:droid> Query::getDroid(const response::IdType& idArg) const noexcept { std::shared_ptr<:droid> result; if (const auto itr = droids_.find(idArg); itr != droids_.end()) { result = std::make_shared<:droid>(itr->second); } return result; } } // namespace graphql::learn