wavelength 1.0.0
Loading...
Searching...
No Matches
scriptfunction.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
5#include "os/string.h"
6#include "script/dataarray.h"
7
14public:
23 typedef void (*Handler)(DataArray *pCommand, void *pUserData);
24
34 static void Register(Handler pfnHandler, const char *pszName, void *pUserData);
35
43 static void Unregister(Handler pfnHandler);
44
55 static bool Dispatch(DataArray *pCommand);
56
57private:
58 // One registered command.
59 struct Entry {
60 String mName; // The command name.
61 Handler mHandler; // The routine the command calls.
62 void *mUserData; // The value passed back to the handler.
63 };
64
65 // The registered commands, in the order Register() added them.
66 static std::vector<Entry> sFunctions;
67};
Reference-counted array of script data nodes.
Definition dataarray.h:20
Registry of the C++ routines a script command can call by name.
Definition scriptfunction.h:13
static void Register(Handler pfnHandler, const char *pszName, void *pUserData)
Add a command to the registry.
void(* Handler)(DataArray *pCommand, void *pUserData)
Routine a script command calls.
Definition scriptfunction.h:23
static bool Dispatch(DataArray *pCommand)
Run a script command through the routine registered for its name.
static void Unregister(Handler pfnHandler)
Remove the command that calls a routine.
Growable text buffer that is also a PrnStream.
Definition string.h:19