1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-15 22:57:12 +02:00

Update the Mongoose module to work with the modified API.

Separate Mongoose handles into their own source files.
This commit is contained in:
Sandu Liviu Catalin
2016-06-03 21:30:05 +03:00
parent 26d12d601d
commit e1a1ccf979
17 changed files with 415 additions and 886 deletions

View File

@ -0,0 +1,181 @@
// ------------------------------------------------------------------------------------------------
#include "Handle/Connection.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
void ConnectionHnd::Validate() const
{
// Is the handle valid?
if ((m_Hnd == nullptr))
{
STHROWF("Invalid Mongoose connection reference");
}
}
// ------------------------------------------------------------------------------------------------
void ConnectionHnd::Validate(CSStr act) const
{
// Is the handle valid?
if ((m_Hnd == nullptr))
{
STHROWF("Invalid Mongoose connection reference while: %s", act);
}
}
// ------------------------------------------------------------------------------------------------
void ConnectionHnd::EvFwd(Pointer nc, Int32 ev_type, void * ev_data)
{
if (!nc->user_data)
{
_SqMod->LogErr("Event dispatched without valid instance");
}
else
{
static_cast< Handle * >(nc->user_data)->Event(ev_type, ev_data);
}
}
// ------------------------------------------------------------------------------------------------
ConnectionHnd::Handle::Handle(Pointer con)
: mCon(con)
, mRef(1)
{
// Validate the connection handle
if (!mCon)
{
STHROWF("Invalid Mongoose connection handle");
}
// Associate with the connection instance
mCon->user_data = this;
}
// ------------------------------------------------------------------------------------------------
ConnectionHnd::Handle::~Handle()
{
// Tell the manager to close this connection as soon as possible
mCon->flags |= MG_F_CLOSE_IMMEDIATELY;
}
// ------------------------------------------------------------------------------------------------
void ConnectionHnd::Handle::Event(Int32 ev_type, void * ev_data)
{
switch (ev_type)
{
case MG_EV_POLL:
{
if (!mOnPOLL.IsNull())
{
mOnPOLL.Execute();
}
} break;
case MG_EV_ACCEPT:
{
if (!mOnACCEPT.IsNull())
{
mOnACCEPT.Execute();
}
} break;
case MG_EV_CONNECT:
{
if (!mOnCONNECT.IsNull())
{
mOnCONNECT.Execute(*static_cast< Int32 * >(ev_data));
}
} break;
case MG_EV_RECV:
{
if (!mOnRECV.IsNull())
{
mOnRECV.Execute(*static_cast< Int32 * >(ev_data));
}
} break;
case MG_EV_SEND:
{
if (!mOnSEND.IsNull())
{
mOnSEND.Execute(*static_cast< Int32 * >(ev_data));
}
} break;
case MG_EV_CLOSE:
{
if (!mOnCLOSE.IsNull())
{
mOnCLOSE.Execute();
}
} break;
case MG_EV_TIMER:
{
if (!mOnTIMER.IsNull())
{
mOnTIMER.Execute();
}
} break;
default:
{
if (!mOnUNKNOWN.IsNull())
{
mOnUNKNOWN.Execute();
}
} break;
}
}
// ------------------------------------------------------------------------------------------------
Function & ConnectionHnd::Handle::GetEvent(Int32 ev_type)
{
// Identify the requested event type
switch (ev_type)
{
case MGCE_POLL: return mOnPOLL;
case MGCE_ACCEPT: return mOnACCEPT;
case MGCE_CONNECT: return mOnCONNECT;
case MGCE_RECV: return mOnRECV;
case MGCE_SEND: return mOnSEND;
case MGCE_CLOSE: return mOnCLOSE;
case MGCE_TIMER: return mOnTIMER;
case MGCE_HTTP_REQUEST: return mOnHTTP_REQUEST;
case MGCE_HTTP_REPLY: return mOnHTTP_REPLY;
case MGCE_HTTP_CHUNK: return mOnHTTP_CHUNK;
case MGCE_SSI_CALL: return mOnSSI_CALL;
case MGCE_WEBSOCKET_HANDSHAKE_REQUEST: return mOnWEBSOCKET_HANDSHAKE_REQUEST;
case MGCE_WEBSOCKET_HANDSHAKE_DONE: return mOnWEBSOCKET_HANDSHAKE_DONE;
case MGCE_WEBSOCKET_FRAME: return mOnWEBSOCKET_FRAME;
case MGCE_WEBSOCKET_CONTROL_FRAME: return mOnWEBSOCKET_CONTROL_FRAME;
case MGCE_HTTP_MULTIPART_REQUEST: return mOnHTTP_MULTIPART_REQUEST;
case MGCE_HTTP_PART_BEGIN: return mOnHTTP_PART_BEGIN;
case MGCE_HTTP_PART_DATA: return mOnHTTP_PART_DATA;
case MGCE_HTTP_PART_END: return mOnHTTP_PART_END;
case MGCE_MQTT_CONNECT: return mOnMQTT_CONNECT;
case MGCE_MQTT_CONNACK: return mOnMQTT_CONNACK;
case MGCE_MQTT_PUBLISH: return mOnMQTT_PUBLISH;
case MGCE_MQTT_PUBACK: return mOnMQTT_PUBACK;
case MGCE_MQTT_PUBREC: return mOnMQTT_PUBREC;
case MGCE_MQTT_PUBREL: return mOnMQTT_PUBREL;
case MGCE_MQTT_PUBCOMP: return mOnMQTT_PUBCOMP;
case MGCE_MQTT_SUBSCRIBE: return mOnMQTT_SUBSCRIBE;
case MGCE_MQTT_SUBACK: return mOnMQTT_SUBACK;
case MGCE_MQTT_UNSUBSCRIBE: return mOnMQTT_UNSUBSCRIBE;
case MGCE_MQTT_UNSUBACK: return mOnMQTT_UNSUBACK;
case MGCE_MQTT_PINGREQ: return mOnMQTT_PINGREQ;
case MGCE_MQTT_PINGRESP: return mOnMQTT_PINGRESP;
case MGCE_MQTT_DISCONNECT: return mOnMQTT_DISCONNECT;
case MGCE_MQTT_CONNACK_ACCEPTED: return mOnMQTT_CONNACK_ACCEPTED;
case MGCE_MQTT_CONNACK_UNACCEPTABLE_VERSION: return mOnMQTT_CONNACK_UNACCEPTABLE_VERSION;
case MGCE_MQTT_CONNACK_IDENTIFIER_REJECTED: return mOnMQTT_CONNACK_IDENTIFIER_REJECTED;
case MGCE_MQTT_CONNACK_SERVER_UNAVAILABLE: return mOnMQTT_CONNACK_SERVER_UNAVAILABLE;
case MGCE_MQTT_CONNACK_BAD_AUTH: return mOnMQTT_CONNACK_BAD_AUTH;
case MGCE_MQTT_CONNACK_NOT_AUTHORIZED: return mOnMQTT_CONNACK_NOT_AUTHORIZED;
case MGCE_COAP_CON: return mOnCOAP_CON;
case MGCE_COAP_NOC: return mOnCOAP_NOC;
case MGCE_COAP_ACK: return mOnCOAP_ACK;
case MGCE_COAP_RST: return mOnCOAP_RST;
case MGEV_UNKNOWN: return mOnUNKNOWN;
default: break;
}
// Default to a null function
return NullFunction();
}
} // Namespace:: SqMod

