Pimpl declaration macros now define a make_pimpl(...) static helper function

This commit is contained in:
Nikita Lisitsa 2021-01-23 10:42:14 +03:00
parent a8aef622a1
commit 5e7aa7601d
11 changed files with 15 additions and 13 deletions

View file

@ -52,7 +52,7 @@ namespace psemek::app
{}
app::app(std::string const & name, int multisampling)
: pimpl_{std::make_unique<struct impl>(this)}
: pimpl_{make_impl(this)}
{
impl().start_time = clock::now();

View file

@ -185,7 +185,7 @@ namespace psemek::audio
if (auto p = instance_ptr.lock(); p)
return p;
auto p = std::make_shared<struct impl>();
auto p = make_impl();
instance_ptr = p;
return p;
}

View file

@ -139,7 +139,7 @@ void main()
};
hblur::hblur(int size, float sigma)
: pimpl_{std::make_unique<struct impl>(size, sigma, true)}
: pimpl_{make_impl(size, sigma, true)}
{}
hblur::~hblur() = default;
@ -156,7 +156,7 @@ void main()
};
vblur::vblur(int size, float sigma)
: pimpl_{std::make_unique<struct impl>(size, sigma, false)}
: pimpl_{make_impl(size, sigma, false)}
{}
vblur::~vblur() = default;

View file

@ -212,7 +212,7 @@ void main()
};
fxaa::fxaa()
: pimpl_{std::make_unique<struct impl>()}
: pimpl_{make_impl()}
{
impl().program.bind();
impl().program["u_input"] = 0;

View file

@ -54,7 +54,7 @@ void main()
};
gamma_correction::gamma_correction()
: pimpl_{std::make_unique<struct impl>()}
: pimpl_{make_impl()}
{
impl().program.bind();
impl().program["u_input"] = 0;

View file

@ -51,7 +51,7 @@ void main()
};
overlay::overlay()
: pimpl_{std::make_unique<struct impl>()}
: pimpl_{make_impl()}
{
impl().program.bind();
impl().program["u_texture"] = 0;

View file

@ -175,7 +175,7 @@ namespace psemek::gfx
};
painter::painter()
: pimpl_{std::make_unique<struct impl>()}
: pimpl_{make_impl()}
{}
painter::~painter() = default;

View file

@ -878,7 +878,7 @@ void main(){}
};
deferred_renderer::deferred_renderer()
: pimpl_{std::make_unique<struct impl>()}
: pimpl_{make_impl()}
{
impl().g_buffer_pass_program.bind();
impl().g_buffer_pass_program["u_texture"] = 0;

View file

@ -95,7 +95,7 @@ void main()
};
simple_renderer::simple_renderer()
: pimpl_{std::make_unique<struct impl>()}
: pimpl_{make_impl()}
{}
simple_renderer::~simple_renderer() = default;

View file

@ -1002,7 +1002,7 @@ namespace psemek::phys2d
}
engine::engine()
: pimpl_{std::make_unique<struct impl>()}
: pimpl_{make_impl()}
{}
engine::~engine() = default;

View file

@ -7,13 +7,15 @@
struct impl; \
std::unique_ptr<struct impl> pimpl_; \
struct impl & impl() { return *pimpl_; } \
struct impl const & impl() const { return *pimpl_; }
struct impl const & impl() const { return *pimpl_; } \
template <typename ... Args> static auto make_impl(Args && ... args) { return std::make_unique<struct impl>(std::forward<Args>(args)...); }
#define psemek_declare_shared_pimpl \
struct impl; \
std::shared_ptr<struct impl> pimpl_; \
struct impl & impl() { return *pimpl_; } \
struct impl const & impl() const { return *pimpl_; }
struct impl const & impl() const { return *pimpl_; } \
template <typename ... Args> static auto make_impl(Args && ... args) { return std::make_shared<struct impl>(std::forward<Args>(args)...); }
namespace psemek::util::pimpl
{