Next: Handling controls, Previous: Methods of the object, Up: Anatomy of a MarSystem
The first function is the standard C++ constructor; the second function is the copy constructor. The destructor is straightforward.
MyName::MyName(string name):MarSystem("MyName", name)
MyName::MyName(const MyName& a) : MarSystem(a)
MyName::~MyName()
MarSystem* MyName::clone() const
clone() is used to create a new MarSystem; Marsyas stores an
instance of every MarSystem at run-time, and future MarSystems are
simply clone()'d from the initial instance.
All member pointers to controls must be explicitly reassigned in the copy constructor. Otherwise these member points would be invalid, which results in trying to de-allocate them twice! The function should look like this:
MyMar::MyMar(const MyMar& a) : MarSystem(a)
{
ctrl_gain_ = getctrl("mrs_real/gain");
ctrl_other_ = getctrl("mrs_natural/other");
ctrl_dothis_ = getctrl("mrs_bool/dothis");
...
}