dynamic polymorphism or std::list<boost::any>

S

Sebastian Faust

Hi,

I am thinking now for a while about a design decision. I would be glad if
you can give me some advices which is maybe the better way for solving my
problem.
I wanna do something like described in the Bridge-Pattern. Therefore I have
the following classes:
Instrument
InstrumentImpl
InstrumentData
An Instrument has an InstrumentImpl ( for example how to make an instrument
viewable ) and an InstrumentData ( holds the data of the instrument, for
example in a map, or often other structures and can perform special
operations on it, like calculating the max of all data in the map ).
Furhtermore there is a class Panel which holds all Instruments in a
std::list. My question is now what you think is the better approach for
solving this design problem:
1.) Using dynamic-polymorphism with common base-classes for Instrument,
InstrumentImpl and InstrumentData and connect a specific InstrumentImpl and
InstrumentData object with an Instrument object by using the ctor
Instrument(Base_InstrumentImpl* imp, Base_InstrumentData* data). And then
using in the Panel-class a std::list<Instrument*>.
2.) Using templates the way that Instument is a class template:
template<typename impl, typename data> class Instrument and then using in
the Panel class a std::list<boost::any>.
The important thing is that in general it would be hard for me to find a
common base-class for the data- and impl-classes. So it would be better if
the data- and impl-types would be unrelated. That's why IMHO I tend to use
the second solution.

Thanks in advance,
Sebastian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top