C++ introspection library and portable industrial graphical components for GPL and commercial use
Hi,
I’ve just found out two libraries which seem to be very interesting.
The first, CAMP, is an introspection library for C++. It appears to be well-thought and easily usable in concrete projects. Indeed, it isn’t (at all !) intrusive, which means you don’t have to modify existing classes to expose them to introspection. The example given in the documentation will be better than my words to explain that :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | #include <camp/camptype.hpp> #include <camp/class.hpp> #include <string> #include <iostream> // Let's define a class for handling persons class Person { public: // Construct a person from its name Person(const std::string& name) : m_name(name), m_age(0) { } // Retrieve the name of a person std::string name() const { return m_name; } // Retrieve the age of a person unsigned int age() const { return m_age; } // Set the age of a person void setAge(unsigned int age) { m_age = age; } // Make a person speak (tell about its name and age) void speak() { std::cout << "Hi! My name is " << m_name << " and I'm " << m_age << " years old." << std::endl; } private: std::string m_name; unsigned int m_age; }; // Make the Person type available to CAMP CAMP_TYPE(Person); int main() { // Bind our Person class to CAMP camp::Class::declare<Person>("Person") .constructor1<std::string>() .property("name", &Person::name) .property("age", &Person::age, &Person::setAge) .function("speak", &Person::speak); // Retrieve it by its name const camp::Class& metaclass = camp::classByName("Person"); // Construct a new person named John Person* john = metaclass.construct<Person>(camp::Args("John")); // Print its name std::string name = metaclass.property("name").get(john); std::cout << "John's name is: " << name << std::endl; // Set its age to 24 metaclass.property("age").set(john, 24); // Make John say something metaclass.function("speak").call(john); // Kill John metaclass.destroy(john); return 0; } |
The key part here is CAMP_TYPE(your_class). It exposes your_class to the introspection engine. Then, you bind anything you want from your class to the introspection engine, and you can play with all the CAMP API.
There’s also GICS, a portable library of industrial graphical components. Here are some screenshots :
![]()
![]()
Since it is based on Qt 4.5 and its QGraphicsView module, it is very efficient, scalable and easy to use. One can rely on that since Qt’s popularity and use is increasing, day after day.
Both are double-licensed : GPL and Commercial, depending on your usage. More informations and download links can be found on the products page of Tegesoft : http://www.tegesoft.com/products
I’m happy to see such good libraries, written in good C++, available under GPL !



Leave a Comment