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: 584
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: 42
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: 6,379
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...)
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   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 11:28 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.