Introspectable properties in C++

I'm working on a C++ project on my free time, and there's one thing I miss about this language : introspection.

The case is quite common : I want to access my object's properties dynamically, for example when I need to serialize or deserialize them. Being a great fan of Objective-C, I basically wanted to access my attributes as Objective-C Key Value Coding compliant properties :

object.getValueForKey("key");
object.setValueForKey("key", value);

I also wanted to keep this access method independent from the internal representation of the property (which basically means that I just want to provide a getter and setter method).

Obviously no such mecanism exists in C++, and the goal was to build a generic solution that could be applied to all my objects.

Continue reading

Conceptoire 2.0

Even if I don't update this site really often (yes, you can consider that an euphemism), I spent some time to upgrade it, both on the design side and on the code.
The changes includes :

  • Installing a rich text editor (fck editor) for the back-office.
    (maybe it will help me to post more often !)
  • Upgrading to Rails 2.1.1.
    Le passage à Rails 2 s'était un peu fait dans l'urgence, et pas mal de choses marchaient mal.
  • Leaving from ERB to HAML for the rendering engine (partial, there's still some ERB but Rails allows an easy cohabitation).
  • Used SASS to write my CSS.
    Very handy when it comes to write a flexible layout using the em unit, instead of a fixed layout using pixels or points.
    Give it a try, increase or decrease the font size on this page !
  • CSS3 !
    Internet Explorer users are definetely left behind. This website is the opportunity for me to try some of the cool stuff presents in upcoming standards. I must say it's pretty awesome.

Recommended browsers : Safari 3 or greater, Chrome, Firefox 3. Opera should be ok, I'll check that soon.

Configuring a NSToolbar

Introduced with Leopard was Interface Builder 3 (IB3), which finally included support to include NSToolbar design in nib (or xib – the new trendy format) files.

Yes. But.

Following Apple documentation, I added a NSToolbar instance to my document window, and customized it with some NSToolbarItems. As expected, it works great, my toolbar items have custom icons and calls the specified action.

The problem occurred as I wanted to make some of these items “selectable” – meaning they would have a mode-selection behavior. The thing is IB3 doesn’t provide a way to set this property in its interface. The way to do this is to specify a delegate for the toolbar and override

- (NSArray *)toolbarSelectableItemIdentifiers: (NSToolbar *)toolbar;

The name of this method is pretty much self explanatory, but I hadn’t specified any item identifiers for my custom toolbar items in IB, because this essential property is nowhere to be found ! Looking at the xib file directly in a text editor, it looks like IB generates a hash-code for each custom toolbar item to use as its identifier. This makes it impossible (or at least darn difficult) to programmatically retrieve or use these items.

In the end I had to configure manually my toolbar’s content by loading a plist file which did more or less the work of the xib file : hold the configuration of my toolbar, but allowing me to specify which items were selectable. And it works great, except that I can’t visualize the content of my toolbar at design-time.

Now I have one more question to ask the Apple engineers at WWDC ;-)

You can read some code on the full-post.

Continue reading

Google Maps API calls from Cocoa

This is the first post of a serie in which I will present some useful (and often trivial) stuff I’m implementing in Cocoa for my (hopefully) upcoming app.

The basic idea is to present short snippets of code to do something.

In this case, to get a Google Static Map representing the world (but could be refactored easily to customize the view) in an NSImage object.

The code is available on the full post.

Continue reading

There's something in the Air

Allright ... it's late, I will translate at least two posts this week-end. Promise.

Java Enterprise Edition

Alright, that's two french only posts in a row ... I'm sure you'll be able to read them some day between now ... and later.

Paris on Rails 2007 : Tools, Internationalization and Views

Translation coming when it's done (sorry guys)

I'm back !

Two months ...
Two months without internet (at least at home ... but you can't really do much when you're in lab at the university). I must say it's been hard and depressing.

Following are some thoughts in regard of how I felt during this period.

Continue reading

Routes and Rails

When I designed this website, I wanted to keep a classic pages hierarchy like /projects/conceptoire.com/subsection/... .
Here is what went wrong, and what worked.

Continue reading

Resolutions

Alright, let's try to do something with this blog. I'll try to note posts during the week and put them online when I can use the university's connection. Additionally, I'll try to post more into the projects section, this will be more interesting than my offline life. On the DSL front, there's still a technical interventions going on to figure out why my modem won't synchronize (the modem is fine by the way ... somebody's shoe must have caught a wire between my home and the central). I've nearly lost all hopes to have a working internet connection before my the end of the year.