ZNC  trunk
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 <memory>
#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  CCapability
 
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

◆ GLOBALMODULEDEFS

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

This works exactly like MODULEDEFS, but for global modules.

◆ MODCOMMONDEFS

#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, \
ZNC_COMPILE_OPTIONS_STRING, \
FillModInfo}; \
return &ThisModule; \
} \
}
Definition: Modules.h:258
CString t_s(const CString &sEnglish, const CString &sContext="") const
String class that is used inside ZNC.
Definition: ZNCString.h:68
C-style entry point to the module.
Definition: Modules.h:81
#define VERSION_EXTRA
Definition: version.h:24

◆ MODCONSTRUCTOR

#define MODCONSTRUCTOR (   CLASS)
Value:
CLASS(ModHandle pDLL, CUser* pUser, CIRCNetwork* pNetwork, \
const CString& sModName, const CString& sModPath, \
: CModule(pDLL, pUser, pNetwork, sModName, sModPath, eType)
void * ModHandle
Definition: Modules.h:256
Definition: IRCNetwork.h:40
EModuleType
Definition: Modules.h:260
The base class for your own ZNC modules.
Definition: Modules.h:420
Definition: User.h:38

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
}
}
#define MODCONSTRUCTOR(CLASS)
Instead of writing a constructor, you should call this macro.
Definition: Modules.h:127
Parameters
CLASSThe name of your module's class.

◆ MODULEDEFS

#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.

◆ NETWORKMODULEDEFS

#define NETWORKMODULEDEFS (   CLASS,
  DESCRIPTION 
)     MODCOMMONDEFS(CLASS, DESCRIPTION, CModInfo::NetworkModule)

This works exactly like MODULEDEFS, but for network modules.

◆ USERMODULEDEFS

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

This works exactly like MODULEDEFS, but for user modules.

◆ ZNC_EXPORT_LIB_EXPORT

#define ZNC_EXPORT_LIB_EXPORT

Typedef Documentation

◆ FPTimer_t

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

◆ ModHandle

typedef void* ModHandle

Function Documentation

◆ TModInfo()

template<class M >
void TModInfo ( CModInfo Info)

◆ TModLoad()

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