473,651 Members | 2,582 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Design question - interfacing with lots of different hardware architectures

Hello

My program works with different types of telephone system. Their interfaces
are all different.

But, of course, I don't want to have to write a different program for each
system. There is a LOT of code in the existing program which interfaces
with just one telephone system. I can re-use a lot of that. But I want a
flexible interface to the hardware.

My thinking is I would need to use some sort of polymorphic interface class.
Is this idea along the right lines:

class CTelephoneInter face
This class would have pure virtual functions eg to connect, disconnect,
request, configure, etc.

Then I would I would inherit:

class CSpecificSystem : public CTelephoneInter face

which would implement the base class pure virtual functions.

Any tips on implementation would be handy?

Then my next problem is that the telephone system sends event information.
some of it is unsolicited (ie no request generated the event). How would I
model that?

Any help would be much appreciated.

A
Aug 2 '08 #1
4 1300
In article <g7************ *******@news.de mon.co.uk>,
"Angus" <no****@gmail.c omwrote:
...
class CTelephoneInter face
This class would have pure virtual functions eg to connect, disconnect,
request, configure, etc.

Then I would I would inherit:

class CSpecificSystem : public CTelephoneInter face

which would implement the base class pure virtual functions.
Just a side comment on naming: drop the C prefix and Interface suffix,
unless they add any useful information. So you have Telephone as the
base class, LucentTelephone as a derived class for example. Code reads
more naturally without stilted names.
Aug 2 '08 #2
"Angus" <no****@gmail.c omwrote:
My program works with different types of telephone system. Their interfaces
are all different.

But, of course, I don't want to have to write a different program for each
system. There is a LOT of code in the existing program which interfaces
with just one telephone system. I can re-use a lot of that. But I want a
flexible interface to the hardware.

My thinking is I would need to use some sort of polymorphic interface class.
Is this idea along the right lines:
Probably not. I would only do the above is I had to change hardware at
runtime and I have a feeling that isn't the case.

One option that I consider better is a variation of the handle-body or
pimpl idiom.

Make your "Telephone. h" like this:

class Telephone {
struct Impl;
Impl* pimpl;
public:
void connect();
void disconnect();
// &c.
};

Now define the "Telephone::Imp l struct inside the Telephone.cpp file and
implement the functions as appropriate.

Now here is the cool bit. Write Multiple Telephone.cpp files
(ThisTelephone. cpp, ThatTelephone.c pp, SoOnTelephone.c pp) with each one
dedicated to a specific hardware.

Now when you compile for a particular hardware, use the appropriate cpp
file. QED.
Then my next problem is that the telephone system sends event information.
some of it is unsolicited (ie no request generated the event). How would I
model that?
Sounds like an Observer pattern would be appropriate.
Aug 3 '08 #3
On Aug 3, 3:30 am, "Daniel T." <danie...@earth link.netwrote:
"Angus" <nos...@gmail.c omwrote:
My thinking is I would need to use some sort of polymorphic
interface class. Is this idea along the right lines:
Probably not. I would only do the above is I had to change
hardware at runtime and I have a feeling that isn't the case.
The original poster didn't specify what his program was doing,
but polymorphic interfaces were certainly an important part of
the telephone systems I worked on. First, because you normally
connect more than one piece of equipment to the system, the
various equipment will be of different types, and you want to
handle them identically. And secondly, you're not allowed to
shut the system down, even when upgrading equipment. (The
hardware is specially designed so that you can safely remove a
PCB and insert another without removing power, or even stopping
operations on other PCB's on the same bus. Don't try that on
your PC, however.)
One option that I consider better is a variation of the
handle-body or pimpl idiom.
*IF* you just have one type per instance of the program, why
bother. Just define one header file, as many source files (or
libraries) as needed, and link in the appropriate one.
Make your "Telephone. h" like this:

class Telephone {
struct Impl;
Impl* pimpl;
public:
void connect();
void disconnect();
// &c.

};
Now define the "Telephone::Imp l struct inside the
Telephone.cpp file and implement the functions as appropriate.
If the different types require different data, yes.
Alternatively (although I prefer the above approach as well),
you can define an interface with a static member function to
construct instances, and put the data in the derived class.
Now here is the cool bit. Write Multiple Telephone.cpp files
(ThisTelephone. cpp, ThatTelephone.c pp, SoOnTelephone.c pp) with
each one dedicated to a specific hardware.
Now when you compile for a particular hardware, use the
appropriate cpp file. QED.
Then my next problem is that the telephone system sends
event information. some of it is unsolicited (ie no request
generated the event). How would I model that?
Sounds like an Observer pattern would be appropriate.
More or less. In larger systems, you typically use some sort of
central dispatcher: events are defined using ASN.1 (much like
LDAP), and objects interested in some events register for them
with a "discriminator" . But that may be overkill in many cases
(although it's necessary when the objects are distributed over a
network).

