0

Within the NodeJS code, one can recognize a macro being used, to add information to a seemingly global struct, that allows the component to be available through that struct - or, possibly an array; I didn't figure it out.

What I want to do is to create a similar model - where I have smaller components (that are going to be statically compiled into the binary) that then get all initialized in a row.

Traditionally, you might be doing something like this:

#include "my_module.h"
namespace my_module {
    int a_function() {...}
};
void initialize_my_module(SomeContext* ctx) {...}

And then within your main app, you'd have a few of these initializeXYZ functions. But I will have about 20 and upwards of these components - and it would be a huge advantage, if all components were initialized automatically.

Does anyone know of a structure or way of doing this? For an almost-real example, let's consider this situation: I am using the AngelScript scripting language and I want to initialize 5 components into it by iterating over entries in an array-like structure. Example:

asContext* ctx;
for(SomeIterator it=ComponentList.begin(); it!=ComponentList.end(); ++it) {
    it->initializer_function(ctx);
}

Thanks in advance!

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
Ingwie Phoenix
  • 2,703
  • 2
  • 24
  • 33

0 Answers0