return m_Items; /* Makes a copy of the map. */
}
- static signals2::signal<void (const String&, const T&)> OnRegistered;
- static signals2::signal<void (const String&)> OnUnregistered;
+ signals2::signal<void (const String&, const T&)> OnRegistered;
+ signals2::signal<void (const String&)> OnUnregistered;
private:
mutable boost::mutex m_Mutex;
typename Registry<T>::ItemMap m_Items;
};
-template<typename T>
-signals2::signal<void (const String&, const T&)> Registry<T>::OnRegistered;
-
-template<typename T>
-signals2::signal<void (const String&)> Registry<T>::OnUnregistered;
-
}
#endif /* REGISTRY_H */
}
};
-#define REGISTER_CONFIG_FRAGMENT(name, fragment) \
- static icinga::RegisterConfigFragmentHelper g_RegisterCF_ ## type(name, fragment)
+#define REGISTER_CONFIG_FRAGMENT(id, name, fragment) \
+ static icinga::RegisterConfigFragmentHelper g_RegisterCF_ ## id(name, fragment)
}
PyEval_ReleaseLock();
String name;
- BOOST_FOREACH(tie(name, tuples::ignore), ScriptFunction::GetFunctions()) {
+ BOOST_FOREACH(tie(name, tuples::ignore), ScriptFunctionRegistry::GetInstance()->GetItems()) {
RegisterNativeFunction(name);
}
- ScriptFunction::OnRegistered.connect(boost::bind(&PythonLanguage::RegisterNativeFunction, this, _1));
- ScriptFunction::OnUnregistered.connect(boost::bind(&PythonLanguage::UnregisterNativeFunction, this, _1));
+ ScriptFunctionRegistry::GetInstance()->OnRegistered.connect(boost::bind(&PythonLanguage::RegisterNativeFunction, this, _1));
+ ScriptFunctionRegistry::GetInstance()->OnUnregistered.connect(boost::bind(&PythonLanguage::UnregisterNativeFunction, this, _1));
m_Initialized = true;
}
--- /dev/null
+mkembedconfig
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
int main(int argc, char **argv)
{
int cols;
FILE *infp, *outfp;
+ int i;
if (argc < 3) {
fprintf(stderr, "Syntax: %s <in-file> <out-file>\n", argv[0]);
cols++;
}
- fprintf(outfp, "0\n};\n\nREGISTER_CONFIG_FRAGMENT(\"%s\", g_ConfigFragment);\n", argv[1]);
+ char id[32];
+ strncpy(id, argv[1], sizeof(id));
+ id[sizeof(id) - 1] = '\0';
+
+ for (i = 0; i < sizeof(id) - 1; i++) {
+ if ((id[i] < 'a' || id[i] > 'z') && (id[i] < 'A' || id[i] > 'Z'))
+ id[i] = '_';
+ }
+
+ fprintf(outfp, "0\n};\n\nREGISTER_CONFIG_FRAGMENT(%s, \"%s\", g_ConfigFragment);\n", id, argv[1]);
fclose(outfp);
fclose(infp);