Link to home
Start Free TrialLog in
Avatar of mears11
mears11

asked on

C++/XML Design Question

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.
ASKER CERTIFIED SOLUTION
Avatar of BigRat
BigRat
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial