mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-06-16 07:07:13 +02:00
Initial ZMQ bindings.
This commit is contained in:
@ -76,6 +76,7 @@ add_library(SqModule MODULE SqBase.hpp Main.cpp
|
||||
Library/Utils.cpp Library/Utils.hpp
|
||||
Library/Utils/Map.cpp Library/Utils/Map.hpp
|
||||
Library/Utils/Vector.cpp Library/Utils/Vector.hpp
|
||||
Library/ZMQ.cpp Library/ZMQ.hpp
|
||||
# Misc
|
||||
Misc/Broadcast.cpp
|
||||
Misc/Constants.cpp
|
||||
@ -89,9 +90,11 @@ add_library(SqModule MODULE SqBase.hpp Main.cpp
|
||||
# POCO
|
||||
PocoLib/Crypto.cpp PocoLib/Crypto.hpp
|
||||
PocoLib/Data.cpp PocoLib/Data.hpp
|
||||
PocoLib/Foundation.cpp PocoLib/Foundation.hpp
|
||||
PocoLib/JSON.cpp PocoLib/JSON.hpp
|
||||
PocoLib/Net.cpp PocoLib/Net.hpp
|
||||
PocoLib/RegEx.cpp PocoLib/RegEx.hpp
|
||||
PocoLib/Register.cpp PocoLib/Register.hpp
|
||||
PocoLib/Time.cpp PocoLib/Time.hpp
|
||||
PocoLib/Util.cpp PocoLib/Util.hpp
|
||||
PocoLib/XML.cpp PocoLib/XML.hpp
|
||||
#
|
||||
@ -105,7 +108,7 @@ if(WIN32 OR MINGW)
|
||||
target_link_libraries(SqModule wsock32 ws2_32 shlwapi)
|
||||
endif()
|
||||
# Link to base libraries
|
||||
target_link_libraries(SqModule Squirrel FmtLib SimpleINI TinyDir ConcurrentQueue cpr maxminddb)
|
||||
target_link_libraries(SqModule Squirrel FmtLib SimpleINI TinyDir ConcurrentQueue cpr maxminddb libzmq-static)
|
||||
# Link to POCO libraries
|
||||
target_link_libraries(SqModule Poco::Foundation Poco::Encodings Poco::Crypto Poco::Util Poco::Data Poco::Net Poco::JSON Poco::XML Poco::Zip Poco::JWT Poco::Redis Poco::MongoDB)
|
||||
# Does POCO have SQLite support?
|
||||
|
@ -37,7 +37,8 @@ namespace SqMod {
|
||||
extern bool RegisterAPI(HSQUIRRELVM vm);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
extern void PocoStartup();
|
||||
extern void ZmqProcess();
|
||||
extern void ZmqTerminate();
|
||||
extern void InitializeTasks();
|
||||
extern void InitializeRoutines();
|
||||
extern void TerminateAreas();
|
||||
@ -46,7 +47,6 @@ extern void TerminateTasks();
|
||||
extern void TerminateRoutines();
|
||||
extern void TerminateCommands();
|
||||
extern void TerminateSignals();
|
||||
//extern void TerminateWorkers();
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
extern Buffer GetRealFilePath(const SQChar * path);
|
||||
@ -501,8 +501,8 @@ void Core::Terminate(bool shutdown)
|
||||
TerminateAreas();
|
||||
// Release privilege managers
|
||||
//TerminatePrivileges();
|
||||
// Terminate workers
|
||||
//TerminateWorkers();
|
||||
// Release ZMQ sockets
|
||||
ZmqTerminate();
|
||||
// In case there's a payload for reload
|
||||
m_ReloadPayload.Release();
|
||||
// Release null objects in case any reference to valid objects is stored in them
|
||||
|
287
module/Library/ZMQ.cpp
Normal file
287
module/Library/ZMQ.cpp
Normal file
@ -0,0 +1,287 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Library/ZMQ.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <sqratConst.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQMOD_DECL_TYPENAME(SqZContext, _SC("SqZmqContext"))
|
||||
SQMOD_DECL_TYPENAME(SqZMessage, _SC("SqZmqMessage"))
|
||||
SQMOD_DECL_TYPENAME(SqZSocket, _SC("SqZmqSocket"))
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void ZSkt::Flush(HSQUIRRELVM vm)
|
||||
{
|
||||
// Need someone to receive the message
|
||||
ZMsg msg;
|
||||
// Try to get a message from the queue
|
||||
while (mOutputQueue.try_dequeue(msg))
|
||||
{
|
||||
// Is there a callback to receive the message?
|
||||
if (!mOnData.IsNull())
|
||||
{
|
||||
// Transform the message into a script object
|
||||
LightObj o(SqTypeIdentity< ZMessage >{}, vm, std::make_shared< ZMsg >(std::move(msg)));
|
||||
// Forward it to the callback
|
||||
mOnData(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
LightObj ZContext::Socket(int type) const
|
||||
{
|
||||
return LightObj(SqTypeIdentity< ZSocket >{}, SqVM(), *this, type);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static void ZmqProcess()
|
||||
{
|
||||
// Go over all sockets and try to update them
|
||||
for (ZSkt * inst = ZSkt::sHead; inst && inst->mNext != ZSkt::sHead; inst = inst->mNext)
|
||||
{
|
||||
// Flush pending messages
|
||||
inst->Flush(SqVM());
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void ZmqTerminate()
|
||||
{
|
||||
// Go over all sockets and try to close them
|
||||
for (ZSkt * inst = ZSkt::sHead; inst && inst->mNext != ZSkt::sHead; inst = inst->mNext)
|
||||
{
|
||||
// Close the socket
|
||||
inst->Close();
|
||||
// Flush pending messages
|
||||
inst->Flush(SqVM());
|
||||
}
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_ZMQ(HSQUIRRELVM vm)
|
||||
{
|
||||
Table ns(vm);
|
||||
|
||||
ns.Func(_SC("Process"), &ZmqProcess);
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
ns.Bind(_SC("Context"),
|
||||
Class< ZContext, NoCopy< ZContext > >(vm, SqZContext::Str)
|
||||
// Constructors
|
||||
.Ctor()
|
||||
// Meta-methods
|
||||
.SquirrelFunc(_SC("_typename"), &SqZContext::Fn)
|
||||
// Properties
|
||||
.Prop(_SC("IsNull"), &ZContext::IsNull)
|
||||
// Member Methods
|
||||
.Func(_SC("Get"), &ZContext::Get)
|
||||
.Func(_SC("Set"), &ZContext::Set)
|
||||
.Func(_SC("Shutdown"), &ZContext::Shutdown)
|
||||
.Func(_SC("Socket"), &ZContext::Socket)
|
||||
);
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
ns.Bind(_SC("Message"),
|
||||
Class< ZMessage, NoCopy< ZMessage > >(vm, SqZMessage::Str)
|
||||
// Constructors
|
||||
.Ctor()
|
||||
.Ctor< SQInteger >()
|
||||
.Ctor< SQInteger, StackStrF & >()
|
||||
// Meta-methods
|
||||
.SquirrelFunc(_SC("_typename"), &SqZMessage::Fn)
|
||||
// Properties
|
||||
.Prop(_SC("IsNull"), &ZMessage::IsNull)
|
||||
.Prop(_SC("More"), &ZMessage::More)
|
||||
.Prop(_SC("Size"), &ZMessage::GetSize)
|
||||
// Member Methods
|
||||
.Func(_SC("Get"), &ZMessage::Get)
|
||||
.Func(_SC("Set"), &ZMessage::Set)
|
||||
.Func(_SC("Meta"), &ZMessage::Meta)
|
||||
.Func(_SC("ToString"), &ZMessage::ToString)
|
||||
);
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
ns.Bind(_SC("Socket"),
|
||||
Class< ZSocket, NoCopy< ZSocket > >(vm, SqZSocket::Str)
|
||||
// Constructors
|
||||
.Ctor()
|
||||
// Meta-methods
|
||||
.SquirrelFunc(_SC("_typename"), &SqZSocket::Fn)
|
||||
// Properties
|
||||
.Prop(_SC("IsNull"), &ZSocket::IsNull)
|
||||
// Member Methods
|
||||
.Func(_SC("Bind"), &ZSocket::Bind)
|
||||
.Func(_SC("Connect"), &ZSocket::Connect)
|
||||
.Func(_SC("Disconnect"), &ZSocket::Disconnect)
|
||||
.Func(_SC("Run"), &ZSocket::Run)
|
||||
.Func(_SC("Close"), &ZSocket::Close)
|
||||
.CbFunc(_SC("OnData"), &ZSocket::OnData)
|
||||
);
|
||||
|
||||
RootTable(vm).Bind(_SC("SqZMQ"), ns);
|
||||
|
||||
ConstTable(vm).Enum(_SC("SqZmq"), Enumeration(vm)
|
||||
/* Context options */
|
||||
.Const(_SC("IO_THREADS"), int32_t(ZMQ_IO_THREADS))
|
||||
.Const(_SC("MAX_SOCKETS"), int32_t(ZMQ_MAX_SOCKETS))
|
||||
.Const(_SC("SOCKET_LIMIT"), int32_t(ZMQ_SOCKET_LIMIT))
|
||||
.Const(_SC("THREAD_PRIORITY"), int32_t(ZMQ_THREAD_PRIORITY))
|
||||
.Const(_SC("THREAD_SCHED_POLICY"), int32_t(ZMQ_THREAD_SCHED_POLICY))
|
||||
.Const(_SC("MAX_MSGSZ"), int32_t(ZMQ_MAX_MSGSZ))
|
||||
.Const(_SC("MSG_T_SIZE"), int32_t(ZMQ_MSG_T_SIZE))
|
||||
.Const(_SC("THREAD_AFFINITY_CPU_ADD"), int32_t(ZMQ_THREAD_AFFINITY_CPU_ADD))
|
||||
.Const(_SC("THREAD_AFFINITY_CPU_REMOVE"), int32_t(ZMQ_THREAD_AFFINITY_CPU_REMOVE))
|
||||
.Const(_SC("THREAD_NAME_PREFIX"), int32_t(ZMQ_THREAD_NAME_PREFIX))
|
||||
/* Socket types. */
|
||||
.Const(_SC("PAIR"), int32_t(ZMQ_PAIR))
|
||||
.Const(_SC("PUB"), int32_t(ZMQ_PUB))
|
||||
.Const(_SC("SUB"), int32_t(ZMQ_SUB))
|
||||
.Const(_SC("REQ"), int32_t(ZMQ_REQ))
|
||||
.Const(_SC("REP"), int32_t(ZMQ_REP))
|
||||
.Const(_SC("DEALER"), int32_t(ZMQ_DEALER))
|
||||
.Const(_SC("ROUTER"), int32_t(ZMQ_ROUTER))
|
||||
.Const(_SC("PULL"), int32_t(ZMQ_PULL))
|
||||
.Const(_SC("PUSH"), int32_t(ZMQ_PUSH))
|
||||
.Const(_SC("XPUB"), int32_t(ZMQ_XPUB))
|
||||
.Const(_SC("XSUB"), int32_t(ZMQ_XSUB))
|
||||
.Const(_SC("STREAM"), int32_t(ZMQ_STREAM))
|
||||
/* Socket options */
|
||||
.Const(_SC("AFFINITY"), int32_t(ZMQ_AFFINITY))
|
||||
.Const(_SC("ROUTING_ID"), int32_t(ZMQ_ROUTING_ID))
|
||||
.Const(_SC("SUBSCRIBE"), int32_t(ZMQ_SUBSCRIBE))
|
||||
.Const(_SC("UNSUBSCRIBE"), int32_t(ZMQ_UNSUBSCRIBE))
|
||||
.Const(_SC("RATE"), int32_t(ZMQ_RATE))
|
||||
.Const(_SC("RECOVERY_IVL"), int32_t(ZMQ_RECOVERY_IVL))
|
||||
.Const(_SC("SNDBUF"), int32_t(ZMQ_SNDBUF))
|
||||
.Const(_SC("RCVBUF"), int32_t(ZMQ_RCVBUF))
|
||||
.Const(_SC("RCVMORE"), int32_t(ZMQ_RCVMORE))
|
||||
.Const(_SC("FD"), int32_t(ZMQ_FD))
|
||||
.Const(_SC("EVENTS"), int32_t(ZMQ_EVENTS))
|
||||
.Const(_SC("TYPE"), int32_t(ZMQ_TYPE))
|
||||
.Const(_SC("LINGER"), int32_t(ZMQ_LINGER))
|
||||
.Const(_SC("RECONNECT_IVL"), int32_t(ZMQ_RECONNECT_IVL))
|
||||
.Const(_SC("BACKLOG"), int32_t(ZMQ_BACKLOG))
|
||||
.Const(_SC("RECONNECT_IVL_MAX"), int32_t(ZMQ_RECONNECT_IVL_MAX))
|
||||
.Const(_SC("MAXMSGSIZE"), int32_t(ZMQ_MAXMSGSIZE))
|
||||
.Const(_SC("SNDHWM"), int32_t(ZMQ_SNDHWM))
|
||||
.Const(_SC("RCVHWM"), int32_t(ZMQ_RCVHWM))
|
||||
.Const(_SC("MULTICAST_HOPS"), int32_t(ZMQ_MULTICAST_HOPS))
|
||||
.Const(_SC("RCVTIMEO"), int32_t(ZMQ_RCVTIMEO))
|
||||
.Const(_SC("SNDTIMEO"), int32_t(ZMQ_SNDTIMEO))
|
||||
.Const(_SC("LAST_ENDPOINT"), int32_t(ZMQ_LAST_ENDPOINT))
|
||||
.Const(_SC("ROUTER_MANDATORY"), int32_t(ZMQ_ROUTER_MANDATORY))
|
||||
.Const(_SC("TCP_KEEPALIVE"), int32_t(ZMQ_TCP_KEEPALIVE))
|
||||
.Const(_SC("TCP_KEEPALIVE_CNT"), int32_t(ZMQ_TCP_KEEPALIVE_CNT))
|
||||
.Const(_SC("TCP_KEEPALIVE_IDLE"), int32_t(ZMQ_TCP_KEEPALIVE_IDLE))
|
||||
.Const(_SC("TCP_KEEPALIVE_INTVL"), int32_t(ZMQ_TCP_KEEPALIVE_INTVL))
|
||||
.Const(_SC("IMMEDIATE"), int32_t(ZMQ_IMMEDIATE))
|
||||
.Const(_SC("XPUB_VERBOSE"), int32_t(ZMQ_XPUB_VERBOSE))
|
||||
.Const(_SC("ROUTER_RAW"), int32_t(ZMQ_ROUTER_RAW))
|
||||
.Const(_SC("IPV6"), int32_t(ZMQ_IPV6))
|
||||
.Const(_SC("MECHANISM"), int32_t(ZMQ_MECHANISM))
|
||||
.Const(_SC("PLAIN_SERVER"), int32_t(ZMQ_PLAIN_SERVER))
|
||||
.Const(_SC("PLAIN_USERNAME"), int32_t(ZMQ_PLAIN_USERNAME))
|
||||
.Const(_SC("PLAIN_PASSWORD"), int32_t(ZMQ_PLAIN_PASSWORD))
|
||||
.Const(_SC("CURVE_SERVER"), int32_t(ZMQ_CURVE_SERVER))
|
||||
.Const(_SC("CURVE_PUBLICKEY"), int32_t(ZMQ_CURVE_PUBLICKEY))
|
||||
.Const(_SC("CURVE_SECRETKEY"), int32_t(ZMQ_CURVE_SECRETKEY))
|
||||
.Const(_SC("CURVE_SERVERKEY"), int32_t(ZMQ_CURVE_SERVERKEY))
|
||||
.Const(_SC("PROBE_ROUTER"), int32_t(ZMQ_PROBE_ROUTER))
|
||||
.Const(_SC("REQ_CORRELATE"), int32_t(ZMQ_REQ_CORRELATE))
|
||||
.Const(_SC("REQ_RELAXED"), int32_t(ZMQ_REQ_RELAXED))
|
||||
.Const(_SC("CONFLATE"), int32_t(ZMQ_CONFLATE))
|
||||
.Const(_SC("ZAP_DOMAIN"), int32_t(ZMQ_ZAP_DOMAIN))
|
||||
.Const(_SC("ROUTER_HANDOVER"), int32_t(ZMQ_ROUTER_HANDOVER))
|
||||
.Const(_SC("TOS"), int32_t(ZMQ_TOS))
|
||||
.Const(_SC("CONNECT_ROUTING_ID"), int32_t(ZMQ_CONNECT_ROUTING_ID))
|
||||
.Const(_SC("GSSAPI_SERVER"), int32_t(ZMQ_GSSAPI_SERVER))
|
||||
.Const(_SC("GSSAPI_PRINCIPAL"), int32_t(ZMQ_GSSAPI_PRINCIPAL))
|
||||
.Const(_SC("GSSAPI_SERVICE_PRINCIPAL"), int32_t(ZMQ_GSSAPI_SERVICE_PRINCIPAL))
|
||||
.Const(_SC("GSSAPI_PLAINTEXT"), int32_t(ZMQ_GSSAPI_PLAINTEXT))
|
||||
.Const(_SC("HANDSHAKE_IVL"), int32_t(ZMQ_HANDSHAKE_IVL))
|
||||
.Const(_SC("SOCKS_PROXY"), int32_t(ZMQ_SOCKS_PROXY))
|
||||
.Const(_SC("XPUB_NODROP"), int32_t(ZMQ_XPUB_NODROP))
|
||||
.Const(_SC("BLOCKY"), int32_t(ZMQ_BLOCKY))
|
||||
.Const(_SC("XPUB_MANUAL"), int32_t(ZMQ_XPUB_MANUAL))
|
||||
.Const(_SC("XPUB_WELCOME_MSG"), int32_t(ZMQ_XPUB_WELCOME_MSG))
|
||||
.Const(_SC("STREAM_NOTIFY"), int32_t(ZMQ_STREAM_NOTIFY))
|
||||
.Const(_SC("INVERT_MATCHING"), int32_t(ZMQ_INVERT_MATCHING))
|
||||
.Const(_SC("HEARTBEAT_IVL"), int32_t(ZMQ_HEARTBEAT_IVL))
|
||||
.Const(_SC("HEARTBEAT_TTL"), int32_t(ZMQ_HEARTBEAT_TTL))
|
||||
.Const(_SC("HEARTBEAT_TIMEOUT"), int32_t(ZMQ_HEARTBEAT_TIMEOUT))
|
||||
.Const(_SC("XPUB_VERBOSER"), int32_t(ZMQ_XPUB_VERBOSER))
|
||||
.Const(_SC("CONNECT_TIMEOUT"), int32_t(ZMQ_CONNECT_TIMEOUT))
|
||||
.Const(_SC("TCP_MAXRT"), int32_t(ZMQ_TCP_MAXRT))
|
||||
.Const(_SC("THREAD_SAFE"), int32_t(ZMQ_THREAD_SAFE))
|
||||
.Const(_SC("MULTICAST_MAXTPDU"), int32_t(ZMQ_MULTICAST_MAXTPDU))
|
||||
.Const(_SC("VMCI_BUFFER_SIZE"), int32_t(ZMQ_VMCI_BUFFER_SIZE))
|
||||
.Const(_SC("VMCI_BUFFER_MIN_SIZE"), int32_t(ZMQ_VMCI_BUFFER_MIN_SIZE))
|
||||
.Const(_SC("VMCI_BUFFER_MAX_SIZE"), int32_t(ZMQ_VMCI_BUFFER_MAX_SIZE))
|
||||
.Const(_SC("VMCI_CONNECT_TIMEOUT"), int32_t(ZMQ_VMCI_CONNECT_TIMEOUT))
|
||||
.Const(_SC("USE_FD"), int32_t(ZMQ_USE_FD))
|
||||
.Const(_SC("GSSAPI_PRINCIPAL_NAMETYPE"), int32_t(ZMQ_GSSAPI_PRINCIPAL_NAMETYPE))
|
||||
.Const(_SC("GSSAPI_SERVICE_PRINCIPAL_NAMETYPE"), int32_t(ZMQ_GSSAPI_SERVICE_PRINCIPAL_NAMETYPE))
|
||||
.Const(_SC("BINDTODEVICE"), int32_t(ZMQ_BINDTODEVICE))
|
||||
/* Message options */
|
||||
.Const(_SC("MORE"), int32_t(ZMQ_MORE))
|
||||
.Const(_SC("SHARED"), int32_t(ZMQ_SHARED))
|
||||
/* Send/recv options. */
|
||||
.Const(_SC("DONTWAIT"), int32_t(ZMQ_DONTWAIT))
|
||||
.Const(_SC("SNDMORE"), int32_t(ZMQ_SNDMORE))
|
||||
.Const(_SC("NULL"), int32_t(ZMQ_NULL))
|
||||
.Const(_SC("PLAIN"), int32_t(ZMQ_PLAIN))
|
||||
/* Security mechanisms */
|
||||
//.Const(_SC("CURVE"), int32_t(ZMQ_CURVE))
|
||||
//.Const(_SC("GSSAPI"), int32_t(ZMQ_GSSAPI))
|
||||
/* RADIO-DISH protocol */
|
||||
//.Const(_SC("GROUP_MAX_LENGTH"), int32_t(ZMQ_GROUP_MAX_LENGTH))
|
||||
/* GSSAPI principal name types */
|
||||
//.Const(_SC("GSSAPI_NT_HOSTBASED"), int32_t(ZMQ_GSSAPI_NT_HOSTBASED))
|
||||
//.Const(_SC("GSSAPI_NT_USER_NAME"), int32_t(ZMQ_GSSAPI_NT_USER_NAME))
|
||||
//.Const(_SC("GSSAPI_NT_KRB5_PRINCIPAL"), int32_t(ZMQ_GSSAPI_NT_KRB5_PRINCIPAL))
|
||||
/* Socket transport events (TCP, IPC and TIPC only) */
|
||||
//.Const(_SC("EVENT_CONNECTED"), int32_t(ZMQ_EVENT_CONNECTED))
|
||||
//.Const(_SC("EVENT_CONNECT_DELAYED"), int32_t(ZMQ_EVENT_CONNECT_DELAYED))
|
||||
//.Const(_SC("EVENT_CONNECT_RETRIED"), int32_t(ZMQ_EVENT_CONNECT_RETRIED))
|
||||
//.Const(_SC("EVENT_LISTENING"), int32_t(ZMQ_EVENT_LISTENING))
|
||||
//.Const(_SC("EVENT_BIND_FAILED"), int32_t(ZMQ_EVENT_BIND_FAILED))
|
||||
//.Const(_SC("EVENT_ACCEPTED"), int32_t(ZMQ_EVENT_ACCEPTED))
|
||||
//.Const(_SC("EVENT_ACCEPT_FAILED"), int32_t(ZMQ_EVENT_ACCEPT_FAILED))
|
||||
//.Const(_SC("EVENT_CLOSED"), int32_t(ZMQ_EVENT_CLOSED))
|
||||
//.Const(_SC("EVENT_CLOSE_FAILED"), int32_t(ZMQ_EVENT_CLOSE_FAILED))
|
||||
//.Const(_SC("EVENT_DISCONNECTED"), int32_t(ZMQ_EVENT_DISCONNECTED))
|
||||
//.Const(_SC("EVENT_MONITOR_STOPPED"), int32_t(ZMQ_EVENT_MONITOR_STOPPED))
|
||||
//.Const(_SC("EVENT_ALL"), int32_t(ZMQ_EVENT_ALL))
|
||||
//.Const(_SC("EVENT_HANDSHAKE_FAILED_NO_DETAIL"), int32_t(ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL))
|
||||
//.Const(_SC("EVENT_HANDSHAKE_SUCCEEDED"), int32_t(ZMQ_EVENT_HANDSHAKE_SUCCEEDED))
|
||||
//.Const(_SC("EVENT_HANDSHAKE_FAILED_PROTOCOL"), int32_t(ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL))
|
||||
//.Const(_SC("EVENT_HANDSHAKE_FAILED_AUTH"), int32_t(ZMQ_EVENT_HANDSHAKE_FAILED_AUTH))
|
||||
//.Const(_SC("PROTOCOL_ERROR_ZMTP_UNSPECIFIED"), int32_t(ZMQ_PROTOCOL_ERROR_ZMTP_UNSPECIFIED))
|
||||
//.Const(_SC("PROTOCOL_ERROR_ZMTP_UNEXPECTED_COMMAND"), int32_t(ZMQ_PROTOCOL_ERROR_ZMTP_UNEXPECTED_COMMAND))
|
||||
//.Const(_SC("PROTOCOL_ERROR_ZMTP_INVALID_SEQUENCE"), int32_t(ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_SEQUENCE))
|
||||
//.Const(_SC("PROTOCOL_ERROR_ZMTP_KEY_EXCHANGE"), int32_t(ZMQ_PROTOCOL_ERROR_ZMTP_KEY_EXCHANGE))
|
||||
//.Const(_SC("PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_UNSPECIFIED"), int32_t(ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_UNSPECIFIED))
|
||||
//.Const(_SC("PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_MESSAGE"), int32_t(ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_MESSAGE))
|
||||
//.Const(_SC("PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_HELLO"), int32_t(ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_HELLO))
|
||||
//.Const(_SC("PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_INITIATE"), int32_t(ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_INITIATE))
|
||||
//.Const(_SC("PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_ERROR"), int32_t(ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_ERROR))
|
||||
//.Const(_SC("PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_READY"), int32_t(ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_READY))
|
||||
//.Const(_SC("PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_WELCOME"), int32_t(ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_WELCOME))
|
||||
//.Const(_SC("PROTOCOL_ERROR_ZMTP_INVALID_METADATA"), int32_t(ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_METADATA))
|
||||
//.Const(_SC("PROTOCOL_ERROR_ZMTP_CRYPTOGRAPHIC"), int32_t(ZMQ_PROTOCOL_ERROR_ZMTP_CRYPTOGRAPHIC))
|
||||
//.Const(_SC("PROTOCOL_ERROR_ZMTP_MECHANISM_MISMATCH"), int32_t(ZMQ_PROTOCOL_ERROR_ZMTP_MECHANISM_MISMATCH))
|
||||
//.Const(_SC("PROTOCOL_ERROR_ZAP_UNSPECIFIED"), int32_t(ZMQ_PROTOCOL_ERROR_ZAP_UNSPECIFIED))
|
||||
//.Const(_SC("PROTOCOL_ERROR_ZAP_MALFORMED_REPLY"), int32_t(ZMQ_PROTOCOL_ERROR_ZAP_MALFORMED_REPLY))
|
||||
//.Const(_SC("PROTOCOL_ERROR_ZAP_BAD_REQUEST_ID"), int32_t(ZMQ_PROTOCOL_ERROR_ZAP_BAD_REQUEST_ID))
|
||||
//.Const(_SC("PROTOCOL_ERROR_ZAP_BAD_VERSION"), int32_t(ZMQ_PROTOCOL_ERROR_ZAP_BAD_VERSION))
|
||||
//.Const(_SC("PROTOCOL_ERROR_ZAP_INVALID_STATUS_CODE"), int32_t(ZMQ_PROTOCOL_ERROR_ZAP_INVALID_STATUS_CODE))
|
||||
//.Const(_SC("PROTOCOL_ERROR_ZAP_INVALID_METADATA"), int32_t(ZMQ_PROTOCOL_ERROR_ZAP_INVALID_METADATA))
|
||||
//.Const(_SC("PROTOCOL_ERROR_WS_UNSPECIFIED"), int32_t(ZMQ_PROTOCOL_ERROR_WS_UNSPECIFIED))
|
||||
);
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
1078
module/Library/ZMQ.hpp
Normal file
1078
module/Library/ZMQ.hpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -5,14 +5,6 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <Poco/Base32Encoder.h>
|
||||
#include <Poco/Base32Decoder.h>
|
||||
#include <Poco/Base64Encoder.h>
|
||||
#include <Poco/Base64Decoder.h>
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <Poco/Checksum.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
@ -240,7 +232,7 @@ static SQInteger SqGetADLER32(HSQUIRRELVM vm)
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_POCO_Crypto(HSQUIRRELVM vm)
|
||||
void Register_POCO_Crypto(HSQUIRRELVM vm, Table &)
|
||||
{
|
||||
Table ns(vm);
|
||||
|
||||
|
@ -4,7 +4,12 @@
|
||||
#include "Core/Common.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Poco/Crypto/DigestEngine.h"
|
||||
#include <Poco/Checksum.h>
|
||||
#include <Poco/Base32Encoder.h>
|
||||
#include <Poco/Base32Decoder.h>
|
||||
#include <Poco/Base64Encoder.h>
|
||||
#include <Poco/Base64Decoder.h>
|
||||
#include <Poco/Crypto/DigestEngine.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
@ -390,10 +390,10 @@ static void Register_POCO_Data_Binding(HSQUIRRELVM vm, Table & ns, const SQChar
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_POCO_Data(HSQUIRRELVM vm)
|
||||
void Register_POCO_Data(HSQUIRRELVM vm, Table &)
|
||||
{
|
||||
Table ns(vm);
|
||||
//Poco::Data::Keywords::into()
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
ns.Bind(_SC("Session"),
|
||||
Class< SqDataSession >(vm, SqPcDataSession::Str)
|
||||
|
@ -8,7 +8,7 @@ namespace SqMod {
|
||||
|
||||
|
||||
// ================================================================================================
|
||||
void Register_POCO_JSON(HSQUIRRELVM vm)
|
||||
void Register_POCO_JSON(HSQUIRRELVM vm, Table &)
|
||||
{
|
||||
Table ns(vm);
|
||||
|
||||
|
@ -8,7 +8,7 @@ namespace SqMod {
|
||||
|
||||
|
||||
// ================================================================================================
|
||||
void Register_POCO_Net(HSQUIRRELVM vm)
|
||||
void Register_POCO_Net(HSQUIRRELVM vm, Table &)
|
||||
{
|
||||
Table ns(vm);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "PocoLib/Foundation.hpp"
|
||||
#include "PocoLib/RegEx.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
@ -8,11 +8,11 @@ namespace SqMod {
|
||||
|
||||
|
||||
// ================================================================================================
|
||||
void Register_POCO_Foundation(HSQUIRRELVM vm)
|
||||
void Register_POCO_RegEx(HSQUIRRELVM vm, Table &)
|
||||
{
|
||||
Table ns(vm);
|
||||
|
||||
RootTable(vm).Bind(_SC("SqPOCO"), ns);
|
||||
RootTable(vm).Bind(_SC("SqRegEx"), ns);
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
34
module/PocoLib/Register.cpp
Normal file
34
module/PocoLib/Register.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "PocoLib/Register.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
extern Register_POCO_Crypto(HSQUIRRELVM vm, Table & ns);
|
||||
extern Register_POCO_Data(HSQUIRRELVM vm, Table & ns);
|
||||
extern Register_POCO_JSON(HSQUIRRELVM vm, Table & ns);
|
||||
extern Register_POCO_Net(HSQUIRRELVM vm, Table & ns);
|
||||
extern Register_POCO_RegEx(HSQUIRRELVM vm, Table & ns);
|
||||
extern Register_POCO_Time(HSQUIRRELVM vm, Table & ns);
|
||||
extern Register_POCO_Util(HSQUIRRELVM vm, Table & ns);
|
||||
extern Register_POCO_XML(HSQUIRRELVM vm, Table & ns);
|
||||
|
||||
// ================================================================================================
|
||||
void Register_POCO(HSQUIRRELVM vm)
|
||||
{
|
||||
Table ns(vm);
|
||||
|
||||
Register_POCO_Crypto(vm, ns);
|
||||
Register_POCO_Data(vm, ns);
|
||||
Register_POCO_JSON(vm, ns);
|
||||
Register_POCO_Net(vm, ns);
|
||||
Register_POCO_RegEx(vm, ns);
|
||||
Register_POCO_Time(vm, ns);
|
||||
Register_POCO_Util(vm, ns);
|
||||
Register_POCO_XML(vm, ns);
|
||||
|
||||
RootTable(vm).Bind(_SC("Sq"), ns);
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
11
module/PocoLib/Register.hpp
Normal file
11
module/PocoLib/Register.hpp
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Core/Common.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
|
||||
|
||||
} // Namespace:: SqMod
|
60
module/PocoLib/Time.cpp
Normal file
60
module/PocoLib/Time.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "PocoLib/Time.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQMOD_DECL_TYPENAME(SqClock, _SC("SqClock"))
|
||||
SQMOD_DECL_TYPENAME(SqDateTime, _SC("SqDateTime"))
|
||||
SQMOD_DECL_TYPENAME(SqDateTimeFormatter, _SC("SqDateTimeFormatter"))
|
||||
SQMOD_DECL_TYPENAME(SqDateTimeParser, _SC("SqDateTimeParser"))
|
||||
SQMOD_DECL_TYPENAME(SqLocalDateTime, _SC("SqLocalDateTime"))
|
||||
SQMOD_DECL_TYPENAME(SqStopwatch, _SC("SqStopwatch"))
|
||||
SQMOD_DECL_TYPENAME(SqTimespan, _SC("SqTimespan"))
|
||||
SQMOD_DECL_TYPENAME(SqTimestamp, _SC("SqTimestamp"))
|
||||
SQMOD_DECL_TYPENAME(SqTimezone, _SC("SqTimezone"))
|
||||
|
||||
// ================================================================================================
|
||||
void Register_POCO_Time(HSQUIRRELVM vm, Table & ns)
|
||||
{
|
||||
// --------------------------------------------------------------------------------------------
|
||||
ns.Bind(_SC("Timespan"),
|
||||
Class< Timespan >(vm, SqTimespan::Str)
|
||||
// Constructors
|
||||
.Ctor()
|
||||
.Ctor< const Timespan & >()
|
||||
.Ctor< long, long >()
|
||||
.Ctor< int, int, int, int, int >()
|
||||
// Meta-methods
|
||||
.SquirrelFunc(_SC("_typename"), &SqTimespan::Fn)
|
||||
// Properties
|
||||
.Prop(_SC("Days"), &Timespan::days)
|
||||
.Prop(_SC("Hours"), &Timespan::hours)
|
||||
.Prop(_SC("TotalHours"), &Timespan::totalHours)
|
||||
.Prop(_SC("Minutes"), &Timespan::minutes)
|
||||
.Prop(_SC("TotalMinutes"), &Timespan::totalMinutes)
|
||||
.Prop(_SC("Seconds"), &Timespan::seconds)
|
||||
.Prop(_SC("TotalSeconds"), &Timespan::totalSeconds)
|
||||
.Prop(_SC("Milliseconds"), &Timespan::milliseconds)
|
||||
.Prop(_SC("TotalMilliseconds"), &Timespan::totalMilliseconds)
|
||||
.Prop(_SC("Microseconds"), &Timespan::microseconds)
|
||||
.Prop(_SC("Useconds"), &Timespan::useconds)
|
||||
.Prop(_SC("TotalMicroseconds"), &Timespan::totalMicroseconds)
|
||||
// Member Methods
|
||||
.FmtFunc(_SC("Swap"), &Timespan::swap)
|
||||
// Member Overloads
|
||||
.Overload< Timespan & (Timespan::*)(long, long) >
|
||||
(_SC("Assign"), &Timespan::assign)
|
||||
.Overload< Timespan & (Timespan::*)(int, int, int, int, int) >
|
||||
(_SC("Assign"), &Timespan::assign)
|
||||
// Static Values
|
||||
.SetStaticValue(_SC("MILLISECONDS"), static_cast< SQInteger >(Timespan::MILLISECONDS))
|
||||
.SetStaticValue(_SC("SECONDS"), static_cast< SQInteger >(Timespan::SECONDS))
|
||||
.SetStaticValue(_SC("MINUTES"), static_cast< SQInteger >(Timespan::MINUTES))
|
||||
.SetStaticValue(_SC("HOURS"), static_cast< SQInteger >(Timespan::HOURS))
|
||||
.SetStaticValue(_SC("DAYS"), static_cast< SQInteger >(Timespan::DAYS))
|
||||
);
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
31
module/PocoLib/Time.hpp
Normal file
31
module/PocoLib/Time.hpp
Normal file
@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Core/Common.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <Poco/Clock.h>
|
||||
#include <Poco/DateTime.h>
|
||||
#include <Poco/DateTimeFormatter.h>
|
||||
#include <Poco/DateTimeParser.h>
|
||||
#include <Poco/LocalDateTime.h>
|
||||
#include <Poco/Stopwatch.h>
|
||||
#include <Poco/Timespan.h>
|
||||
#include <Poco/Timestamp.h>
|
||||
#include <Poco/Timezone.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
using Poco::Clock;
|
||||
using Poco::DateTime;
|
||||
using Poco::DateTimeFormatter;
|
||||
using Poco::DateTimeParser;
|
||||
using Poco::LocalDateTime;
|
||||
using Poco::Stopwatch;
|
||||
using Poco::Timespan;
|
||||
using Poco::Timestamp;
|
||||
using Poco::Timezone;
|
||||
|
||||
} // Namespace:: SqMod
|
@ -8,7 +8,7 @@ namespace SqMod {
|
||||
|
||||
|
||||
// ================================================================================================
|
||||
void Register_POCO_Util(HSQUIRRELVM vm)
|
||||
void Register_POCO_Util(HSQUIRRELVM vm, Table &)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ namespace SqMod {
|
||||
|
||||
|
||||
// ================================================================================================
|
||||
void Register_POCO_XML(HSQUIRRELVM vm)
|
||||
void Register_POCO_XML(HSQUIRRELVM vm, Table &)
|
||||
{
|
||||
Table ns(vm);
|
||||
|
||||
|
@ -34,21 +34,14 @@ extern void Register_CVehicle(HSQUIRRELVM vm);
|
||||
extern void Register_Chrono(HSQUIRRELVM vm);
|
||||
extern void Register_CURL(HSQUIRRELVM vm);
|
||||
extern void Register_IO(HSQUIRRELVM vm);
|
||||
extern void Register_Job(HSQUIRRELVM vm);
|
||||
extern void Register_MMDB(HSQUIRRELVM vm);
|
||||
extern void Register_MySQL(HSQUIRRELVM vm);
|
||||
extern void Register_Numeric(HSQUIRRELVM vm);
|
||||
extern void Register_Socket(HSQUIRRELVM vm);
|
||||
extern void Register_SQLite(HSQUIRRELVM vm);
|
||||
extern void Register_String(HSQUIRRELVM vm);
|
||||
extern void Register_System(HSQUIRRELVM vm);
|
||||
extern void Register_Utils(HSQUIRRELVM vm);
|
||||
extern void Register_Worker(HSQUIRRELVM vm);
|
||||
extern void Register_Web(HSQUIRRELVM vm);
|
||||
extern void Register_ZMQ(HSQUIRRELVM vm);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
extern void Register_POCO_Crypto(HSQUIRRELVM vm);
|
||||
extern void Register_POCO_Data(HSQUIRRELVM vm);
|
||||
extern void Register_POCO(HSQUIRRELVM vm);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
extern void Register_Constants(HSQUIRRELVM vm);
|
||||
@ -91,20 +84,13 @@ bool RegisterAPI(HSQUIRRELVM vm)
|
||||
Register_Chrono(vm);
|
||||
Register_CURL(vm);
|
||||
Register_IO(vm);
|
||||
//Register_Job(vm);
|
||||
//Register_MMDB(vm);
|
||||
//Register_MySQL(vm);
|
||||
Register_Numeric(vm);
|
||||
//Register_Socket(vm);
|
||||
//Register_SQLite(vm);
|
||||
Register_String(vm);
|
||||
Register_System(vm);
|
||||
Register_Utils(vm);
|
||||
//Register_Worker(vm);
|
||||
//Register_Web(vm);
|
||||
Register_ZMQ(vm);
|
||||
|
||||
Register_POCO_Crypto(vm);
|
||||
Register_POCO_Data(vm);
|
||||
Register_POCO(vm);
|
||||
|
||||
Register_Constants(vm);
|
||||
Register_Log(vm);
|
||||
|
@ -138,7 +138,7 @@ static _Noreturn void unreachable() { return; }
|
||||
/// Removes unused variable warnings in a way that Doxygen can understand
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
void SQUNUSED(const T&) {
|
||||
inline void SQUNUSED(const T&) {
|
||||
}
|
||||
|
||||
/// @endcond
|
||||
@ -2202,88 +2202,86 @@ template < typename T > struct SqChainedInstances
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Default constructor.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
SqChainedInstances()
|
||||
: m_Prev(nullptr), m_Next(nullptr)
|
||||
SqChainedInstances() noexcept
|
||||
: mPrev(nullptr), mNext(nullptr)
|
||||
{
|
||||
//...
|
||||
}
|
||||
|
||||
protected:
|
||||
T * mPrev; // Previous instance in the chain.
|
||||
T * mNext; // Next instance in the chain.
|
||||
|
||||
SqChainedInstances * m_Prev; // Previous instance in the chain.
|
||||
SqChainedInstances * m_Next; // Next instance in the chain.
|
||||
|
||||
static SqChainedInstances * s_Head; // The head of the instance chain.
|
||||
static T * sHead; // The head of the instance chain.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Attach the instance to the chain.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void ChainInstance()
|
||||
void ChainInstance() noexcept
|
||||
{
|
||||
// Is there an existing head?
|
||||
if (s_Head == nullptr)
|
||||
if (sHead == nullptr)
|
||||
{
|
||||
// There was no existing head
|
||||
m_Prev = m_Next = nullptr;
|
||||
mPrev = mNext = nullptr;
|
||||
// We're the head
|
||||
s_Head = this;
|
||||
sHead = static_cast< T * >(this);
|
||||
}
|
||||
// Is there a preceding instance before the current head?
|
||||
else if (s_Head->m_Prev == nullptr)
|
||||
else if (sHead->mPrev == nullptr)
|
||||
{
|
||||
// Grab the current head as the next instance in the chain
|
||||
m_Next = s_Head;
|
||||
mNext = sHead;
|
||||
// Become the new head and the preceding instance of the current head
|
||||
m_Next->m_Prev = s_Head = this;
|
||||
mNext->mPrev = sHead = static_cast< T * >(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Grab the current head as the next instance in the chain
|
||||
m_Next = s_Head;
|
||||
mNext = sHead;
|
||||
// Become the new head and the next instance of the preceding instance of the current head
|
||||
m_Next->m_Prev->m_Next = s_Head = this;
|
||||
mNext->mPrev->mNext = sHead = static_cast< T * >(this);
|
||||
// Become the preceding instance of the current head
|
||||
m_Next->m_Prev = this;
|
||||
mNext->mPrev = static_cast< T * >(this);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Detach the instance from the chain.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void UnchainInstance()
|
||||
void UnchainInstance() noexcept
|
||||
{
|
||||
// Is there an instance after us?
|
||||
if (m_Next != nullptr)
|
||||
if (mNext != nullptr)
|
||||
{
|
||||
// Link the next instance with the one before us
|
||||
m_Next->m_Prev = m_Prev;
|
||||
mNext->mPrev = mPrev;
|
||||
// Are we the current head?
|
||||
if (s_Head == this)
|
||||
if (sHead == static_cast< T * >(this))
|
||||
{
|
||||
s_Head = m_Next; // Make the next one the head
|
||||
sHead = mNext; // Make the next one the head
|
||||
}
|
||||
}
|
||||
// Is there an instance before us?
|
||||
if (m_Prev != nullptr)
|
||||
if (mPrev != nullptr)
|
||||
{
|
||||
// Link the previous instance with the one after us
|
||||
m_Prev->m_Next = m_Next;
|
||||
mPrev->mNext = mNext;
|
||||
// Are we the current head?
|
||||
if (s_Head == nullptr || s_Head == this)
|
||||
if (sHead == nullptr || sHead == static_cast< T * >(this))
|
||||
{
|
||||
// If there was no instance after us then make the previous one the head
|
||||
s_Head = m_Prev;
|
||||
sHead = mPrev;
|
||||
}
|
||||
}
|
||||
// Are we the current and the only head?
|
||||
else if (s_Head == this)
|
||||
else if (sHead == static_cast< T * >(this))
|
||||
{
|
||||
s_Head = nullptr; // No more instances of this type
|
||||
sHead = nullptr; // No more instances of this type
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template < typename T > SqChainedInstances< T > * SqChainedInstances< T >::s_Head = nullptr;
|
||||
template < typename T > T * SqChainedInstances< T >::sHead = nullptr;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @cond DEV
|
||||
|
Reference in New Issue
Block a user