<?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/"
	>

<channel>
	<title>Coding My Thoughts &#187; CLAPP</title>
	<atom:link href="http://marianoiglesias.com.ar/category/c/clapp/feed/" rel="self" type="application/rss+xml" />
	<link>http://marianoiglesias.com.ar</link>
	<description>A glimpse at a coder&#039;s troubled mind</description>
	<lastBuildDate>Wed, 06 Jan 2010 19:25:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>New fun project: a C++ Web Framework</title>
		<link>http://marianoiglesias.com.ar/c/new-fun-project-a-c-web-framework/</link>
		<comments>http://marianoiglesias.com.ar/c/new-fun-project-a-c-web-framework/#comments</comments>
		<pubDate>Sat, 07 Feb 2009 19:37:00 +0000</pubDate>
		<dc:creator>mariano</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[CLAPP]]></category>

		<guid isPermaLink="false">http://marianoiglesias.com.ar/1/new-fun-project-a-c-web-framework/</guid>
		<description><![CDATA[<p>As a true programmer, I need fun projects to stay alive. Don&#8217;t get me wrong, my client work fulfills me, and eventhough I&#8217;ve been slacking lately in keeping up with its workload, CakePHP is also a lot of fun. However,&#8230;</p>


No related posts.]]></description>
			<content:encoded><![CDATA[<p>As a true programmer, I need fun projects to stay alive. Don&#8217;t get me wrong, my client work fulfills me, and eventhough I&#8217;ve been slacking lately in keeping up with its workload, CakePHP is also a lot of fun. However, true programmers are always looking for a fun project, one they can call their own. Meet CLAPP, a C++ MVC Web Framework.</p>
<p>I am not even close to finishing it, but so far I&#8217;m having LOTS of fun. What is amazing is that missing only the M in MVC (the database abstraction layer), CLAPP&#8217;s performance is already astonishing. Running as <a href="http://www.fastcgi.com" rel="nofollow" >FastCGI</a>, it outperforms the most basic PHP file by a ratio of 1000%. Amazing.</p>
<p>So what am I looking to gain from this? Nothing, just having fun going back to my absolute favourite language: C++. In the meantime, I get to play with speed comparisons, which gets particularly interesting as I enable more stuff in the framework. My ideal goal is to include a lot of the you-just-have-to-have-this kind of things available on real, serious frameworks such as <a href="http://www.cakephp.org" rel="nofollow" >CakePHP</a>. This doesn&#8217;t mean that I will hereon start developing every web application in C++, that would just be dumb (if you are asking why, then that&#8217;s because you haven&#8217;t given CakePHP a try). It does mean, however, that I&#8217;ll be posting about CLAPP every now and then.</p>
<p>To calm your expectations, here&#8217;s a very, VERY small preview of the Dispatcher, which is directly attached to every controller:</p>
<pre name="code" class="cpp">#ifndef __CLAPP_DISPATCHER_HPP
#define __CLAPP_DISPATCHER_HPP

#include &lt;clapp/cgi_stream.h&gt;
#include &lt;clapp/controller.h&gt;

namespace clapp {
	template &lt;class C&gt;
	class Dispatcher {
		public:
			Dispatcher();
			~Dispatcher();
			void dispatch();

		private:
#ifdef CLAPP_WITH_FASTCGI
			CgiStreamFastCgi * cgiStream;
#else
			CgiStream * cgiStream;
#endif

			void execute();
	};
}

template &lt;class C&gt;
clapp::Dispatcher&lt;C&gt;::Dispatcher() {
#ifdef CLAPP_WITH_FASTCGI
	this-&gt;cgiStream = new CgiStreamFastCgi();
#else
	this-&gt;cgiStream = new CgiStream();
#endif
}

template &lt;class C&gt;
clapp::Dispatcher&lt;C&gt;::~Dispatcher() {
	delete this-&gt;cgiStream;
}

template &lt;class C&gt;
void clapp::Dispatcher&lt;C&gt;::dispatch() {
#ifdef CLAPP_WITH_FASTCGI
	FCGX_Request request;

	FCGX_Init();
	FCGX_InitRequest(&amp;request, 0, 0);

	while (FCGX_Accept_r(&amp;request) == 0) {
		this-&gt;cgiStream-&gt;setRequest(request);
		this-&gt;execute();
		FCGX_Finish_r(&amp;request);
	}
#else
	this-&gt;execute();
#endif
}

template &lt;class C&gt;
void clapp::Dispatcher&lt;C&gt;::execute() {
	C *controller = NULL;

	try {
		controller = new C();

		controller-&gt;setStream(this-&gt;cgiStream);
		controller-&gt;dispatch();

		delete controller;
	} catch(...) {
		if (controller != NULL) {
			delete controller;
		}
		throw;
	}
}

#endif</pre>
<p>As you can guess from the source code, CLAPP can produce FastCGIs and regular CGIs. It uses <a href="http://www.clearsilver.net" rel="nofollow" >ClearSilver</a> for its view / layout templates, the <a href="http://www.fastcgi.com" rel="nofollow" >FastCGI development kit</a> (when FastCGI mode is enabled), and <a href="http://www.gnu.org/software/cgicc" rel="nofollow" >GNU cgicc</a> as a CGI / FastCGI input wrapper. More news coming soon!</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://marianoiglesias.com.ar/c/new-fun-project-a-c-web-framework/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk
Database Caching 12/32 queries in 0.042 seconds using disk

Served from: marianoiglesias.com.ar @ 2010-07-30 05:20:54 -->