J
Joe C
I have a class that performs transformations on data streams. As written,
the class constructor takes several parameters and a data-source to produce
it's stream.
I have the need to combine the output of two instances of this class to
generate a third data stream. (think eg of applying a filters to audio)
When I do this, the parameters that I supply the second class are dependent
upon the state of the system after the first transform has occured.
I have been accomplishing this by using a function outside the class that
instantiates the two classes as the information needed to instantiate them
becomes available. Once both objects are built, their output is combined
and the function exits, the objects are destroyed, and the caller gets his
transformed data.
I don't like this solution because my objects cease to exist once I return
the data...but I want to keem them around for a while longer.
So...as a solution, I decided to create a new class that would hold the two
instances of my transforming class objects and return the combined data. My
problem is...how can I construct my two member-data objects when the
construction parameters of the second object depend upon having made some
calculations on the first, successfully constructed object?
I can't supply the constructor parameters for the second object in the
initialization list because those parameters require some processing *after*
the first object is constructed.
Thanks for your thoughts
Joe
the class constructor takes several parameters and a data-source to produce
it's stream.
I have the need to combine the output of two instances of this class to
generate a third data stream. (think eg of applying a filters to audio)
When I do this, the parameters that I supply the second class are dependent
upon the state of the system after the first transform has occured.
I have been accomplishing this by using a function outside the class that
instantiates the two classes as the information needed to instantiate them
becomes available. Once both objects are built, their output is combined
and the function exits, the objects are destroyed, and the caller gets his
transformed data.
I don't like this solution because my objects cease to exist once I return
the data...but I want to keem them around for a while longer.
So...as a solution, I decided to create a new class that would hold the two
instances of my transforming class objects and return the combined data. My
problem is...how can I construct my two member-data objects when the
construction parameters of the second object depend upon having made some
calculations on the first, successfully constructed object?
I can't supply the constructor parameters for the second object in the
initialization list because those parameters require some processing *after*
the first object is constructed.
Thanks for your thoughts
Joe