Solved

C++/XML Design Question

Posted on 2006-07-03
3
308 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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…

734 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