idioskopos

idioskopos

idioskopos (Greek: idio- inward, within, private; -skopos look, aim, target) is a C++ library that simplifies (hopefully) the addition of object reflection and introspection to C++ classes.

Looking for RPMS?

RPMS for Fedora Core 5, 6 and 7 are available for i386, x86_64 and ppc in Fedora Extras (see the downloads page for links).


Idioskopos provides classes for implementing:

The approach taken is an intrusive approach. One advantage is that special preprocessors are not necessary; either for your own code, or for those that use your code. A disadvantage of an intrusive approach is just that; it's intrusive, meaning you must explicitly state what class members are properties and instantiate them in your constructors.

Why?

There are numerous libraries that provide object introspection, but are generally part of some framework such as:

There is at least one other open source library that provides property management; libpropc++ at: http://ex-code.com/propcpp/

Support for object reflection and introspection are 'hot' topics in C++ and already have some groups pushing for inclusion in the next ANSI/ISO C++ standard. If you're looking for more information on the subject, this might be a good starting point.

So, why does the world need yet another library supporting reflection and introspection? It probably doesn't, but the reason I decided to create one anyway was due to the fact that I was writing an application that needed support for reflection. After scouring Freshmeat, Sourceforge, the GNU Savannah, and the nonGNU Savannah as well as googling for a solution, I felt that the current approaches suffered from one of the following issues:

  1. Preprocessors; approaches such as that taken by QT and PUMA require a preprocessor that adds reflection support. This is probably the cleanest approach, but IMHO not as simple and straightforward if all you want is basic reflection/introspection support.
  2. Not free; If you take a look at the libpropc++ library the code is released under the LGPL, but the author's statements regarding what the LGPL means are wrong. I'm not trying to start a flame war, debate over libpropc++ or anything else. However, I will clarify that idioskopos is released under the LGPL and may be used in commercial applications without releasing the application source code as long as you comply with the provisions of the LGPL that permit this.

What?

The idioskopos library is based heavily on several concepts used in Gtkmm to wrap the gobject interface. However, it is a standalone library and depends only on libsigc++.

How?

The following illustrates the code necessary to create reflective properties: a static property x and a dynamic property y.

class Example: public Idioskopos::Object {
  public:
    Example::Example();

    Idioskopos::Property<double> x;
};

Example::Example():
  x(*this, "x", 2.0),
{
  create_property<double>("y", 1.0);
}

Introspection can be accomplished using the iterators provided by Idioskopos::Object:

Example ex;
Idioskopos::Object::iterator i;

cout << "All properties in class Example:\n";
for (i = ex.properties_begin(); i != ex.properties_end(); i++)
   cout << "  " << i->name()
        << "  Type: " << i->type().name()
        << "  Value: " << i->value()
        << std::endl;

SourceForge.net Logo     Support This Project     Valid XHTML 1.0!