View File

@ -0,0 +1,341 @@
#ifndef _SQMG_HANDLE_CONNECTION_HPP_
#define _SQMG_HANDLE_CONNECTION_HPP_
// ------------------------------------------------------------------------------------------------
#include "Common.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Manages a reference counted connection and its associated resources.
*/
class ConnectionHnd
{
// --------------------------------------------------------------------------------------------
friend class Manager;
friend class Connection;
public:
// --------------------------------------------------------------------------------------------
typedef mg_connection Type; // The managed type.
// --------------------------------------------------------------------------------------------
typedef Type* Pointer; // Pointer to the managed type.
typedef const Type* ConstPtr; // Constant pointer to the managed type.
// --------------------------------------------------------------------------------------------
typedef Type& Reference; // Reference to the managed type.
typedef const Type& ConstRef; // Constant reference to the managed type.
// --------------------------------------------------------------------------------------------
typedef unsigned int Counter; // Reference counter type.
/* --------------------------------------------------------------------------------------------
* Validate the connection handle and throw an error if invalid.
*/
void Validate() const;
/* --------------------------------------------------------------------------------------------
* Validate the connection handle and throw an error if invalid.
*/
void Validate(CSStr act) const;
/* --------------------------------------------------------------------------------------------
* Forward connection events to the associated instance.
*/
static void EvFwd(Pointer nc, Int32 ev_type, void * ev_data);
protected:
/* --------------------------------------------------------------------------------------------
* The structure that holds the data associated with a physically simulated world.
*/
struct Handle
{
// ----------------------------------------------------------------------------------------
Pointer mCon; // The managed connection structure.
Counter mRef; // Reference count to the managed handles.
// ----------------------------------------------------------------------------------------
Function mOnPOLL;
Function mOnACCEPT;
Function mOnCONNECT;
Function mOnRECV;
Function mOnSEND;
Function mOnCLOSE;
Function mOnTIMER;
Function mOnHTTP_REQUEST;
Function mOnHTTP_REPLY;
Function mOnHTTP_CHUNK;
Function mOnSSI_CALL;
Function mOnWEBSOCKET_HANDSHAKE_REQUEST;
Function mOnWEBSOCKET_HANDSHAKE_DONE;
Function mOnWEBSOCKET_FRAME;
Function mOnWEBSOCKET_CONTROL_FRAME;
Function mOnHTTP_MULTIPART_REQUEST;
Function mOnHTTP_PART_BEGIN;
Function mOnHTTP_PART_DATA;
Function mOnHTTP_PART_END;
Function mOnMQTT_CONNECT;
Function mOnMQTT_CONNACK;
Function mOnMQTT_PUBLISH;
Function mOnMQTT_PUBACK;
Function mOnMQTT_PUBREC;
Function mOnMQTT_PUBREL;
Function mOnMQTT_PUBCOMP;
Function mOnMQTT_SUBSCRIBE;
Function mOnMQTT_SUBACK;
Function mOnMQTT_UNSUBSCRIBE;
Function mOnMQTT_UNSUBACK;
Function mOnMQTT_PINGREQ;
Function mOnMQTT_PINGRESP;
Function mOnMQTT_DISCONNECT;
Function mOnMQTT_CONNACK_ACCEPTED;
Function mOnMQTT_CONNACK_UNACCEPTABLE_VERSION;
Function mOnMQTT_CONNACK_IDENTIFIER_REJECTED;
Function mOnMQTT_CONNACK_SERVER_UNAVAILABLE;
Function mOnMQTT_CONNACK_BAD_AUTH;
Function mOnMQTT_CONNACK_NOT_AUTHORIZED;
Function mOnCOAP_CON;
Function mOnCOAP_NOC;
Function mOnCOAP_ACK;
Function mOnCOAP_RST;
Function mOnUNKNOWN;
/* ----------------------------------------------------------------------------------------
* Base constructor.
*/
Handle(Pointer con);
/* ----------------------------------------------------------------------------------------
* Destructor.
*/
~Handle();
/* ----------------------------------------------------------------------------------------
* Handle a certain event for this connection.
*/
void Event(Int32 ev_type, void * ev_data);
/* ----------------------------------------------------------------------------------------
* Retrieve the sript callback associated with a certain identifier.
*/
Function & GetEvent(Int32 ev_type);
};
private:
// --------------------------------------------------------------------------------------------
Handle * m_Hnd; // The managed handle instance.
/* --------------------------------------------------------------------------------------------
* Grab a strong reference to a connection handle.
*/
void Grab()
{
if (m_Hnd)
{
++(m_Hnd->mRef);
}
}
/* --------------------------------------------------------------------------------------------
* Drop a strong reference to a connection handle.
*/
void Drop()
{
if (m_Hnd && --(m_Hnd->mRef) == 0)
{
delete m_Hnd; // Let the destructor take care of cleaning up (if necessary)
}
}
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
ConnectionHnd(Pointer con)
: m_Hnd(new Handle(con))
{
/* ... */
}
public:
/* --------------------------------------------------------------------------------------------
* Default constructor (null).
*/
ConnectionHnd()
: m_Hnd(nullptr)
{
/* ... */
}
/* --------------------------------------------------------------------------------------------
* Handle constructor.
*/
ConnectionHnd(Handle * hnd)
: m_Hnd(hnd)
{
Grab();
}
/* --------------------------------------------------------------------------------------------
* Copy constructor.
*/
ConnectionHnd(const ConnectionHnd & o)
: m_Hnd(o.m_Hnd)
{
Grab();
}
/* --------------------------------------------------------------------------------------------
* Move constructor.
*/
ConnectionHnd(ConnectionHnd && o)
: m_Hnd(o.m_Hnd)
{
o.m_Hnd = nullptr;
}
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~ConnectionHnd()
{
Drop();
}
/* --------------------------------------------------------------------------------------------
* Copy assignment operator.
*/
ConnectionHnd & operator = (const ConnectionHnd & o)
{
if (m_Hnd != o.m_Hnd)
{
Drop();
m_Hnd = o.m_Hnd;
Grab();
}
return *this;
}
/* --------------------------------------------------------------------------------------------
* Move assignment operator.
*/
ConnectionHnd & operator = (ConnectionHnd && o)
{
if (m_Hnd != o.m_Hnd)
{
m_Hnd = o.m_Hnd;
o.m_Hnd = nullptr;
}
return *this;
}
/* --------------------------------------------------------------------------------------------
* Perform an equality comparison between two connection handles.
*/
bool operator == (const ConnectionHnd & o) const
{
return (m_Hnd == o.m_Hnd);
}
/* --------------------------------------------------------------------------------------------
* Perform an inequality comparison between two connection handles.
*/
bool operator != (const ConnectionHnd & o) const
{
return (m_Hnd != o.m_Hnd);
}
/* --------------------------------------------------------------------------------------------
* Implicit conversion to boolean for use in boolean operations.
*/
operator bool () const
{
return (m_Hnd != nullptr);
}
/* --------------------------------------------------------------------------------------------
* Implicit conversion to the managed instance.
*/
operator Pointer ()
{
return (m_Hnd != nullptr) ? (m_Hnd->mCon) : nullptr;
}
/* --------------------------------------------------------------------------------------------
* Implicit conversion to the managed instance.
*/
operator Pointer () const
{
return (m_Hnd != nullptr) ? (m_Hnd->mCon) : nullptr;
}
/* --------------------------------------------------------------------------------------------
* Implicit conversion to the managed instance.
*/
operator Reference ()
{
assert((m_Hnd != nullptr));
return *(m_Hnd->mCon);
}
/* --------------------------------------------------------------------------------------------
* Implicit conversion to the managed instance.
*/
operator ConstRef () const
{
assert((m_Hnd != nullptr));
return *(m_Hnd->mCon);
}
/* --------------------------------------------------------------------------------------------
* Member operator for dereferencing the managed pointer.
*/
Handle * operator -> () const
{
assert(m_Hnd != nullptr);
return m_Hnd;
}
/* --------------------------------------------------------------------------------------------
* Indirection operator for obtaining a reference of the managed pointer.
*/
Handle & operator * () const
{
assert(m_Hnd != nullptr);
return *m_Hnd;
}
/* --------------------------------------------------------------------------------------------
* Retrieve the raw handle structure pointer.
*/
Handle * HndPtr()
{
return m_Hnd;
}
/* --------------------------------------------------------------------------------------------
* Retrieve the raw handle structure pointer.
*/
Handle * HndPtr() const
{
return m_Hnd;
}
/* --------------------------------------------------------------------------------------------
* Retrieve the number of active references to the managed instance.
*/
Counter Count() const
{
return (m_Hnd != nullptr) ? m_Hnd->mRef : 0;
}
};
} // Namespace:: SqMod
#endif // _SQMG_HANDLE_CONNECTION_HPP_

