Solved

C++/XML Design Question

Posted on 2006-07-03
3
305 Views
Last Modified: 2010-04-17
Cliffs at the bottom

I'm writing an automated test application that is connected to the test article via a network connection.  The application monitors output from the test article and needs to analyze the output in near real-time to determine pass/fail.

The nature of the software on the test article is such that new applications with different capabilities are developed frequently.  I need to provide a way for a test engineer to define tests that won't break with each new version (or will require minimal changes to my application).  Each new application will bring new or modified packets that I need to analyze.  

I have limited experience with XML and haven't coded heavily in C/C++ for about two years.  I was thinking about writing a XML structure for each packet type that defines the fields in the packet.  I would then allow the test engineers to create tests by defining specific values or acceptable ranges for a field on a packet by packet basis.

I hope I haven't lost you yet.  So the test that the engineer defines would itself be in xml format and loaded into my test application.  My test application contains classes for each packet type that contain members for each field in the packet.  Now as packets are received I turn them into objects.  I want to somehow be able to look at the test specification (the XML the test engineer provides) and check those fields that were specified.  For example, the test might contain:

Packet Type Box A:
Field powerOn - 1
Field temperature - 20 < X < 40

So when I see a Box A packet, I want to check the powerOn field and make sure it is a 1 and the temperature field to make sure it is between 20 and 40 degrees.  What I'm having difficulty with is coming up with a generic way for an object to look at the fields and determine which members it needs to check.  In Java, I could title the XML fields the same as class members and use reflection.  I'm not sure if there is similar functionality available in C++, or ideally there is a better way to do it.

Cliff Notes:
I have an XML file that contains fields that need to be checked in various classes.  I need a generic way for a class to pull any fields in the XML file associated with it and check the values in its data members.  I don't want to have to implement a specific method for each class that contains a massive if/else block that says if fieldA is in the xml file check data member A and if fieldB is in the xml file...  I want it to be able to be able to determine on its own that fieldA in the XML file maps to its internal fieldA.
0
Comment
Question by:mears11
3 Comments
 
LVL 27

Accepted Solution

by:
BigRat earned 500 total points
ID: 17042177
If the classes were implemented as active X objects where each property is implemented via a getter and putter you'd effectively have a reflection on the class. The XML file gets loaded into a DOM, each "level" would create an instance of that class associated with the level and you'd use the IDispatch Invoke mechanism to set the appropiate properties
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

770 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