ZNC  trunk
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Macros | Typedefs | Functions
Modules.h File Reference
#include <znc/zncconfig.h>
#include <znc/WebModules.h>
#include <znc/Utils.h>
#include <znc/Threads.h>
#include <znc/Message.h>
#include <znc/main.h>
#include <znc/Translation.h>
#include <functional>
#include <set>
#include <queue>
#include <sys/time.h>
+ Include dependency graph for Modules.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  CModuleEntry
 C-style entry point to the module. More...
 
class  CTimer
 
class  CFPTimer
 
class  CModuleJob
 A CJob version which can be safely used in modules. More...
 
class  CModInfo
 
class  CModCommand
 A helper class for handling commands in modules. More...
 
class  CModule
 The base class for your own ZNC modules. More...
 
class  CModules
 

Macros

#define ZNC_EXPORT_LIB_EXPORT
 
#define MODCOMMONDEFS(CLASS, DESCRIPTION, TYPE)
 
#define MODCONSTRUCTOR(CLASS)
 Instead of writing a constructor, you should call this macro. More...
 
#define USERMODULEDEFS(CLASS, DESCRIPTION)   MODCOMMONDEFS(CLASS, DESCRIPTION, CModInfo::UserModule)
 This works exactly like MODULEDEFS, but for user modules. More...
 
#define GLOBALMODULEDEFS(CLASS, DESCRIPTION)   MODCOMMONDEFS(CLASS, DESCRIPTION, CModInfo::GlobalModule)
 This works exactly like MODULEDEFS, but for global modules. More...
 
#define NETWORKMODULEDEFS(CLASS, DESCRIPTION)   MODCOMMONDEFS(CLASS, DESCRIPTION, CModInfo::NetworkModule)
 This works exactly like MODULEDEFS, but for network modules. More...
 
#define MODULEDEFS(CLASS, DESCRIPTION)   NETWORKMODULEDEFS(CLASS, DESCRIPTION)
 At the end of your source file, you must call this macro in global context. More...
 

Typedefs

typedef void(* FPTimer_t )(CModule *, CFPTimer *)
 
typedef void * ModHandle
 

Functions

template<class M >
void TModInfo (CModInfo &Info)
 
template<class M >
CModuleTModLoad (ModHandle p, CUser *pUser, CIRCNetwork *pNetwork, const CString &sModName, const CString &sModPath, CModInfo::EModuleType eType)
 

Macro Definition Documentation

#define GLOBALMODULEDEFS (   CLASS,
  DESCRIPTION 
)    MODCOMMONDEFS(CLASS, DESCRIPTION, CModInfo::GlobalModule)

This works exactly like MODULEDEFS, but for global modules.

#define MODCOMMONDEFS (   CLASS,
  DESCRIPTION,
  TYPE 
)
Value:
static void FillModInfo(CModInfo& Info) { \
auto t_s = [&](const CString& sEnglish, \
const CString& sContext = "") { \
return sEnglish.empty() ? "" : Info.t_s(sEnglish, sContext); \
}; \
t_s(CString()); /* Don't warn about unused t_s */ \
Info.SetDescription(DESCRIPTION); \
Info.SetDefaultType(TYPE); \
Info.AddType(TYPE); \
Info.SetLoader(TModLoad<CLASS>); \
TModInfo<CLASS>(Info); \
} \
extern "C" { \
/* A global variable leads to ODR violation when several modules are \
* loaded. But a static variable inside a function works. */ \
ZNC_EXPORT_LIB_EXPORT const CModuleEntry* ZNCModuleEntry(); \
ZNC_EXPORT_LIB_EXPORT const CModuleEntry* ZNCModuleEntry() { \
static const CModuleEntry ThisModule = {VERSION_STR, VERSION_EXTRA, \
FillModInfo}; \
return &ThisModule; \
} \
}
C-style entry point to the module.
Definition: Modules.h:80
String class that is used inside ZNC.
Definition: ZNCString.h:68
CString t_s(const CString &sEnglish, const CString &sContext="") const
Definition: Modules.h:245
#define ZNC_COMPILE_OPTIONS_STRING
Definition: version.h:70
#define VERSION_STR
Definition: version.h:25
#define ZNC_EXPORT_LIB_EXPORT
Definition: Modules.h:60
#define VERSION_EXTRA
Definition: version.h:34
#define MODCONSTRUCTOR (   CLASS)
Value:
CLASS(ModHandle pDLL, CUser* pUser, CIRCNetwork* pNetwork, \
const CString& sModName, const CString& sModPath, \
: CModule(pDLL, pUser, pNetwork, sModName, sModPath, eType)
Definition: User.h:37
EModuleType
Definition: Modules.h:247
void * ModHandle
Definition: Modules.h:243
Definition: IRCNetwork.h:40
String class that is used inside ZNC.
Definition: ZNCString.h:68
The base class for your own ZNC modules.
Definition: Modules.h:407

Instead of writing a constructor, you should call this macro.

It accepts all the necessary arguments and passes them on to CModule's constructor. You should assume that there are no arguments to the constructor.

Usage:

class MyModule : public CModule {
MODCONSTRUCTOR(MyModule) {
// Your own constructor's code here
}
}
Parameters
CLASSThe name of your module's class.
#define MODULEDEFS (   CLASS,
  DESCRIPTION 
)    NETWORKMODULEDEFS(CLASS, DESCRIPTION)

At the end of your source file, you must call this macro in global context.

It defines some static functions which ZNC needs to load this module. By default the module will be a network module.

Parameters
CLASSThe name of your module's class.
DESCRIPTIONA short description of your module.
#define NETWORKMODULEDEFS (   CLASS,
  DESCRIPTION 
)    MODCOMMONDEFS(CLASS, DESCRIPTION, CModInfo::NetworkModule)

This works exactly like MODULEDEFS, but for network modules.

#define USERMODULEDEFS (   CLASS,
  DESCRIPTION 
)    MODCOMMONDEFS(CLASS, DESCRIPTION, CModInfo::UserModule)

This works exactly like MODULEDEFS, but for user modules.

#define ZNC_EXPORT_LIB_EXPORT

Typedef Documentation

typedef void(* FPTimer_t)(CModule *, CFPTimer *)
typedef void* ModHandle

Function Documentation

template<class M >
void TModInfo ( CModInfo Info)
template<class M >
CModule* TModLoad ( ModHandle  p,
CUser pUser,
CIRCNetwork pNetwork,
const CString sModName,
const CString sModPath,
CModInfo::EModuleType  eType 
)