View File

@ -0,0 +1,74 @@
// ------------------------------------------------------------------------------------------------
#include "Handle/Manager.hpp"
// ------------------------------------------------------------------------------------------------
#include <ctime>
#include <algorithm>
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
ManagerHnd::Managers ManagerHnd::s_Managers;
// ------------------------------------------------------------------------------------------------
void ManagerHnd::Validate() const
{
// Is the handle valid?
if ((m_Hnd == nullptr))
{
STHROWF("Invalid Mongoose manager reference");
}
}
// ------------------------------------------------------------------------------------------------
void ManagerHnd::Validate(CSStr act) const
{
// Is the handle valid?
if ((m_Hnd == nullptr))
{
STHROWF("Invalid Mongoose manager reference while: %s", act);
}
}
// ------------------------------------------------------------------------------------------------
ManagerHnd::Handle::Handle()
: mMgr()
, mRef(1)
{
// Initialize event manager object
mg_mgr_init(&mMgr, this);
// Add this instance to the pool
s_Managers.push_back(this);
}
// ------------------------------------------------------------------------------------------------
ManagerHnd::Handle::~Handle()
{
// Attempt to release manager resources
mg_mgr_free(&mMgr);
// Remove this from the pool
s_Managers.erase(std::remove(s_Managers.begin(), s_Managers.end(), this), s_Managers.end());
}
// ------------------------------------------------------------------------------------------------
Int64 ManagerHnd::Handle::Pool(Int32 milli)
{
// Pool the manager for events and store the returned timestamp
std::time_t timestamp = mg_mgr_poll(&mMgr, milli);
// Create a tm structure pointing to the unix epoch time
std::tm epoch_strt;
epoch_strt.tm_sec = 0;
epoch_strt.tm_min = 0;
epoch_strt.tm_hour = 0;
epoch_strt.tm_mday = 1;
epoch_strt.tm_mon = 0;
epoch_strt.tm_year = 70;
epoch_strt.tm_isdst = -1;
// Convert it to a time structure
std::time_t basetime = std::mktime(&epoch_strt);
// Return obtained timestamp
return static_cast< Int64 >(std::difftime(timestamp, basetime));
}
} // Namespace:: SqMod

