32using AccountMap = std::map<std::string, std::shared_ptr<T>, std::less<>>;
49 template<
class T = Account>
52 std::lock_guard
lk(mutex_);
55 return map
and map->find(
id) != map->cend();
58 template<
class T = Account>
61 std::lock_guard
lk(mutex_);
70 template<
class T = Account>
73 std::lock_guard lock(mutex_);
76 return map
and map->empty();
79 template<
class T = Account>
82 std::lock_guard lock(mutex_);
91 template<
class T = Account>
94 std::lock_guard lock(mutex_);
100 const auto&
it = map->find(
id);
101 if (
it == map->cend())
104 return std::static_pointer_cast<T>(
it->second);
107 template<
class T = Account>
110 std::lock_guard lock(mutex_);
111 std::vector<std::shared_ptr<T>> v;
114 v.reserve(map->size());
115 for (
const auto&
it : *map)
116 v.emplace_back(std::static_pointer_cast<T>(
it.second));
122 mutable std::recursive_mutex mutex_ {};
123 std::map<std::string, std::function<std::shared_ptr<Account>(
const std::string&)>, std::less<>> generators_ {};
124 std::map<std::string, AccountMap<Account>, std::less<>> accountMaps_ {};
129 const auto&
itermap = accountMaps_.find(T::ACCOUNT_TYPE);
130 if (
itermap != accountMaps_.cend())
std::shared_ptr< T > getAccount(std::string_view id) const
std::vector< std::shared_ptr< T > > getAllAccounts() const
bool isSupportedType(std::string_view accountType) const
static const std::string_view DEFAULT_ACCOUNT_TYPE
std::size_t accountCount() const
bool hasAccount(std::string_view id) const
void removeAccount(Account &account)
std::shared_ptr< Account > createAccount(std::string_view accountType, const std::string &id)
void emitSignal(Args... args)
std::map< std::string, std::shared_ptr< T >, std::less<> > AccountMap