Overview
Features
Download
Documentation
Community
Add-Ons & Services

Introspection.

Discussion of ideas for features and new projects based on POCO.

Introspection.

Postby axilmar » 02 Dec 2011, 20:20

I apologize if this has already been posted, but the word 'introspection' doesn't bring any search results in this section of the forum. I also did not find anything in the presentations about introspection, so I assume Poco doesn't have any. Please feel free to correct me.

Anyway, on to the wish: sometimes it is necessary to be able to do actions on code that are defined by runtime parameters; for example, invoking a function by name, getting the fields and methods of a class, walking the inheritance tree, examining the properties of an object, etc. This can be done by introspection, of which C++ does not offer any.

One of the very useful things introspection could do for us is to allow us to convert values from enumerations to integers in a safe manner, as well as automatically discover the names of the values of an enumeration, its minimum and maximum value, the number of values, etc.

I think that the C preprocessor could be 'abused' in some way, along with templates, to provide us a little framework within Poco that can be used to manually provide introspection for our objects.

What do you Poco users think?
axilmar
 
Posts: 8
Joined: 02 Dec 2011, 19:42

Re: Introspection.

Postby guenter » 03 Dec 2011, 17:23

I don't think the preprocessor would be the right tool for that. Using the CppParser library (can be found in the SVN sandbox) or, even better, Clang, and generating meta information from that may be a better approach.
guenter
 
Posts: 1165
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: Introspection.

Postby rakesh » 05 Dec 2011, 05:12

I have successfully used CERN Reflex for introspection.
rakesh
 
Posts: 78
Joined: 13 Apr 2011, 17:43
Location: Chicago

Re: Introspection.

Postby axilmar » 05 Dec 2011, 13:40

I agree that the preprocessor might not be the right approach, but using an external tool like Reflex or the cppparser, means that the tool has to be integrated with existing toolsets, which is very difficult and time consuming and error prone for some toolsets.

It is fine when, for example, a project is setup to be compiled via makefiles, but not so fine if the project is to be compiled with an IDE which does not support the tool, like Code::Blocks, Visual Studio and QtCreator.

Visual Studio allows the user to setup an existing tool to be used on each source code file, but I am not sure if any other IDE has the same functionality.

I think that any solution that does not take into account the tools users use will be doomed to fail.

It might even be a better solution to provide the introspection manually, for the required classes, in the form of static constant variables, because this will work across all tools.
axilmar
 
Posts: 8
Joined: 02 Dec 2011, 19:42

Re: Introspection.

Postby rakesh » 06 Dec 2011, 00:04

I use QT Creator for all my projects. I have a dumb script that I conditionally enable to generate the reflex files. In future, I will probably start comparing header file time stamps and the reflex file timestamp to determine whether genreflex is to be run or not, so I can run the reflex generation script unconditionally when the IDE builds. It is a manual process at present, but works.
rakesh
 
Posts: 78
Joined: 13 Apr 2011, 17:43
Location: Chicago


Return to Wishlist

Who is online

Users browsing this forum: No registered users and 1 guest