<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Sanderson Coelho</title>
	<atom:link href="http://sandersoncoelho.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://sandersoncoelho.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Mon, 20 Apr 2009 18:22:23 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='sandersoncoelho.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/9c48173df23c78acd9d18533446466ca?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Sanderson Coelho</title>
		<link>http://sandersoncoelho.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://sandersoncoelho.wordpress.com/osd.xml" title="Sanderson Coelho" />
		<item>
		<title>Reflection in Qt</title>
		<link>http://sandersoncoelho.wordpress.com/2009/04/15/reflection-in-qt/</link>
		<comments>http://sandersoncoelho.wordpress.com/2009/04/15/reflection-in-qt/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 20:45:34 +0000</pubDate>
		<dc:creator>Sanderson Coelho</dc:creator>
				<category><![CDATA[Qt]]></category>

		<guid isPermaLink="false">http://sandersoncoelho.wordpress.com/?p=15</guid>
		<description><![CDATA[Reflection is a thecnical that lets us to handle object  indirectly by a meta object. It is particular kind of metaprogramming.
This program concept was born from object-oriented program(OOP), on every entity is handled as classes and objects are instances
of those. So, as everything in OOP is an object, A class can be treat as an [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sandersoncoelho.wordpress.com&blog=7286314&post=15&subd=sandersoncoelho&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Reflection is a thecnical that lets us to handle object  indirectly by a meta object. It is particular kind of metaprogramming.<br />
This program concept was born from object-oriented program(OOP), on every entity is handled as classes and objects are instances<br />
of those. So, as everything in OOP is an object, A class can be treat as an object too. This object is known as metaobject. With the<br />
metaobject we can manipulate every feature related to that class, like its consctructor, methods, attributes, and so on.<br />
In this post, I would like to share a little dificult that I had to use reflection concept in Qt. It is just a &#8220;HelloWorld&#8221; example.<br />
So, lets to the example!</p>
<p>For this example, I just implemented person.h, person.cpp and main.cpp. Below, it is the code and some commentaries.</p>
<p><strong>person.h</strong></p>
<pre>/*
 * Here, we implemented Person class. In Qt, to use reflection, it is necessary
 * that class inherits QObject and uses Q_OBJECT macro. The inheritance due QObject
 * class provides staticMetaObject member. This is the meta object for our class.
 * With the Q_OBJECT macro, the meta object compiler(moc) creates another C++
 * source file where is implemented meta object code.
 */

#ifndef PERSON_H
#define PERSON_H

#include &lt;QObject&gt;

class Person : public QObject
{
	Q_OBJECT

public:
	Q_INVOKABLE Person(QString nome);
	QString getName();

private:
	QString _name;
};

#endif // PERSON_H</pre>
<p><strong>person.cpp</strong></p>
<pre>/*
 * Implementation of Person class.
 */
#include "person.h"

Person::Person(QString name)
{
	_name = name;
}

QString Person::getName()
{
	return _name;
}</pre>
<p><strong>main.cpp</strong></p>
<pre>/*
 * Main program.
 */
#include &lt;QMetaObject&gt;
#include &lt;QDebug&gt;
#include "person.h"

void anyMethod(QMetaObject metaObject)
{
	//We invoke the Person constructor through metaObject.
	Person *person = (Person *)metaObject
		.newInstance(Q_ARG(QString, QString("Sanderson")));
	QString name = person-&gt;getName();
	qDebug() &lt;&lt; "Name: " &lt;&lt; name;
}

int main()
{
	//Meta object to Person class. It is not a Person instance.
	anyMethod(Person::staticMetaObject);
	return 0;
}</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sandersoncoelho.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sandersoncoelho.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sandersoncoelho.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sandersoncoelho.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sandersoncoelho.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sandersoncoelho.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sandersoncoelho.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sandersoncoelho.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sandersoncoelho.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sandersoncoelho.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sandersoncoelho.wordpress.com&blog=7286314&post=15&subd=sandersoncoelho&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://sandersoncoelho.wordpress.com/2009/04/15/reflection-in-qt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/02fb1bdd6278acf01b90cebec06b6859?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sanderson Coelho</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting/Sending a dictionary through dbus with Qt</title>
		<link>http://sandersoncoelho.wordpress.com/2009/04/08/gettingsending-a-dictionary-through-dbus-with-qt/</link>
		<comments>http://sandersoncoelho.wordpress.com/2009/04/08/gettingsending-a-dictionary-through-dbus-with-qt/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 18:38:56 +0000</pubDate>
		<dc:creator>Sanderson Coelho</dc:creator>
				<category><![CDATA[Qt]]></category>

		<guid isPermaLink="false">http://sandersoncoelho.wordpress.com/?p=3</guid>
		<description><![CDATA[A little about DBus
DBus is message bus system, where applications can exchange information. This information can be, numbers, data structures, called function or just simple messages. By default there are two standard buses: session bus and system bus.
Session bus: It is generally used by desktop applications.
System bus: It used to the traffic of messages from [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sandersoncoelho.wordpress.com&blog=7286314&post=3&subd=sandersoncoelho&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-indent:0;margin:0;"><strong>A little about DBus</strong></p>
<p style="text-indent:0;margin:0;">DBus is message bus system, where applications can exchange information. This information can be, numbers, data structures, called function or just simple messages. By default there are two standard buses: session bus and system bus.</p>
<p style="text-indent:0;margin:0;">Session bus: It is generally used by desktop applications.</p>
<p style="text-indent:0;margin:0;">System bus: It used to the traffic of messages from the operating system kernel.</p>
<p style="text-indent:0;margin:0;">In this post, I&#8217;ve tried to explain how to call a remote function that returns a dictionary structure.</p>
<p style="text-indent:0;margin:0;">
<div id="attachment_7" class="wp-caption alignnone" style="width: 442px"><img class="size-full wp-image-7" title="dbus-dictionary" src="http://sandersoncoelho.files.wordpress.com/2009/04/dbus-dictionary.png?w=432&#038;h=415" alt="Scheme with applications and bus session." width="432" height="415" /><p class="wp-caption-text">Scheme with applications and bus session.</p></div>
<p style="text-indent:0;margin:0;"><strong>Connecting dbus session</strong></p>
<p style="text-indent:0;margin:0;">To connect to DBus system, is needed to inform the system bus and the bus name. Bus name is name of the available service.</p>
<p style="text-indent:0;margin:0;">It is something like org.mycompany.service.</p>
<p style="text-indent:0;margin:0;">conn = QDBusConnection(QDBusConnection::connectToBus(QDBusConnection::SessionBus, DBUS_BUS_NAME));</p>
<p style="text-indent:0;margin:0;"><strong>Getting the interface</strong></p>
<p style="text-indent:0;margin:0;">After connect to the bus, it must obtein the interface object, to send/receive message trough bus. To achieve this goal, the bus name, path object and interface name must be informed.</p>
<p style="text-indent:0;margin:0;">QDBusInterface iface(DBUS_BUS_NAME, DBUS_OBJECT_PATH, DBUS_INTERFACE, conn); p, li { white-space: pre-wrap; }</p>
<p style="text-indent:0;margin:0;"><strong>Getting the dictionary</strong></p>
<p style="text-indent:0;margin:0;">Invoque the remote method GetOptions returning a dictionary to reply variable.</p>
<p style="text-indent:0;margin:0;">QDBusReply&lt;QVariantMap&gt; reply = iface.call(&#8220;GetOptions&#8221;);</p>
<p style="text-indent:0;margin:0;"><strong>Setting the dictionary</strong></p>
<p style="text-indent:0;margin:0;">Invoke the remote method SetOptions, passing a dictionary as argument.</p>
<p style="text-indent:0;margin:0;">iface.call(&#8220;SetOptions&#8221;, protocolOptions);<!--EndFragment--></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/sandersoncoelho.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/sandersoncoelho.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/sandersoncoelho.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/sandersoncoelho.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/sandersoncoelho.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/sandersoncoelho.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/sandersoncoelho.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/sandersoncoelho.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/sandersoncoelho.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/sandersoncoelho.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=sandersoncoelho.wordpress.com&blog=7286314&post=3&subd=sandersoncoelho&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://sandersoncoelho.wordpress.com/2009/04/08/gettingsending-a-dictionary-through-dbus-with-qt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/02fb1bdd6278acf01b90cebec06b6859?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sanderson Coelho</media:title>
		</media:content>

		<media:content url="http://sandersoncoelho.files.wordpress.com/2009/04/dbus-dictionary.png" medium="image">
			<media:title type="html">dbus-dictionary</media:title>
		</media:content>
	</item>
	</channel>
</rss>