34using AccountMap = std::map<std::string, std::shared_ptr<T>, std::less<>>;
51 template<
class T = Account>
54 std::lock_guard
lk(mutex_);
57 return map
and map->find(
id) != map->cend();
60 template<
class T = Account>
63 std::lock_guard
lk(mutex_);
72 template<
class T = Account>
75 std::lock_guard lock(mutex_);
78 return map
and map->empty();
81 template<
class T = Account>
84 std::lock_guard lock(mutex_);
93 template<
class T = Account>
96 std::lock_guard lock(mutex_);
102 const auto&
it = map->find(
id);
103 if (
it == map->cend())
106 return std::static_pointer_cast<T>(
it->second);
109 template<
class T = Account>
112 std::lock_guard lock(mutex_);
113 std::vector<std::shared_ptr<T>> v;
116 v.reserve(map->size());
117 for (
const auto&
it : *map)
118 v.emplace_back(std::static_pointer_cast<T>(
it.second));
124 mutable std::recursive_mutex mutex_ {};
125 std::map<std::string, std::function<std::shared_ptr<Account>(
const std::string&)>, std::less<>> generators_ {};
126 std::map<std::string, AccountMap<Account>, std::less<>> accountMaps_ {};
131 const auto&
itermap = accountMaps_.find(T::ACCOUNT_TYPE);
132 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