I have a C++ audio project. From an external file, that is made as follows: ~ Oscillator…
- User
I have a C++ audio project. From an external file, that is made as follows: ~ Oscillator osc1; Filter filter1; osc1 -> filter1; ~ I am able to obtain a class made contains the following information: {"Oscillator", "osc1"}, {"Filter", "filter1"} and {"osc1", "filter1"}. The pair Oscillator / osc1 represents a type and an id, while the pair id / id represents a logical order of execution. I would integrate this information to replace this syntax in my main logic class: ~ std::vector<std::unique_ptr> processors; processors.push_back( std::make_unique("osc1"); processors.push_back(std::make_unique("filter1"); ~ Basically, the type is name of the implementation of the AudioProcessor (AudioProcessor is the interface), while the fact that I push back in the vector firstly the Oscillator osc1 then the Filter filter is for order of execution (push_back firstly filter1 then osc1 is wrong). Please provide feedback on the following topics:
- Is it possible to implement this feature?
- Do I need any kind of register (like an unordered map) where I must register each implementation of AudioProcessor such that they are retrievable? 2a. If yes, where is the best place to insert this register? (Consider that this AudioProcessors will be part of a library, so I can consider to have a centralized register).
- Do you see any caveat on this approach?
- Is there a design pattern to handle this task?
- Assistant
- User
Thank you for your proposal. There is one topic still open in my opinion: in your approach, there is no verification about order of execution. Indeed, you are correctly retrieving from the vector typeIdPairs the pair, but nowhere you are verifying that the correct order of execution is respected, while effectively I also have the information {“osc1”, “filter1”}. Moreover, I would underline that I can have a scenario like: {“Filter”, “filter1”} , {“Oscillator”, “osc1”} and {“osc1”, “filter1”}, such that the order in which the AudioProcessors are defined is not the one in which they should be executed.
- Assistant
- User
Where is logically correct to place the call to the macro REGISTER_PROCESSOR? Each class will be part of a shared library, so I am wondering if such call has to belong directly to the class itself, such that once loaded each class registers itself to the Factory.
- Assistant
- User
I am getting for this call REGISTER_PROCESSOR(Oscillator) the following error: a value of type "void" cannot be used to initialize an entity of type "const bool" . Do you know what I can be?
- Assistant