I asked about this in an earlier thread, but now I have some skeletal code to show for it.

I'd like to have the functionality as shown in this family of classes. It all boils down to constructing the correct derived type from a simulator pointer and passing it as a thread (or just calling it, for the single threaded case). I should note the the multithreaded version functions as one of the threads, not as something that spawns threads.

Can anybody think of a more elegant way to do this?
Code:
class simulator
{
	//constructor: modes, laplacian, region, dt, n.
public: 
	virtual void operator()() = 0;
protected:
	//all the references and stuff
};

class single_thread
{
	//constructor: modes, laplacian, region, dt, n.
public: void operator()()
		{
			//laplacian
			//relax
			//subtract()
		}
		virtual void subtract()
		{
			//unsynchronized subtract
		}
};

class multi_thread
{
	//constructor: modes, laplacian, region, dt, n, barrier.
public: void operator()()
		{
			//laplacian
			//wait()
			//relax
			//wait()
			//subtract()
			//wait()
		}
		virtual void subtract()
		{
			//synchronized subtract
			//TODO: (note to self) How will I pull this off?
		}
};

struct low_mode
{
	void subtract() {}  //overloads subtract() to do nothing.
};

struct high_mode
{
	//doesn't overload subtract().
};

///////////// So.... ///////////

//simulator, single thread, low mode
class sim_st_lm : public simulator, public single_thread, public low_mode
{
	//constructor: modes, laplacian, region, dt, n. 
};

//simulator, multiple thread, low mode
class sim_mt_lm : public simulator, public multi_thread, public low_mode
{
	//constructor: modes, laplacian, region, dt, n, barrier.
};

//etc...
class sim_st_hm : public simulator, public single_thread, public high_mode
{
	//constructor: modes, laplacian, region, dt, n.
};

class sim_mt_hm : public simulator, public multi_thread, public high_mode
{
	//constructor: modes, laplacian, region, dt, n, barrier.
};