// This file is part of VSTGUI. It is subject to the license terms // in the LICENSE file found in the top-level directory of this // distribution and at http://github.com/steinbergmedia/vstgui/LICENSE #pragma once #include //------------------------------------------------------------------------ namespace VSTGUI { //------------------------------------------------------------------------ class Interface { public: virtual ~Interface () noexcept {} Interface () = default; Interface (const Interface&) = delete; Interface (Interface&&) = delete; Interface& operator= (const Interface&) = delete; Interface& operator= (Interface&&) = delete; template const auto dynamicCast () const { return dynamic_cast (this); } template auto dynamicCast () { return dynamic_cast (this); } }; //------------------------------------------------------------------------ using InterfacePtr = std::shared_ptr; //------------------------------------------------------------------------ template inline auto dynamicPtrCast (std::shared_ptr& obj) { return std::dynamic_pointer_cast (obj); } //------------------------------------------------------------------------ template inline const auto dynamicPtrCast (const std::shared_ptr& obj) { return std::dynamic_pointer_cast (obj); } //------------------------------------------------------------------------ template inline auto staticPtrCast (std::shared_ptr& obj) { return std::static_pointer_cast (obj); } //------------------------------------------------------------------------ template inline const auto staticPtrCast (const std::shared_ptr& obj) { return std::static_pointer_cast (obj); } //------------------------------------------------------------------------ template inline const auto& asInterface (const T& obj) { return static_cast (obj); } //------------------------------------------------------------------------ } // VSTGUI