Victor Bazarov wrote:
Vladimir Jovic wrote:
[..]
Buffers (except for the source and destination) can be created in a
vector, list, or queue (different container objects for different
base buffer classes).
Where do those live and what is the relationship between buffers of
different types (instance of different templates) and the queue (one
object) which is going to "connect buffers"?
Buffers are created on the heap, and are completely independent.
They can't be independent if they are put in a queue.
requirements are that the first has to be the source buffer type, which
somehow gets input data (doesn't matter how), and the last has to be the
destination buffer type, where the resulting data is stored.
Data is of fixed size, which is known in front.
All filter objects will be stored in one container, and the data will
be processed in one run.
OK, let's proceed with a simplified model. Let's have a queue of two
filters, and make it create all the "buffers" for those and process
the input to get to the output.
struct Filter
{
virtual void setFrom(???);
virtual void setTo(???);
virtual void process(??, ??);
};
It is actually simpler :
struct Filter
{
Filter( const BufferType1 &b1, BufferType2 &b2 );
virtual void Process();
};
or as you wrote it:
struct Filter
{
void SetFrom( const BufferType1 &b1 );
void SetTo( BufferType1 &b1 );
virtual void Process();
};
Only one combination of BufferType1/BufferType2 are valid for any Filter
type.
The Process() method reads data from the input buffer, process it, and
store the result in the output buffer.
// now, is this queue generic or does it know how many filters
// it has and what is the sequence of types it processes?
The queue is generic, and can be changed during the program execution.
It can contain any number of filters.
If it was static, I would not have this problem.
struct FilterQueue
{
typedef std::list<Filter*> list;
typedef list::iterator iterator;
list filters;
void append(Filter* pf) { filters.push_back(pf); }
void createBuffers(???) {
// the filters are added in 'append', here we need to add
// all the buffers between the filters
for (iterator it = filters.begin(); it != filters.end; ++it)
{
// it would seem that the buffers have to be *ALSO*
// storable in some kind of container, no? Otherwise
// how do you move from 'createBuffers' to 'process'?
}
}
void process(???) {
for (iterator it = filters.begin(); it != filters.end; ++it)
it->process(??,??);
}
};
I can only see more questions that haven't yet been answered. Do you
have any answers?
There are actually two classes:
class BufferQueue
{
typedef std::list<Filter*> list;
Seems like you got a few things to figure out, still.