--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Aug 3 '08 #4
James Kanze <ja*********@gm ail.comwrote:
"Daniel T." <danie...@earth link.netwrote:
"Angus" <nos...@gmail.c omwrote:
My thinking is I would need to use some sort of polymorphic
interface class. Is this idea along the right lines:
Probably not. I would only do the above is I had to change
hardware at runtime and I have a feeling that isn't the case.

The original poster didn't specify what his program was doing, but
polymorphic interfaces were certainly an important part of the
telephone systems I worked on. First, because you normally connect
more than one piece of equipment to the system, the various
equipment will be of different types, and you want to handle them
identically. And secondly, you're not allowed to shut the system
down, even when upgrading equipment. (The hardware is specially
designed so that you can safely remove a PCB and insert another
without removing power, or even stopping operations on other PCB's
on the same bus. Don't try that on your PC, however.)
That is a different problem than what I was trying to solve. If the OP
does need to deal with hot-swappable hardware, then my post may not
apply.
One option that I consider better is a variation of the
handle-body or pimpl idiom.

*IF* you just have one type per instance of the program, why
bother. Just define one header file, as many source files (or
libraries) as needed, and link in the appropriate one.
That's exactly what I'm suggesting in that case.
Aug 3 '08 #5

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

Similar topics

43
4834
by: grz02 | last post by:
Hi, Im an experienced database+software designer and developer, but, unfortunately, anything to do with web-programming and web-systems designs is still a pretty new area to me... (been working mostly with "legacy" environments the last 10 years) So I am writing this, hoping to get some useful advise and feedback... I have done some pretty trivial, small websites with html/PHP,
7
1195
by: Richard Pope | last post by:
I have some existing code that I am trying to upgrade to c++. The data in question is two bytes, which are used to identify what information is requested from an industrial computer (a PLC). The first few bits represent the "category" of the data, and determine how the rest of the two bytes are interpreted. The existing code extracts various details from the data, but always uses a switch statement on the category. I could write a...
4
1859
by: Shaurya Anand | last post by:
I would like to know more about Interfacing hardware devices through .NET. We're students and what we're trying to do is control our robots with printer or serial port interfacing... very similar to C++ classic style. Please help us as it could do great wonders for our project.
10
2128
by: Saso Zagoranski | last post by:
hi, this is not actually a C# problem but since this is the only newsgroup I follow I decided to post my question here (please tell me where to post this next time if you think this post shouldn't be here). I have two design questions: 1. what is the correct (or best) way to include database queries into the code if you plan on
29
3562
by: MP | last post by:
Greets, context: vb6/ado/.mdb/jet 4.0 (no access)/sql beginning learner, first database, planning stages (I think the underlying question here is whether to normalize or not to normalize this one data field - but i'm not sure) :-) Background info:
6
2391
by: dev | last post by:
hi i want to know about interfacing or accessing a serial port using c-program please help me with an example thanks for whom who reply me soon
2
1336
by: Rajesh | last post by:
HI, I am newer person in VB development, any one guide me for hardware interfacing in VB. Thanks.
0
2502
by: YellowFin Announcements | last post by:
Introduction Usability and relevance have been identified as the major factors preventing mass adoption of Business Intelligence applications. What we have today are traditional BI tools that don't work nearly as well as they should, even for analysts and power users. The reason they haven't reached the masses is because most of the tools are so difficult to use and reveal so little
6
1959
by: abcd | last post by:
I have 13 yrs experience working from Visual Studio 1.x today VS 2005 (both VB and C++) Most of the time I have worked in N-tier applications, Web applications, Windows applications....My company is a small company very limited budget..We have enterprise web products written in VB/VC++, class ASP. We have not even used .NET etc. Lots of people are talking about Design patterns, standard architecture (SOS or other IBM). I am very...
0
8347
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8275
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
8694
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7294
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
6157
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
5605
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
4143
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...
1
1905
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1585
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.