mop65715
February 3rd, 2007, 10:44 PM
This is in some respects an oversimplification of my problem, nonetheless, I'm having a hard time trying to structure my design. The code below shows two methods that differ in the amount of buffers used. One method supports dual buffer mode. Another method supports single buffer mode. Dual buffer is just that - two buffers where writes to the buffers is done in an alternating fashion. Here's a synopsis of the code.
# include <iostream>
# include <string>
class foo_c {
int buffer_a;
int buffer_b;
public :
foo_c ( int buffer_a, int buffer_b = 0 )
: buffer_a ( buffer_a )
, buffer_b ( buffer_b )
{}
void
dual_buffer_method ( int arg )
{
if ( arg == buffer_a ) {
// stuff
} else if ( arg == buffer_b )
{
// stuff
}
}
void
single_buffer_method ( int arg )
{
if ( arg == buffer_a )
{
// stuff
}
}
};
int main()
{
foo_c single ( 5 ) ;
foo_c dual ( 6, 3 ) ;
}
What disturbs me is the selection of the buffer ( signal versus dual ) is not _quite_ intuitive. Sure I have functions ( single_buffer_method / dual_buffer_method) and a constructor with a default value, however I feel there's something amiss. Ideas welcomed.
Thanks alot
# include <iostream>
# include <string>
class foo_c {
int buffer_a;
int buffer_b;
public :
foo_c ( int buffer_a, int buffer_b = 0 )
: buffer_a ( buffer_a )
, buffer_b ( buffer_b )
{}
void
dual_buffer_method ( int arg )
{
if ( arg == buffer_a ) {
// stuff
} else if ( arg == buffer_b )
{
// stuff
}
}
void
single_buffer_method ( int arg )
{
if ( arg == buffer_a )
{
// stuff
}
}
};
int main()
{
foo_c single ( 5 ) ;
foo_c dual ( 6, 3 ) ;
}
What disturbs me is the selection of the buffer ( signal versus dual ) is not _quite_ intuitive. Sure I have functions ( single_buffer_method / dual_buffer_method) and a constructor with a default value, however I feel there's something amiss. Ideas welcomed.
Thanks alot