COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 02-26-2017, 02:26 AM   #1
Anomaly
Human being with feelings
 
Anomaly's Avatar
 
Join Date: Sep 2007
Posts: 642
Default Overriding a method..?

Greetings,

I'm just learning c++, so I hope my question is not ridiculous?
My dilemma is that I'd like to be able to programmatically override a method INSIDE a single class. Is this even possible?

Here is a pseudo-code example:
Code:
Class Processor {

	void SetUpProcessor(int choice) {
		if (choice == 0) {
			howToProcess = DoItThisWay();
		}
		if (choice == 1) {
			howToProcess = DoItThatWay();
		}
	}

	double DoItThisWay(double input) {
		...blaa blaa
	}

	double DoItThatWay(double input) {
		...blaa blaa
	}

	double Process(double input) {
		return howToProcess(input);
	}

}
Thanks for your patience
__________________
___________________________
Sonic Anomaly | free JSFX & VST Plugins
Anomaly is offline   Reply With Quote
Old 02-26-2017, 09:06 AM   #2
gstuff
Human being with feelings
 
Join Date: Feb 2014
Posts: 63
Default

Look into function pointers in C++.
gstuff is offline   Reply With Quote
Old 02-26-2017, 09:37 AM   #3
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by gstuff View Post
Look into function pointers in C++.
Or just do the choice of processing function inside the audio processing function itself. I'd guess the performance overhead is about the same between using a function pointer or doing a branch. (At least if the compiler is able to inline the called functions...)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 10:50 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.