Slashdot Mirror


Web Interfaces for C++ Introspection?

Milo_Mindbender asks: "For a C++ application I'm working on I want to be able to pop up an interface to a class that will display all the 'tunable' parameters of the class and let me inspect/modify them, while the program is running. The catch is that I'm running on a minimal embedded OS with Open GL but no GUI library. Rather than porting a widget set or writing my own, I was thinking about having the application talk to a web browser, and then use the browser to display the GUI, take user input, and finally push the data back to the app. The classes have metadata that describes the public data locations/types so they can be accessed, but not being a web-wizard I'm not sure of the best way of generating the information I need to create the UI. My first thought is to generate HTML and push that to the browser, but it seems like there must be a better way than this, maybe someone has written a library specifically for doing this sort of thing? Any help/suggestions would be appreciated!"

6 of 66 comments (clear)

  1. Why GUI by the+eric+conspiracy · · Score: 3, Insightful

    Any particular reason that it has to be a GUI? Something like an ncurses interface might be a lit easier.

    1. Re:Why GUI by billcopc · · Score: 2, Insightful

      I second this opinion. Remote debugging or "tuning" could be rather easily done from a serial terminal. There's no need for an HTTP protocol and the sloppy hassle of HTML forms; just a quick text console, not unlike those found in games such as Quake.

      get myvar, set myvar xxyy, toggle myvar, listvars etc etc

      Yeah, web interfaces are nice for end-users, but since you just want to debug your own one-off app and it's quite likely you will be the only person doing it, might as well be lazy - I mean efficient - and code the simplest interface possible, as long as it does what you need.

      --
      -Billco, Fnarg.com
  2. This question is odd.... by Manip · · Score: 2, Insightful

    I find this question somewhat odd... The guy clearly knows C++ and is able to develop on an embedded OS which isn't an easy thing to do but yet can't write himself a simple web-server, which a lot of us learnt during our first few years of programming in something nooby like VBA or Java...

    So either he isn't being completely accurate in so much that he might not be as knowledgeable as he claims or just by freak chance managed never to write a web-server in a couple of hours like everyone else...

    1. Re:This question is odd.... by Omnifarious · · Score: 3, Insightful

      Well, I didn't assume he was asking how to write an http server. I assumed he was looking for introspection facilities like Java's, which C++ doesn't have. I wish it did. typeinfo could be that if any compiler manufacturer implemented a rich enough set of extensions to it.

      It would be nice to get, at runtime, a list of pointers to functions a class supported as well as their names and type signatures. It would also be nice to be able to get a list of members and their types and their offsets from the beginning of the class.

  3. Well, you don't necessarily need a web browser... by FooAtWFU · · Score: 2, Insightful
    Instead of embedding a mini HTTP server into your application so it can talk to an application, you could just write a GUI in your favorite language (Java? C++? Java?) and talk to it with good old-fashioned TCP/IP (or even UDP) network sockets. Probably a lot simpler to define your own stuff than to deal with a big old standard like HTTP and parsing all the browsers which may be mangling your requests.

    If it must be accessible via the web/intranet/browser/etc, set up some of your favorite CGI/PHP/JSP/Python/Ruby and have it talk to the application via TCP/IP and to the browser with HTTP.

    --
    The World Wide Web is dying. Soon, we shall have only the Internet.
  4. What about ICE or CORBA? by motus · · Score: 3, Insightful
    I think the challenge here is not how to represent the data visually (i.e. web/GUI), but how to control a C++ object from the remote application. For that puropse, I would suggest CORBA. You can define all controllable classes in CORBA IDL, compile it into C++ code and integrate with your existing application with minimum efforts. CORBA client should not necessarily written in C++ - it can be Java or Python, for example. I have very good experience with omniORB (http://omniorb.sourceforge.net/). It supports both C++ and Python, and I use a bunch of Python scripts as a test harness for my C++ CORBA services. Besides omniORB, there are lots other decent implementations of CORBA in many programming languages (http://www.omg.org/technology/corba/corbadownload s.htm).

    PS. Good alternative to CORBA is ICE (http://www.zeroc.com/ice.html), which is basically the same thing as CORBA, and founded by one of the CORBA gurus. ICE has much better C++ mapping, and lots of other nice features.

    Hope this helps!