2008-06-02 17:41:35 -04:00
|
|
|
#include "surface.h"
|
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace Mackie;
|
|
|
|
|
|
|
|
Surface::Surface( uint32_t max_strips, uint32_t unit_strips )
|
|
|
|
: _max_strips( max_strips ), _unit_strips( unit_strips )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Surface::init()
|
|
|
|
{
|
2008-12-12 17:55:03 -05:00
|
|
|
#ifdef DEBUG
|
|
|
|
cout << "Surface::init" << endl;
|
|
|
|
#endif
|
2008-06-02 17:41:35 -04:00
|
|
|
init_controls();
|
|
|
|
init_strips( _max_strips, _unit_strips );
|
2008-12-12 17:55:03 -05:00
|
|
|
#ifdef DEBUG
|
|
|
|
cout << "Surface::init finish" << endl;
|
|
|
|
#endif
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Surface::~Surface()
|
|
|
|
{
|
|
|
|
// delete groups
|
|
|
|
for( Groups::iterator it = groups.begin(); it != groups.end(); ++it )
|
|
|
|
{
|
|
|
|
delete it->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
// delete controls
|
|
|
|
for( Controls::iterator it = controls.begin(); it != controls.end(); ++it )
|
|
|
|
{
|
|
|
|
delete *it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mackie-specific, because of multiple devices on separate ports
|
|
|
|
// add the strips from 9..max_strips
|
|
|
|
// unit_strips is the number of strips for additional units.
|
|
|
|
void Surface::init_strips( uint32_t max_strips, uint32_t unit_strips )
|
|
|
|
{
|
|
|
|
if ( strips.size() < max_strips )
|
|
|
|
{
|
|
|
|
strips.resize( max_strips );
|
|
|
|
for ( uint32_t i = strips.size(); i < max_strips; ++i )
|
|
|
|
{
|
|
|
|
// because I can't find itoa
|
|
|
|
ostringstream os;
|
|
|
|
os << "strip_" << i + 1;
|
|
|
|
string name = os.str();
|
|
|
|
|
|
|
|
// shallow copy existing strip
|
|
|
|
// which works because the controls
|
|
|
|
// have the same ids across units
|
2008-12-12 17:55:03 -05:00
|
|
|
// TODO this needs to be a deep copy because
|
|
|
|
// controls hold state now - in_use
|
2008-06-02 17:41:35 -04:00
|
|
|
Strip * strip = new Strip( *strips[i % unit_strips] );
|
|
|
|
|
|
|
|
// update the relevant values
|
|
|
|
strip->index( i );
|
|
|
|
strip->name( name );
|
|
|
|
|
|
|
|
// add to data structures
|
|
|
|
groups[name] = strip;
|
|
|
|
strips[i] = strip;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|