27 lines
501 B
C++
27 lines
501 B
C++
#ifndef OBJECT_PROXY_HPP
|
|
#define OBJECT_PROXY_HPP
|
|
|
|
#include <memory>
|
|
|
|
namespace matador::object {
|
|
|
|
class basic_object_proxy {
|
|
public:
|
|
virtual ~basic_object_proxy() = default;
|
|
|
|
virtual void *get() const = 0;
|
|
};
|
|
|
|
template<class Type>
|
|
class object_proxy : public basic_object_proxy {
|
|
public:
|
|
void *get() const override { return static_cast<Type *>(this)->get(); }
|
|
|
|
Type* operator->() const { return obj_.get(); }
|
|
private:
|
|
std::shared_ptr<Type> obj_{};
|
|
};
|
|
|
|
}
|
|
#endif //OBJECT_PROXY_HPP
|