SourceMod SDK  1.7
IShareSys.h
Go to the documentation of this file.
1 
32 #ifndef _INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_
33 #define _INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_
34 
40 #include <sp_vm_types.h>
41 #include <sp_vm_api.h>
42 
43 namespace SourceMod
44 {
45  class IExtension;
46  struct IdentityToken_t;
47 
49  typedef unsigned int HandleType_t;
50 
52  typedef HandleType_t IdentityType_t;
53 
57  enum FeatureType
58  {
59  FeatureType_Native,
60  FeatureType_Capability
61  };
62 
66  enum FeatureStatus
67  {
68  FeatureStatus_Available = 0,
69  FeatureStatus_Unavailable,
70  FeatureStatus_Unknown
71  };
72 
77  {
78  public:
86  virtual FeatureStatus GetFeatureStatus(FeatureType type, const char *name) = 0;
87  };
88 
93  {
94  public:
98  virtual unsigned int GetInterfaceVersion() =0;
99 
103  virtual const char *GetInterfaceName() =0;
104 
112  virtual bool IsVersionCompatible(unsigned int version)
113  {
114  if (version > GetInterfaceVersion())
115  {
116  return false;
117  }
118 
119  return true;
120  }
121  };
122 
126  class IShareSys
127  {
128  public:
136  virtual bool AddInterface(IExtension *myself, SMInterface *iface) =0;
137 
147  virtual bool RequestInterface(const char *iface_name,
148  unsigned int iface_vers,
149  IExtension *myself,
150  SMInterface **pIface) =0;
151 
166  virtual void AddNatives(IExtension *myself, const sp_nativeinfo_t *natives) =0;
167 
176  virtual IdentityType_t CreateIdentType(const char *name) =0;
177 
188  virtual IdentityType_t FindIdentType(const char *name) =0;
189 
198  virtual IdentityToken_t *CreateIdentity(IdentityType_t type, void *ptr) =0;
199 
206  virtual void DestroyIdentType(IdentityType_t type) =0;
207 
214  virtual void DestroyIdentity(IdentityToken_t *identity) =0;
215 
226  virtual void AddDependency(IExtension *myself, const char *filename, bool require, bool autoload) =0;
227 
234  virtual void RegisterLibrary(IExtension *myself, const char *name) =0;
235 
242  virtual void OverrideNatives(IExtension *myself, const sp_nativeinfo_t *natives) =0;
243 
254  virtual void AddCapabilityProvider(IExtension *myself,
255  IFeatureProvider *provider,
256  const char *name) =0;
257 
265  virtual void DropCapabilityProvider(IExtension *myself,
266  IFeatureProvider *provider,
267  const char *name) =0;
268 
277  virtual FeatureStatus TestFeature(SourcePawn::IPluginRuntime *rt,
278  FeatureType type,
279  const char *name) =0;
280 
281  };
282 }
283 
284 #endif //_INCLUDE_SOURCEMOD_IFACE_SHARE_SYS_H_
virtual IdentityType_t CreateIdentType(const char *name)=0
Creates a new identity type. NOTE: Module authors should never need to use this. Due to the current i...
virtual unsigned int GetInterfaceVersion()=0
Must return an integer defining the interface's version.
virtual IdentityToken_t * CreateIdentity(IdentityType_t type, void *ptr)=0
Creates a new identity token. This token is guaranteed to be unique amongst all other open identities...
virtual FeatureStatus TestFeature(SourcePawn::IPluginRuntime *rt, FeatureType type, const char *name)=0
Tracks dependencies and fires dependency listeners.
Definition: IShareSys.h:126
virtual bool RequestInterface(const char *iface_name, unsigned int iface_vers, IExtension *myself, SMInterface **pIface)=0
Requests an interface from the global interface system. If found, the interface's internal reference ...
Defines the base functionality required by a shared interface.
Definition: IShareSys.h:92
virtual void DestroyIdentity(IdentityToken_t *identity)=0
Destroys an identity token. Any handles being owned by this token, or any handles being...
virtual FeatureStatus GetFeatureStatus(FeatureType type, const char *name)=0
Must return whether a capability is present.
virtual IdentityType_t FindIdentType(const char *name)=0
Finds an identity type by name. DEFAULT IDENTITY TYPES: "PLUGIN" - An IPlugin object. "MODULE" - An IModule object. "CORE" - An SMGlobalClass or other singleton.
virtual void AddNatives(IExtension *myself, const sp_nativeinfo_t *natives)=0
Adds a list of natives to the global native pool, to be bound on plugin load.
virtual void AddDependency(IExtension *myself, const char *filename, bool require, bool autoload)=0
Requires an extension. This tells SourceMod that without this extension, your extension should not be...
virtual void OverrideNatives(IExtension *myself, const sp_nativeinfo_t *natives)=0
Deprecated. Does nothing.
virtual void DropCapabilityProvider(IExtension *myself, IFeatureProvider *provider, const char *name)=0
Drops a previously added cap provider.
virtual const char * GetInterfaceName()=0
Must return a string defining the interface's unique name.
IExtension * myself
Definition: smsdk_ext.cpp:41
virtual bool IsVersionCompatible(unsigned int version)
Must return whether the requested version number is backwards compatible. Note: This can be overridde...
Definition: IShareSys.h:112
Definition: IAdminSystem.h:63
virtual void DestroyIdentType(IdentityType_t type)=0
Destroys an identity type. Note that this will delete any identities that are under this type...
Encapsulates an IExtensionInterface and its dependencies.
Definition: IExtensionSys.h:53
virtual bool AddInterface(IExtension *myself, SMInterface *iface)=0
Adds an interface to the global interface system.
virtual void AddCapabilityProvider(IExtension *myself, IFeatureProvider *provider, const char *name)=0
Adds a capability provider. Feature providers are used by plugins to determine if a feature exists at...
Provides a capability feature.
Definition: IShareSys.h:76
virtual void RegisterLibrary(IExtension *myself, const char *name)=0
Registers a library name to an extension.