473,761 Members | 3,187 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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_Instrument Data* data). And then
using in the Panel-class a std::list<Instr ument*>.
2.) Using templates the way that Instument is a class template:
template<typena me 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

Jul 19 '05 #1
0 2213

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
39940
by: Markus Hämmerli | last post by:
I have seen in the STL that the map is working with one key. Does everyboby know if there is a possibility to have two key. Do you have a little example. Thanks Markus
4
2515
by: Steven T. Hatton | last post by:
I'm trying to create an baseclass that will serve as a parent for reference counted objects handled by boost::intrusive_ptr<>. The documentation didn't provide much in the way of describing what the functions intrusive_ptr_add_ref and intrusive_ptr_release should do, nor even what their signatures should be. There is one comment that has me a bit unsure about whether my approach is a good one:"On compilers that support argument-dependent...
3
3782
by: Barry | last post by:
As boost::pool_alloc use singleton holder for pool allocator, client programmers have to reclaim the memory by hand through calling singleton_pool<alloc_tag, elem_size>::purge_memory() or something to release the memory, so the program should have knowledge of the elem_size, sometime, it's impossible or at least hard to know the size of the element allocated by the allocator. for example: struct my_tag list<int, boost::pool_allocator<int...
12
2650
by: arnuld | last post by:
It works fine. any advice on making it better or if I can improve my C++ coding skills: /* C++ Primer - 4/e * * Chapter 9 - Sequential Containers * exercise 9.18 - STATEMENT * Write a program to copy elements from a list of "ints" * to 2 "deques". The list elements that are even should go into one deque * and even elements should go into 2nd deque.
10
6075
by: arnuld | last post by:
WANTED: /* C++ Primer - 4/e * * Exercise: 9.26 * STATEMENT * Using the following definition of ia, copy ia into a vector and into a list. Use the single iterator form of erase to remove the elements with odd values from your list * and the even values from your vector.
7
2631
by: huili80 | last post by:
Should complex<T>::real() and imag() return a value or a refernce? What does the standard say about this? I just realized that MSVC2008's implementation returns a value, but in GCC reference is returned. I tend to believe that MSVC made a big mistake here!!! But unfortunately I must use it at work, which sucks!!!
0
9353
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9788
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8794
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7342
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6623
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5241
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5384
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3481
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2765
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.