View File

@ -0,0 +1,291 @@
#ifndef _SQMG_HANDLE_MANAGER_HPP_
#define _SQMG_HANDLE_MANAGER_HPP_
// ------------------------------------------------------------------------------------------------
#include "Common.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Manages a reference counted manager and its associated resources.
*/
class ManagerHnd
{
// --------------------------------------------------------------------------------------------
friend class Manager;
friend class Connection;
public:
// --------------------------------------------------------------------------------------------
typedef mg_mgr Type; // The managed type.
// --------------------------------------------------------------------------------------------
typedef Type* Pointer; // Pointer to the managed type.
typedef const Type* ConstPtr; // Constant pointer to the managed type.
// --------------------------------------------------------------------------------------------
typedef Type& Reference; // Reference to the managed type.
typedef const Type& ConstRef; // Constant reference to the managed type.
// --------------------------------------------------------------------------------------------
typedef unsigned int Counter; // Reference counter type.
/* --------------------------------------------------------------------------------------------
* Validate the manager handle and throw an error if invalid.
*/
void Validate() const;
/* --------------------------------------------------------------------------------------------
* Validate the manager handle and throw an error if invalid.
*/
void Validate(CSStr act) const;
protected:
/* --------------------------------------------------------------------------------------------
* The structure that holds the data associated with a physically simulated world.
*/
struct Handle
{
// ----------------------------------------------------------------------------------------
Type mMgr; // The managed manager structure.
Counter mRef; // Reference count to the managed handles.
/* ----------------------------------------------------------------------------------------
* Base constructor.
*/
Handle();
/* ----------------------------------------------------------------------------------------
* Destructor.
*/
~Handle();
/* ----------------------------------------------------------------------------------------
* Pool the managed connections for events.
*/
Int64 Pool(Int32 milli);
};
// --------------------------------------------------------------------------------------------
typedef std::vector< Handle * > Managers; // List of created managers.
// --------------------------------------------------------------------------------------------
static Managers s_Managers;
private:
// --------------------------------------------------------------------------------------------
Handle * m_Hnd; // The managed handle instance.
/* --------------------------------------------------------------------------------------------
* Grab a strong reference to a connection handle.
*/
void Grab()
{
if (m_Hnd)
{
++(m_Hnd->mRef);
}
}
/* --------------------------------------------------------------------------------------------
* Drop a strong reference to a connection handle.
*/
void Drop()
{
if (m_Hnd && --(m_Hnd->mRef) == 0)
{
delete m_Hnd; // Let the destructor take care of cleaning up (if necessary)
}
}
/* --------------------------------------------------------------------------------------------
* Base constructor.
*/
ManagerHnd(HndInit init)
: m_Hnd(init == HndInit::InitHnd ? new Handle() : nullptr)
{
/* ... */
}
public:
/* --------------------------------------------------------------------------------------------
* Default constructor (null).
*/
ManagerHnd()
: m_Hnd(nullptr)
{
/* ... */
}
/* --------------------------------------------------------------------------------------------
* Handle constructor.
*/
ManagerHnd(Handle * hnd)
: m_Hnd(hnd)
{
Grab();
}
/* --------------------------------------------------------------------------------------------
* Copy constructor.
*/
ManagerHnd(const ManagerHnd & o)
: m_Hnd(o.m_Hnd)
{
Grab();
}
/* --------------------------------------------------------------------------------------------
* Move constructor.
*/
ManagerHnd(ManagerHnd && o)
: m_Hnd(o.m_Hnd)
{
o.m_Hnd = nullptr;
}
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
~ManagerHnd()
{
Drop();
}
/* --------------------------------------------------------------------------------------------
* Copy assignment operator.
*/
ManagerHnd & operator = (const ManagerHnd & o)
{
if (m_Hnd != o.m_Hnd)
{
Drop();
m_Hnd = o.m_Hnd;
Grab();
}
return *this;
}
/* --------------------------------------------------------------------------------------------
* Move assignment operator.
*/
ManagerHnd & operator = (ManagerHnd && o)
{
if (m_Hnd != o.m_Hnd)
{
m_Hnd = o.m_Hnd;
o.m_Hnd = nullptr;
}
return *this;
}
/* --------------------------------------------------------------------------------------------
* Perform an equality comparison between two connection handles.
*/
bool operator == (const ManagerHnd & o) const
{
return (m_Hnd == o.m_Hnd);
}
/* --------------------------------------------------------------------------------------------
* Perform an inequality comparison between two connection handles.
*/
bool operator != (const ManagerHnd & o) const
{
return (m_Hnd != o.m_Hnd);
}
/* --------------------------------------------------------------------------------------------
* Implicit conversion to boolean for use in boolean operations.
*/
operator bool () const
{
return (m_Hnd != nullptr);
}
/* --------------------------------------------------------------------------------------------
* Implicit conversion to the managed instance.
*/
operator Pointer ()
{
return (m_Hnd != nullptr) ? &(m_Hnd->mMgr) : nullptr;
}
/* --------------------------------------------------------------------------------------------
* Implicit conversion to the managed instance.
*/
operator Pointer () const
{
return (m_Hnd != nullptr) ? &(m_Hnd->mMgr) : nullptr;
}
/* --------------------------------------------------------------------------------------------
* Implicit conversion to the managed instance.
*/
operator Reference ()
{
assert((m_Hnd != nullptr));
return (m_Hnd->mMgr);
}
/* --------------------------------------------------------------------------------------------
* Implicit conversion to the managed instance.
*/
operator ConstRef () const
{
assert((m_Hnd != nullptr));
return (m_Hnd->mMgr);
}
/* --------------------------------------------------------------------------------------------
* Member operator for dereferencing the managed pointer.
*/
Handle * operator -> () const
{
assert(m_Hnd != nullptr);
return m_Hnd;
}
/* --------------------------------------------------------------------------------------------
* Indirection operator for obtaining a reference of the managed pointer.
*/
Handle & operator * () const
{
assert(m_Hnd != nullptr);
return *m_Hnd;
}
/* --------------------------------------------------------------------------------------------
* Retrieve the raw handle structure pointer.
*/
Handle * HndPtr()
{
return m_Hnd;
}
/* --------------------------------------------------------------------------------------------
* Retrieve the raw handle structure pointer.
*/
Handle * HndPtr() const
{
return m_Hnd;
}
/* --------------------------------------------------------------------------------------------
* Retrieve the number of active references to the managed instance.
*/
Counter Count() const
{
return (m_Hnd != nullptr) ? m_Hnd->mRef : 0;
}
};
} // Namespace:: SqMod
#endif // _SQMG_HANDLE_MANAGER_HPP_