Home Class acting as transparent Facade
Reply: 0

Class acting as transparent Facade

Ken Y-N
1#
Ken Y-N Published in 2017-12-07 05:31:58Z

I'm not sure of the best way to describe this, or how to create a minimal compilable example, but I want to use these four registerCallback methods in my own templated class. Rather than create four explicit methods in my own code, I'd like to do something like this:

class MyClass
{
private:
    std::unique_ptr<Synchronizer<MyPolicy>> m_sync;

public:
    Connection <what goes here?>()
    {
        return m_sync.registerCallback(<what goes here?>);
    }

    // Current workaround
    Synchronizer<MyPolicy> &sync() { return *m_sync; }
    Synchronizer<MyPolicy> const sync() const { return *m_sync; }
};

Usage would be something like:

std::unique_ptr<MyClass> sync = std::unique_ptr<MyClass>(new MyClass);
sync->registerCallback(boost::bind(&ThisClass::thisCallback,
                                   this, _1, _2));

My current usage is to just to call the getter:

std::unique_ptr<MyClass> sync = std::unique_ptr<MyClass>(new MyClass);
sync->sync().registerCallback(boost::bind(&ThisClass::thisCallback,
                                          this, _1, _2));

Is there template trickery that can solve my problem? I saw this page referenced in another question, but things seem to be complicated by the Synchronizer class having the copy constructor = delete.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.296578 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO