This commit is contained in:
CallowBlack 2022-05-30 23:53:06 +03:00
commit 85b63eac11
3 changed files with 18 additions and 0 deletions

View File

@ -63,6 +63,12 @@ struct EventCore
{
using TMyHandlerPtr = typename TypeHelper<TParams...>::TEventHandlerPtr;
EventCore() {}
EventCore(const EventCore<TParams...>& other) : handlers(other.handlers) {}
EventCore(EventCore<TParams...>&& other) : handlers(std::move(handlers)) {}
EventCore<TParams...>& operator=(const EventCore<TParams...>& other) { handlers = other.handlers; return *this; }
EventCore<TParams...>& operator=(EventCore<TParams...>&& other) { handlers = std::move(other.handlers); return *this; }
std::list<TMyHandlerPtr> handlers;
mutable std::shared_mutex coreMutex;
};
@ -126,6 +132,11 @@ class TEvent : public IEvent<TParams...>
{
}
TEvent(const TEvent& other) : m_core(other.m_core), m_handlerRunners(other.m_handlerRunners)
{
}
virtual void operator()( TParams... params )
{
TMyHandlerRunner newHandlerRunner( m_core );

View File

@ -3,6 +3,7 @@
#include "util.h"
#include <Windows.h>
#include <shellapi.h>
#include <commdlg.h>
#include <shtypes.h>
#include <shobjidl_core.h>
@ -270,4 +271,9 @@ namespace util
return static_cast<int64_t>(timezoneInfo.Bias) * 60;
}
void OpenURL(const char* url)
{
ShellExecute(nullptr, nullptr, url, nullptr, nullptr, SW_SHOW);
}
}

View File

@ -32,6 +32,7 @@ namespace util
std::optional<std::string> SelectDirectory(const char* title);
std::optional<std::string> GetOrSelectPath(CSimpleIni& ini, const char* section, const char* name, const char* friendName, const char* filter);
void OpenURL(const char* url);
std::string GetLastErrorAsString(DWORD errorId = 0);
int64_t GetCurrentTimeMillisec();