refactoring: public ctors

This commit is contained in:
Konstantin Morozov 2022-08-29 20:19:20 +03:00
parent 6636bdec2a
commit d185b7a332

View File

@ -69,6 +69,9 @@ public:
using Params = ContextAccessParams;
const Params & getParams() const { return params; }
ContextAccess() { } /// NOLINT
ContextAccess(const AccessControl & access_control_, const Params & params_);
/// Returns the current user. Throws if user is nullptr.
UserPtr getUser() const;
/// Same as above, but can return nullptr.
@ -166,27 +169,14 @@ public:
template <typename... Args>
static std::shared_ptr<ContextAccess> make(Args &&... args)
{
return std::make_shared<MakeSharedHelper<ContextAccess>>(std::forward<Args>(args)...);
return std::make_shared<ContextAccess>(std::forward<Args>(args)...);
}
~ContextAccess();
protected:
ContextAccess() { } /// NOLINT
ContextAccess(const AccessControl & access_control_, const Params & params_);
private:
friend class AccessControl;
template <typename T>
struct MakeSharedHelper : public T
{
template <typename... Args>
explicit MakeSharedHelper(Args &&... args) : T(std::forward<Args>(args)...)
{
}
};
void initialize();
void setUser(const UserPtr & user_) const;
void setRolesInfo(const std::shared_ptr<const EnabledRolesInfo> & roles_info_) const;