Structuring an Application Programming Interface

Posted on 2008-11-15
Medium Priority
Last Modified: 2012-05-05
Trying to put together an Application Programming Interface given the following:

Communication Protocol:
General Purpose IO (GPIO)
Discrete Inputs

Now Ethernet and GPIO could be classified as 'Debug' aids/functionality - if you will.

So I have a Subject and four Listeners.  Subject and Listener act as -users if you will of the abovementioned protocols.  
  GPIO,  Enet (Debugging Aids)
  GPIO,  Enet (Debugging Aids)

Lastly, the code executes in two environments... Real Hardware (memory is mapped to FPGA addresses) or Simulation (using PC memory).  This leads me to:


How could I structure this in real source?  Seems like the potential for a host of inheritance looms large.    If you could structure this using example source that would be great.  i.e
      class Base {};  class Derived : public Base {} ;
Except use the names given above.

Question by:forums_mp
  • 3
LVL 39

Accepted Solution

itsmeandnobodyelse earned 200 total points
ID: 22993456
>>>> So I have a Subject and four Listeners.
Normally you call it Server and Clients.

>>>> How could I structure this in real source?
You have to decide if you really want to make a design based on hardware or kernel protocols. Actually I never experienced such a design in the last 20 years or more. Look at Windows operation system. Since NT it has a 'hardware abstraction layer' HAL which make all services independent from hardware but put that task to special drivers. Same thing for network communication. Normal TCP/IP has 7 layers where there is rarely a need to dice deeper than layer 6. Ethernet would be at layer 2 if I remember rightly. Even a peer-to-peer connection using the Internet was not fully build up from scratch programmatically but requires a bundle of services or tools which make the application programming independent of any hardware, protocols or memory addresses. So you can test a peer-to-peer at one single local computer by only changing names and without any knowledge of any physical or system logical settings and environments.

Author Comment

ID: 23000728
The design will be structured around hardware protocol.  I suspect I could have two special drivers; one to talk with the memory map of the FPGA and the other to deal with PC memory (when I'm in a simulation environment .. it's PC memory).  

Author Comment

ID: 23000735
Come to think of it I guess the special drivers (reading your post again) would be the ethernet/GPIO etc. Correct?  Just trying to create a class diagram in my - if you will - head

Author Comment

ID: 23053402
I have a question for you.  Referencing the link:


With regards to your trace class.  You said: "Tell me if you need some of these functions.", then you later alluded to the trace utility in C that you later advanced to C++.  Is it possible for you to upload both the C and C++ version to this thread?   I was tempted to start another thread surrounding a logger class.  I did a search on the site and came across the 'simple C++ Logging' thread.  

Let me know.  Worse case I'll provide an email address where you could email source.   Lastly, I'll  increase the points

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question