tahoma2d/plugins/utils/interf_holder.hpp
Toshihiro Shimizu 890dddabbd first commit
2016-03-19 02:57:51 +09:00

23 lines
635 B
C++

#if !defined(UTILS_INTERFACEHOLDER_HPP__)
#define UTILS_INTERFACEHOLDER_HPP__
#include <toonz_plugin.h>
#include <toonz_hostif.h>
extern toonz::host_interface_t *ifactory_;
void release_interf(void *interf)
{
ifactory_->release_interface(interf);
}
template <class T>
std::unique_ptr<T, decltype(&release_interf)> grab_interf(const toonz::UUID *uuid)
{
T *interf = nullptr;
if (ifactory_->query_interface(uuid, reinterpret_cast<void **>(&interf)))
return std::unique_ptr<T, decltype(&release_interf)>(nullptr, release_interf);
return std::move(std::unique_ptr<T, decltype(&release_interf)>(interf, release_interf));
}
#endif