2013-11-22 15:20:02 -08:00
|
|
|
/******************************************************************************
|
|
|
|
Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.com>
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2013-12-02 21:24:38 -08:00
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
2013-11-22 15:20:02 -08:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
******************************************************************************/
|
|
|
|
|
2013-12-22 16:42:02 -08:00
|
|
|
/* Useful C++ classes and bindings for base obs data */
|
|
|
|
|
2013-11-22 15:20:02 -08:00
|
|
|
#pragma once
|
|
|
|
|
2013-12-22 16:42:02 -08:00
|
|
|
#include "obs.h"
|
2013-11-22 19:57:24 -08:00
|
|
|
|
2013-11-23 22:38:52 -08:00
|
|
|
/* RAII wrappers */
|
|
|
|
|
2021-12-30 21:10:50 -08:00
|
|
|
template<typename T, void release(T)> class OBSRefAutoRelease;
|
2019-06-22 22:13:45 -07:00
|
|
|
template<typename T, void addref(T), void release(T)> class OBSRef;
|
2022-01-24 11:59:17 -08:00
|
|
|
template<typename T, T getref(T), void release(T)> class OBSSafeRef;
|
2019-06-22 22:13:45 -07:00
|
|
|
|
2022-02-02 21:56:30 -08:00
|
|
|
using OBSObject =
|
|
|
|
OBSSafeRef<obs_object_t *, obs_object_get_ref, obs_object_release>;
|
2022-01-24 11:59:17 -08:00
|
|
|
using OBSSource =
|
|
|
|
OBSSafeRef<obs_source_t *, obs_source_get_ref, obs_source_release>;
|
|
|
|
using OBSScene =
|
|
|
|
OBSSafeRef<obs_scene_t *, obs_scene_get_ref, obs_scene_release>;
|
2019-06-22 22:13:45 -07:00
|
|
|
using OBSSceneItem =
|
|
|
|
OBSRef<obs_sceneitem_t *, obs_sceneitem_addref, obs_sceneitem_release>;
|
|
|
|
using OBSData = OBSRef<obs_data_t *, obs_data_addref, obs_data_release>;
|
|
|
|
using OBSDataArray = OBSRef<obs_data_array_t *, obs_data_array_addref,
|
|
|
|
obs_data_array_release>;
|
2022-01-24 11:59:17 -08:00
|
|
|
using OBSOutput =
|
|
|
|
OBSSafeRef<obs_output_t *, obs_output_get_ref, obs_output_release>;
|
2019-06-22 22:13:45 -07:00
|
|
|
using OBSEncoder =
|
2022-01-24 11:59:17 -08:00
|
|
|
OBSSafeRef<obs_encoder_t *, obs_encoder_get_ref, obs_encoder_release>;
|
2019-06-22 22:13:45 -07:00
|
|
|
using OBSService =
|
2022-01-24 11:59:17 -08:00
|
|
|
OBSSafeRef<obs_service_t *, obs_service_get_ref, obs_service_release>;
|
2019-06-22 22:13:45 -07:00
|
|
|
|
2022-02-02 21:56:30 -08:00
|
|
|
using OBSWeakObject = OBSRef<obs_weak_object_t *, obs_weak_object_addref,
|
|
|
|
obs_weak_object_release>;
|
2019-06-22 22:13:45 -07:00
|
|
|
using OBSWeakSource = OBSRef<obs_weak_source_t *, obs_weak_source_addref,
|
|
|
|
obs_weak_source_release>;
|
|
|
|
using OBSWeakOutput = OBSRef<obs_weak_output_t *, obs_weak_output_addref,
|
|
|
|
obs_weak_output_release>;
|
|
|
|
using OBSWeakEncoder = OBSRef<obs_weak_encoder_t *, obs_weak_encoder_addref,
|
|
|
|
obs_weak_encoder_release>;
|
|
|
|
using OBSWeakService = OBSRef<obs_weak_service_t *, obs_weak_service_addref,
|
|
|
|
obs_weak_service_release>;
|
|
|
|
|
2021-12-17 15:50:00 -08:00
|
|
|
#define OBS_AUTORELEASE
|
2022-02-02 21:56:30 -08:00
|
|
|
using OBSObjectAutoRelease =
|
|
|
|
OBSRefAutoRelease<obs_object_t *, obs_object_release>;
|
2021-11-26 00:48:28 -08:00
|
|
|
using OBSSourceAutoRelease =
|
2021-12-30 21:10:50 -08:00
|
|
|
OBSRefAutoRelease<obs_source_t *, obs_source_release>;
|
|
|
|
using OBSSceneAutoRelease = OBSRefAutoRelease<obs_scene_t *, obs_scene_release>;
|
2021-11-26 00:48:28 -08:00
|
|
|
using OBSSceneItemAutoRelease =
|
2021-12-30 21:10:50 -08:00
|
|
|
OBSRefAutoRelease<obs_sceneitem_t *, obs_sceneitem_release>;
|
|
|
|
using OBSDataAutoRelease = OBSRefAutoRelease<obs_data_t *, obs_data_release>;
|
2021-11-26 00:48:28 -08:00
|
|
|
using OBSDataArrayAutoRelease =
|
2021-12-30 21:10:50 -08:00
|
|
|
OBSRefAutoRelease<obs_data_array_t *, obs_data_array_release>;
|
2021-11-26 00:48:28 -08:00
|
|
|
using OBSOutputAutoRelease =
|
2021-12-30 21:10:50 -08:00
|
|
|
OBSRefAutoRelease<obs_output_t *, obs_output_release>;
|
2021-11-26 00:48:28 -08:00
|
|
|
using OBSEncoderAutoRelease =
|
2021-12-30 21:10:50 -08:00
|
|
|
OBSRefAutoRelease<obs_encoder_t *, obs_encoder_release>;
|
2021-11-26 00:48:28 -08:00
|
|
|
using OBSServiceAutoRelease =
|
2021-12-30 21:10:50 -08:00
|
|
|
OBSRefAutoRelease<obs_service_t *, obs_service_release>;
|
2021-11-26 00:48:28 -08:00
|
|
|
|
2022-02-02 21:56:30 -08:00
|
|
|
using OBSWeakObjectAutoRelease =
|
|
|
|
OBSRefAutoRelease<obs_weak_object_t *, obs_weak_object_release>;
|
2021-11-26 00:48:28 -08:00
|
|
|
using OBSWeakSourceAutoRelease =
|
2021-12-30 21:10:50 -08:00
|
|
|
OBSRefAutoRelease<obs_weak_source_t *, obs_weak_source_release>;
|
2021-11-26 00:48:28 -08:00
|
|
|
using OBSWeakOutputAutoRelease =
|
2021-12-30 21:10:50 -08:00
|
|
|
OBSRefAutoRelease<obs_weak_output_t *, obs_weak_output_release>;
|
2021-11-26 00:48:28 -08:00
|
|
|
using OBSWeakEncoderAutoRelease =
|
2021-12-30 21:10:50 -08:00
|
|
|
OBSRefAutoRelease<obs_weak_encoder_t *, obs_weak_encoder_release>;
|
2021-11-26 00:48:28 -08:00
|
|
|
using OBSWeakServiceAutoRelease =
|
2021-12-30 21:10:50 -08:00
|
|
|
OBSRefAutoRelease<obs_weak_service_t *, obs_weak_service_release>;
|
2021-11-26 00:48:28 -08:00
|
|
|
|
2021-12-30 21:10:50 -08:00
|
|
|
template<typename T, void release(T)> class OBSRefAutoRelease {
|
|
|
|
protected:
|
2014-02-02 13:26:23 -08:00
|
|
|
T val;
|
2013-11-22 15:20:02 -08:00
|
|
|
|
2021-12-30 21:10:50 -08:00
|
|
|
public:
|
|
|
|
inline OBSRefAutoRelease() : val(nullptr) {}
|
|
|
|
inline OBSRefAutoRelease(T val_) : val(val_) {}
|
|
|
|
OBSRefAutoRelease(const OBSRefAutoRelease &ref) = delete;
|
|
|
|
inline OBSRefAutoRelease(OBSRefAutoRelease &&ref) : val(ref.val)
|
2014-02-02 14:34:02 -08:00
|
|
|
{
|
2021-12-30 21:10:50 -08:00
|
|
|
ref.val = nullptr;
|
2014-02-02 14:34:02 -08:00
|
|
|
}
|
|
|
|
|
2021-12-30 21:10:50 -08:00
|
|
|
inline ~OBSRefAutoRelease() { release(val); }
|
2013-11-22 15:20:02 -08:00
|
|
|
|
2021-12-30 21:10:50 -08:00
|
|
|
inline operator T() const { return val; }
|
|
|
|
inline T Get() const { return val; }
|
2013-11-22 15:20:02 -08:00
|
|
|
|
2021-12-30 21:10:50 -08:00
|
|
|
inline bool operator==(T p) const { return val == p; }
|
|
|
|
inline bool operator!=(T p) const { return val != p; }
|
2013-11-22 15:20:02 -08:00
|
|
|
|
2021-12-30 21:10:50 -08:00
|
|
|
inline OBSRefAutoRelease &operator=(OBSRefAutoRelease &&ref)
|
2013-11-22 15:20:02 -08:00
|
|
|
{
|
|
|
|
if (this != &ref) {
|
2014-10-29 08:17:07 -07:00
|
|
|
release(val);
|
2014-02-02 13:26:23 -08:00
|
|
|
val = ref.val;
|
2014-02-02 14:34:02 -08:00
|
|
|
ref.val = nullptr;
|
2013-11-22 15:20:02 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2021-12-30 21:10:50 -08:00
|
|
|
inline OBSRefAutoRelease &operator=(T new_val)
|
|
|
|
{
|
|
|
|
release(val);
|
|
|
|
val = new_val;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
};
|
2013-11-22 15:20:02 -08:00
|
|
|
|
2021-12-30 21:10:50 -08:00
|
|
|
template<typename T, void addref(T), void release(T)>
|
|
|
|
class OBSRef : public OBSRefAutoRelease<T, release> {
|
|
|
|
|
|
|
|
inline OBSRef &Replace(T valIn)
|
|
|
|
{
|
|
|
|
addref(valIn);
|
2021-12-30 22:01:30 -08:00
|
|
|
release(this->val);
|
|
|
|
this->val = valIn;
|
2021-12-30 21:10:50 -08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TakeOwnership {
|
|
|
|
};
|
2021-12-30 22:01:30 -08:00
|
|
|
inline OBSRef(T val_, TakeOwnership)
|
|
|
|
: OBSRefAutoRelease<T, release>::OBSRefAutoRelease(val_)
|
|
|
|
{
|
|
|
|
}
|
2021-12-30 21:10:50 -08:00
|
|
|
|
|
|
|
public:
|
2021-12-30 22:01:30 -08:00
|
|
|
inline OBSRef()
|
|
|
|
: OBSRefAutoRelease<T, release>::OBSRefAutoRelease(nullptr)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
inline OBSRef(const OBSRef &ref)
|
|
|
|
: OBSRefAutoRelease<T, release>::OBSRefAutoRelease(ref.val)
|
|
|
|
{
|
|
|
|
addref(this->val);
|
|
|
|
}
|
|
|
|
inline OBSRef(T val_)
|
|
|
|
: OBSRefAutoRelease<T, release>::OBSRefAutoRelease(val_)
|
2021-12-30 21:10:50 -08:00
|
|
|
{
|
2021-12-30 22:01:30 -08:00
|
|
|
addref(this->val);
|
2021-12-30 21:10:50 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
inline OBSRef &operator=(const OBSRef &ref) { return Replace(ref.val); }
|
|
|
|
inline OBSRef &operator=(T valIn) { return Replace(valIn); }
|
2015-05-03 11:45:41 -07:00
|
|
|
|
2022-02-02 21:56:30 -08:00
|
|
|
friend OBSWeakObject OBSGetWeakRef(obs_object_t *object);
|
2015-05-03 11:45:41 -07:00
|
|
|
friend OBSWeakSource OBSGetWeakRef(obs_source_t *source);
|
2015-05-03 16:55:43 -07:00
|
|
|
friend OBSWeakOutput OBSGetWeakRef(obs_output_t *output);
|
2015-05-03 17:01:38 -07:00
|
|
|
friend OBSWeakEncoder OBSGetWeakRef(obs_encoder_t *encoder);
|
2022-01-24 11:59:17 -08:00
|
|
|
friend OBSWeakService OBSGetWeakRef(obs_service_t *service);
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T, T getref(T), void release(T)>
|
|
|
|
class OBSSafeRef : public OBSRefAutoRelease<T, release> {
|
|
|
|
|
|
|
|
inline OBSSafeRef &Replace(T valIn)
|
|
|
|
{
|
|
|
|
T newVal = getref(valIn);
|
|
|
|
release(this->val);
|
|
|
|
this->val = newVal;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TakeOwnership {
|
|
|
|
};
|
|
|
|
inline OBSSafeRef(T val_, TakeOwnership)
|
|
|
|
: OBSRefAutoRelease<T, release>::OBSRefAutoRelease(val_)
|
|
|
|
{
|
|
|
|
}
|
2015-05-03 17:07:43 -07:00
|
|
|
|
2022-01-24 11:59:17 -08:00
|
|
|
public:
|
|
|
|
inline OBSSafeRef()
|
|
|
|
: OBSRefAutoRelease<T, release>::OBSRefAutoRelease(nullptr)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
inline OBSSafeRef(const OBSSafeRef &ref)
|
|
|
|
: OBSRefAutoRelease<T, release>::OBSRefAutoRelease(ref.val)
|
|
|
|
{
|
|
|
|
this->val = getref(ref.val);
|
|
|
|
}
|
|
|
|
inline OBSSafeRef(T val_)
|
|
|
|
: OBSRefAutoRelease<T, release>::OBSRefAutoRelease(val_)
|
|
|
|
{
|
|
|
|
this->val = getref(this->val);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline OBSSafeRef &operator=(const OBSSafeRef &ref)
|
|
|
|
{
|
|
|
|
return Replace(ref.val);
|
|
|
|
}
|
|
|
|
inline OBSSafeRef &operator=(T valIn) { return Replace(valIn); }
|
|
|
|
|
2022-02-02 21:56:30 -08:00
|
|
|
friend OBSObject OBSGetStrongRef(obs_weak_object_t *weak);
|
2022-01-24 11:59:17 -08:00
|
|
|
friend OBSSource OBSGetStrongRef(obs_weak_source_t *weak);
|
|
|
|
friend OBSOutput OBSGetStrongRef(obs_weak_output_t *weak);
|
|
|
|
friend OBSEncoder OBSGetStrongRef(obs_weak_encoder_t *weak);
|
2015-05-03 17:07:43 -07:00
|
|
|
friend OBSService OBSGetStrongRef(obs_weak_service_t *weak);
|
2013-11-22 15:20:02 -08:00
|
|
|
};
|
2014-02-02 13:26:23 -08:00
|
|
|
|
2022-02-02 21:56:30 -08:00
|
|
|
inline OBSObject OBSGetStrongRef(obs_weak_object_t *weak)
|
|
|
|
{
|
|
|
|
return {obs_weak_object_get_object(weak), OBSObject::TakeOwnership()};
|
|
|
|
}
|
|
|
|
|
|
|
|
inline OBSWeakObject OBSGetWeakRef(obs_object_t *object)
|
|
|
|
{
|
|
|
|
return {obs_object_get_weak_object(object),
|
|
|
|
OBSWeakObject::TakeOwnership()};
|
|
|
|
}
|
|
|
|
|
2015-05-03 11:45:41 -07:00
|
|
|
inline OBSSource OBSGetStrongRef(obs_weak_source_t *weak)
|
|
|
|
{
|
|
|
|
return {obs_weak_source_get_source(weak), OBSSource::TakeOwnership()};
|
|
|
|
}
|
|
|
|
|
|
|
|
inline OBSWeakSource OBSGetWeakRef(obs_source_t *source)
|
|
|
|
{
|
|
|
|
return {obs_source_get_weak_source(source),
|
|
|
|
OBSWeakSource::TakeOwnership()};
|
|
|
|
}
|
2014-03-23 01:07:54 -07:00
|
|
|
|
2015-05-03 16:55:43 -07:00
|
|
|
inline OBSOutput OBSGetStrongRef(obs_weak_output_t *weak)
|
|
|
|
{
|
|
|
|
return {obs_weak_output_get_output(weak), OBSOutput::TakeOwnership()};
|
|
|
|
}
|
|
|
|
|
|
|
|
inline OBSWeakOutput OBSGetWeakRef(obs_output_t *output)
|
|
|
|
{
|
|
|
|
return {obs_output_get_weak_output(output),
|
|
|
|
OBSWeakOutput::TakeOwnership()};
|
|
|
|
}
|
|
|
|
|
2015-05-03 17:01:38 -07:00
|
|
|
inline OBSEncoder OBSGetStrongRef(obs_weak_encoder_t *weak)
|
|
|
|
{
|
|
|
|
return {obs_weak_encoder_get_encoder(weak),
|
|
|
|
OBSEncoder::TakeOwnership()};
|
|
|
|
}
|
|
|
|
|
|
|
|
inline OBSWeakEncoder OBSGetWeakRef(obs_encoder_t *encoder)
|
|
|
|
{
|
|
|
|
return {obs_encoder_get_weak_encoder(encoder),
|
|
|
|
OBSWeakEncoder::TakeOwnership()};
|
|
|
|
}
|
|
|
|
|
2015-05-03 17:07:43 -07:00
|
|
|
inline OBSService OBSGetStrongRef(obs_weak_service_t *weak)
|
|
|
|
{
|
|
|
|
return {obs_weak_service_get_service(weak),
|
|
|
|
OBSService::TakeOwnership()};
|
|
|
|
}
|
|
|
|
|
|
|
|
inline OBSWeakService OBSGetWeakRef(obs_service_t *service)
|
|
|
|
{
|
|
|
|
return {obs_service_get_weak_service(service),
|
|
|
|
OBSWeakService::TakeOwnership()};
|
|
|
|
}
|
|
|
|
|
2014-03-23 01:07:54 -07:00
|
|
|
/* objects that are not meant to be instanced */
|
2022-02-02 21:54:39 -08:00
|
|
|
template<typename T, void destroy(T)> class OBSPtr {
|
2014-03-23 01:07:54 -07:00
|
|
|
T obj;
|
|
|
|
|
|
|
|
public:
|
2022-02-02 21:54:39 -08:00
|
|
|
inline OBSPtr() : obj(nullptr) {}
|
|
|
|
inline OBSPtr(T obj_) : obj(obj_) {}
|
|
|
|
inline OBSPtr(const OBSPtr &) = delete;
|
|
|
|
inline OBSPtr(OBSPtr &&other) : obj(other.obj) { other.obj = nullptr; }
|
2014-03-23 01:07:54 -07:00
|
|
|
|
2022-02-02 21:54:39 -08:00
|
|
|
inline ~OBSPtr() { destroy(obj); }
|
2014-03-23 01:07:54 -07:00
|
|
|
|
2022-02-02 21:54:39 -08:00
|
|
|
inline OBSPtr &operator=(T obj_)
|
2014-03-23 01:07:54 -07:00
|
|
|
{
|
|
|
|
if (obj_ != obj)
|
|
|
|
destroy(obj);
|
|
|
|
obj = obj_;
|
|
|
|
return *this;
|
|
|
|
}
|
2022-02-02 21:54:39 -08:00
|
|
|
inline OBSPtr &operator=(const OBSPtr &) = delete;
|
|
|
|
inline OBSPtr &operator=(OBSPtr &&other)
|
2014-10-29 06:37:53 -07:00
|
|
|
{
|
|
|
|
if (obj)
|
|
|
|
destroy(obj);
|
2019-06-22 22:13:45 -07:00
|
|
|
obj = other.obj;
|
2014-10-29 06:37:53 -07:00
|
|
|
other.obj = nullptr;
|
|
|
|
return *this;
|
|
|
|
}
|
2014-03-23 01:07:54 -07:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
inline operator T() const { return obj; }
|
2014-03-23 01:07:54 -07:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
inline bool operator==(T p) const { return obj == p; }
|
|
|
|
inline bool operator!=(T p) const { return obj != p; }
|
2014-03-23 01:07:54 -07:00
|
|
|
};
|
|
|
|
|
2022-02-02 21:54:39 -08:00
|
|
|
using OBSDisplay = OBSPtr<obs_display_t *, obs_display_destroy>;
|
|
|
|
using OBSView = OBSPtr<obs_view_t *, obs_view_destroy>;
|
2014-03-23 01:07:54 -07:00
|
|
|
|
|
|
|
/* signal handler connection */
|
|
|
|
class OBSSignal {
|
2019-06-22 22:13:45 -07:00
|
|
|
signal_handler_t *handler;
|
|
|
|
const char *signal;
|
2014-03-23 01:07:54 -07:00
|
|
|
signal_callback_t callback;
|
2019-06-22 22:13:45 -07:00
|
|
|
void *param;
|
2014-03-23 01:07:54 -07:00
|
|
|
|
|
|
|
public:
|
|
|
|
inline OBSSignal()
|
2019-06-22 22:13:45 -07:00
|
|
|
: handler(nullptr),
|
|
|
|
signal(nullptr),
|
|
|
|
callback(nullptr),
|
|
|
|
param(nullptr)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
inline OBSSignal(signal_handler_t *handler_, const char *signal_,
|
|
|
|
signal_callback_t callback_, void *param_)
|
|
|
|
: handler(handler_),
|
|
|
|
signal(signal_),
|
|
|
|
callback(callback_),
|
|
|
|
param(param_)
|
2014-03-23 01:07:54 -07:00
|
|
|
{
|
2018-03-09 19:31:30 -08:00
|
|
|
signal_handler_connect_ref(handler, signal, callback, param);
|
2014-03-23 01:07:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void Disconnect()
|
|
|
|
{
|
|
|
|
signal_handler_disconnect(handler, signal, callback, param);
|
2019-06-22 22:13:45 -07:00
|
|
|
handler = nullptr;
|
|
|
|
signal = nullptr;
|
2014-03-23 01:07:54 -07:00
|
|
|
callback = nullptr;
|
2019-06-22 22:13:45 -07:00
|
|
|
param = nullptr;
|
2014-03-23 01:07:54 -07:00
|
|
|
}
|
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
inline ~OBSSignal() { Disconnect(); }
|
2014-03-23 01:07:54 -07:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
inline void Connect(signal_handler_t *handler_, const char *signal_,
|
|
|
|
signal_callback_t callback_, void *param_)
|
2014-03-23 01:07:54 -07:00
|
|
|
{
|
|
|
|
Disconnect();
|
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
handler = handler_;
|
|
|
|
signal = signal_;
|
2014-03-23 01:07:54 -07:00
|
|
|
callback = callback_;
|
2019-06-22 22:13:45 -07:00
|
|
|
param = param_;
|
2018-03-09 19:31:30 -08:00
|
|
|
signal_handler_connect_ref(handler, signal, callback, param);
|
2014-03-23 01:07:54 -07:00
|
|
|
}
|
2014-10-28 15:49:20 -07:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
OBSSignal(const OBSSignal &) = delete;
|
2020-03-19 11:20:44 -07:00
|
|
|
OBSSignal(OBSSignal &&other) noexcept
|
2019-06-22 22:13:45 -07:00
|
|
|
: handler(other.handler),
|
|
|
|
signal(other.signal),
|
2014-10-28 15:49:20 -07:00
|
|
|
callback(other.callback),
|
2019-06-22 22:13:45 -07:00
|
|
|
param(other.param)
|
2014-10-28 15:49:20 -07:00
|
|
|
{
|
2019-06-22 22:13:45 -07:00
|
|
|
other.handler = nullptr;
|
|
|
|
other.signal = nullptr;
|
2014-10-28 15:49:20 -07:00
|
|
|
other.callback = nullptr;
|
2019-06-22 22:13:45 -07:00
|
|
|
other.param = nullptr;
|
2014-10-28 15:49:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
OBSSignal &operator=(const OBSSignal &) = delete;
|
2020-03-19 11:20:44 -07:00
|
|
|
OBSSignal &operator=(OBSSignal &&other) noexcept
|
2014-10-28 15:49:20 -07:00
|
|
|
{
|
|
|
|
Disconnect();
|
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
handler = other.handler;
|
|
|
|
signal = other.signal;
|
2014-10-28 15:49:20 -07:00
|
|
|
callback = other.callback;
|
2019-06-22 22:13:45 -07:00
|
|
|
param = other.param;
|
2014-10-28 15:49:20 -07:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
other.handler = nullptr;
|
|
|
|
other.signal = nullptr;
|
2014-10-28 15:49:20 -07:00
|
|
|
other.callback = nullptr;
|
2019-06-22 22:13:45 -07:00
|
|
|
other.param = nullptr;
|
2014-10-28 15:49:20 -07:00
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
2014-03-23 01:07:54 -07:00
|
|
|
};
|