1 #ifndef _INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_
2 #define _INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_
7 * @brief Defines the base functionality required by a shared interface.
13 * @brief Must return an integer defining the interface's version.
15 virtual unsigned int GetInterfaceVersion() =0;
18 * @brief Must return a string defining the interface's unique name.
20 virtual const char *GetInterfaceName() =0;
23 * @brief Must return whether the requested version number is backwards comaptible.
24 * Note: This can be overridden for breaking changes or custom versioning.
26 * @param version Version number to compare against.
27 * @return True if compatible, false otherwise.
29 virtual bool IsVersionCompatible(unsigned int version)
31 if (version > GetInterfaceVersion())
40 enum UnloadableParentType
47 * @brief Denotes a top-level unloadable object.
49 class IUnloadableParent
52 virtual UnloadableParentType GetParentType() =0;
54 virtual void *GetParentToken() =0;
57 * @brief Called when an interface this object has requested is removed.
59 * @param pIface Interface being removed.
61 virtual void OnInterfaceUnlink(SMInterface *pIface) =0;
67 * @brief Listens for unlinked objects.
73 * @brief Called when a parent object is unloaded.
75 * @param parent The parent object which is dying.
77 virtual void OnParentUnlink(IUnloadableParent *parent)
83 * @brief Tracks dependencies and fires dependency listeners.
89 * @brief Adds an interface to the global interface system
91 * @param iface Interface pointer (must be unique).
92 * @param parent Parent unloadable token given to the module/interface.
94 virtual bool AddInterface(SMInterface *iface, IUnloadableParent *parent) =0;
97 * @brief Requests an interface from the global interface system.
98 * If found, the interface's internal reference count will be increased.
100 * @param iface_name Interface name.
101 * @param iface_vers Interface version to attempt to match.
102 * @param me Object requesting this interface, in order to track dependencies.
103 * @param pIface Pointer to store the return value in.
105 virtual bool RequestInterface(const char *iface_name,
106 unsigned int iface_vers,
107 IUnloadableParent *me,
111 * @brief Unloads an interface.
113 * @param iface Interface pointer.
114 * @param parent Security token, trivial measure to prevent accidental unloads.
115 * This token must match the one used with AddInterface().
117 virtual void RemoveInterface(SMInterface *iface, IUnloadableParent *parent) =0;
120 * @brief Adds an unlink listener.
122 * @param pListener Listener pointer.
124 virtual void AddUnlinkListener(IUnlinkListener *pListener) =0;
127 * @brief Removes an unlink listener.
129 * @param pListener Listener pointer.
131 virtual void RemoveUnlinkListener(IUnlinkListener *pListener) =0;
135 #endif //_INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_