Solved

C++/XML Design Question

Posted on 2006-07-03
3
294 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
A short article about a problem I had getting the GPS LocationListener working.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now