<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-35128052</id><updated>2011-09-14T19:39:27.803+03:00</updated><category term='visual studio'/><category term='C++'/><category term='templates'/><category term='editor'/><category term='nothing much'/><category term='design patterns'/><category term='video conferencing'/><category term='indie gaming'/><category term='hello'/><category term='vc++'/><category term='mvc pattern'/><category term='tips'/><category term='code quality'/><category term='random thoughts'/><category term='synchronization'/><category term='status report'/><category term='multithreading'/><category term='projects'/><category term='observer pattern'/><category term='static polymorphism'/><category term='directshow'/><category term='life'/><title type='text'>Seasoned Hacker</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://neurorebel.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://neurorebel.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>neurorebel</name><uri>http://www.blogger.com/profile/06965524988672935344</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_JV83xeUju9w/SQeT73jPw_I/AAAAAAAAAA8/9PiYADflIO8/S220/Picture+5.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>15</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-35128052.post-3789339945355228502</id><published>2010-12-18T14:32:00.009+02:00</published><updated>2010-12-18T15:16:44.353+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='synchronization'/><category scheme='http://www.blogger.com/atom/ns#' term='multithreading'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>Locked internal resources (why it wouldn't work :) )</title><content type='html'>A few days ago I shared this evil template with you:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;template &lt;typename T, typename TLockable = boost::mutex&gt;&lt;br /&gt;class locked_object : boost::noncopyable&lt;br /&gt;{&lt;br /&gt; T *object;&lt;br /&gt; TLockable *lock;&lt;br /&gt; bool locked;&lt;br /&gt;&lt;br /&gt;public:&lt;br /&gt; locked_object(T *_object, TLockable *_lock) : object(_object), lock(_lock), locked(true)&lt;br /&gt; {&lt;br /&gt;  lock-&gt;lock();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; ~locked_object()&lt;br /&gt; {&lt;br /&gt;  lock-&gt;unlock();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; T *get()&lt;br /&gt; {&lt;br /&gt;  _ASSERT(locked);&lt;br /&gt;  if (!locked)&lt;br /&gt;   throw new std::exception("Synchronization error ! Object lock is already released !");&lt;br /&gt;  return this-&gt;object;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; void unlock()&lt;br /&gt; {&lt;br /&gt;  locked = false;&lt;br /&gt;&lt;br /&gt;  lock-&gt;unlock();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; T *operator -&gt;() const&lt;br /&gt; {  &lt;br /&gt;  _ASSERT(locked);&lt;br /&gt;  if (!locked)&lt;br /&gt;   throw new std::exception("Synchronization error ! Object lock is already released !");&lt;br /&gt;&lt;br /&gt;  return this-&gt;object; &lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; operator T *() const&lt;br /&gt; {&lt;br /&gt;  _ASSERT(locked);&lt;br /&gt;  if (!locked)&lt;br /&gt;   throw new std::exception("Synchronization error ! Object lock is already released !");&lt;br /&gt;&lt;br /&gt;  return this-&gt;object;&lt;br /&gt; }&lt;br /&gt;};&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I asked for advice on &lt;a href = "http://stackoverflow.com/questions/4449915/sharing-a-data-member-with-the-outside-world-in-a-thread-safe-manner"&gt;StackOverflow&lt;/a&gt; on the matter and got some very valuable input indeed. The problem with this class is that I trust the programmer to follow the semantics and the protocol of this template which are:&lt;br /&gt;&lt;br /&gt;* Never save the pointer for latter usage&lt;br /&gt;* Never use the object after you call locked_object&lt;&gt;::unlock()&lt;br /&gt;&lt;br /&gt;Well obviously this template solves nothing :) It doesn't &lt;span style="font-weight:bold;"&gt;prevent&lt;/span&gt; the programmer doing sinful things. The programmer might do his best to follow the intended protocol yet a small error may introduce a bug that is very hard to detect and/or reproduce.&lt;br /&gt;&lt;br /&gt;Moreover, I learned about the &lt;a href="http://en.wikipedia.org/wiki/Law_of_Demeter"&gt;Law of Demeter&lt;/a&gt; which implies you never should let anyone "dig the guts of an object" (How could you ever do that safely ? :) ). And with my naive and extremely faulty approach I now fully grasp the idea. The good thing is this class hasn't made its way into any production code.&lt;br /&gt;&lt;br /&gt;Let's close it with a meaningful saying;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;To rise from error to truth is rare and beautiful. &lt;br /&gt;Victor Hugo &lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35128052-3789339945355228502?l=neurorebel.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neurorebel.blogspot.com/feeds/3789339945355228502/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35128052&amp;postID=3789339945355228502' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/3789339945355228502'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/3789339945355228502'/><link rel='alternate' type='text/html' href='http://neurorebel.blogspot.com/2010/12/locked-internal-resources-why-it.html' title='Locked internal resources (why it wouldn&apos;t work :) )'/><author><name>neurorebel</name><uri>http://www.blogger.com/profile/06965524988672935344</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_JV83xeUju9w/SQeT73jPw_I/AAAAAAAAAA8/9PiYADflIO8/S220/Picture+5.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35128052.post-3559375081722478714</id><published>2010-12-14T16:26:00.013+02:00</published><updated>2010-12-18T15:15:31.384+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='synchronization'/><category scheme='http://www.blogger.com/atom/ns#' term='multithreading'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>Locked internal resources (digging the guts of your class safely)</title><content type='html'>&lt;span style="font-weight:bold;"&gt;Disclaimer: See &lt;a href="http://neurorebel.blogspot.com/2010/12/locked-internal-resources-why-it.html"&gt; this &lt;/a&gt; after reading.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Just stopped by to share this template class that I've written to expose internal data members of a class in a thread-safe manner.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;template &amp;lttypename T, typename TLockable = boost::mutex&amp;gt&lt;br /&gt;class locked_object : boost::noncopyable&lt;br /&gt;{&lt;br /&gt; T *object;&lt;br /&gt; TLockable *lock;&lt;br /&gt; bool locked;&lt;br /&gt;&lt;br /&gt;public:&lt;br /&gt; locked_object(T *_object, TLockable *_lock) : object(_object), lock(_lock), locked(true)&lt;br /&gt; {&lt;br /&gt;  lock-&amp;gtlock();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; ~locked_object()&lt;br /&gt; {&lt;br /&gt;  lock-&amp;gtunlock();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; T *get()&lt;br /&gt; {&lt;br /&gt;  _ASSERT(locked);&lt;br /&gt;  if (!locked)&lt;br /&gt;   throw new std::exception("Synchronization error ! Object lock is already released !");&lt;br /&gt;  return this-&amp;gtobject;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; void unlock()&lt;br /&gt; {&lt;br /&gt;  locked = false;&lt;br /&gt;&lt;br /&gt;  lock-&amp;gtunlock();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; T *operator -&amp;gt() const&lt;br /&gt; {  &lt;br /&gt;  _ASSERT(locked);&lt;br /&gt;  if (!locked)&lt;br /&gt;   throw new std::exception("Synchronization error ! Object lock is already released !");&lt;br /&gt;&lt;br /&gt;  return this-&amp;gtobject; &lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; operator T *() const&lt;br /&gt; {&lt;br /&gt;  _ASSERT(locked);&lt;br /&gt;  if (!locked)&lt;br /&gt;   throw new std::exception("Synchronization error ! Object lock is already released !");&lt;br /&gt;&lt;br /&gt;  return this-&amp;gtobject;&lt;br /&gt; }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Usage semantics are fairly easy. You keep your data &lt;span style="font-style:italic;"&gt;private&lt;/span&gt; and define an accessor e.g. &lt;span style="font-style:italic;"&gt;getData()&lt;/span&gt; and return a&lt;span style="font-style:italic;"&gt; locked_object&lt;&gt;&lt;/span&gt; from this method. When the&lt;span style="font-style:italic;"&gt; locked_object&lt;&gt;&lt;/span&gt; goes out of scope it will release the lock, letting other waiting threads reach the resource. You just have to pass a pointer to your data member and a pointer to a synchronization primitive that has &lt;span style="font-style:italic;"&gt;lock()&lt;/span&gt; and &lt;span style="font-style:italic;"&gt;unlock()&lt;/span&gt; methods. See the infamous example class &lt;span style="font-style:italic;"&gt;Foo&lt;/span&gt; sharing a file handle with several other threads.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="cpp" &gt;&lt;br /&gt;#include &amp;ltiostream&amp;gt&lt;br /&gt;#include &amp;ltfstream&amp;gt&lt;br /&gt;#include &amp;ltstring&amp;gt&lt;br /&gt;#include &amp;ltvector&amp;gt&lt;br /&gt;&lt;br /&gt;#include &amp;ltboost/shared_ptr.hpp&amp;gt&lt;br /&gt;#include &amp;ltboost/noncopyable.hpp&amp;gt&lt;br /&gt;#include &amp;ltboost/thread.hpp&amp;gt&lt;br /&gt;&lt;br /&gt;template &amp;lttypename T, typename TLockable = boost::mutex&amp;gt&lt;br /&gt;class locked_object : boost::noncopyable&lt;br /&gt;{&lt;br /&gt; T *object;&lt;br /&gt; TLockable *lock;&lt;br /&gt; bool locked;&lt;br /&gt;&lt;br /&gt;public:&lt;br /&gt; locked_object(T *_object, TLockable *_lock) : object(_object), lock(_lock), locked(true)&lt;br /&gt; {&lt;br /&gt;  lock-&amp;gtlock();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; ~locked_object()&lt;br /&gt; {&lt;br /&gt;  lock-&amp;gtunlock();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; T *get()&lt;br /&gt; {&lt;br /&gt;  _ASSERT(locked);&lt;br /&gt;  if (!locked)&lt;br /&gt;   throw new std::exception("Synchronization error ! Object lock is already released !");&lt;br /&gt;  return this-&amp;gtobject;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; void unlock()&lt;br /&gt; {&lt;br /&gt;  locked = false;&lt;br /&gt;&lt;br /&gt;  lock-&amp;gtunlock();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; T *operator -&amp;gt() const&lt;br /&gt; {  &lt;br /&gt;  _ASSERT(locked);&lt;br /&gt;  if (!locked)&lt;br /&gt;   throw new std::exception("Synchronization error ! Object lock is already released !");&lt;br /&gt;&lt;br /&gt;  return this-&amp;gtobject; &lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; operator T *() const&lt;br /&gt; {&lt;br /&gt;  _ASSERT(locked);&lt;br /&gt;  if (!locked)&lt;br /&gt;   throw new std::exception("Synchronization error ! Object lock is already released !");&lt;br /&gt;&lt;br /&gt;  return this-&amp;gtobject;&lt;br /&gt; }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;std::vector&amp;ltboost::thread&amp;gt thread_list;&lt;br /&gt;&lt;br /&gt;class Foo&lt;br /&gt;{&lt;br /&gt; boost::mutex out_lock;&lt;br /&gt; boost::shared_ptr&amp;ltstd::ofstream&amp;gt file;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public:&lt;br /&gt; Foo() : file(new std::ofstream("important_file.txt", std::ios::trunc))&lt;br /&gt; {&lt;br /&gt;  _ASSERT(file-&amp;gtis_open());&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; locked_object&amp;ltboost::shared_ptr&amp;ltstd::ofstream&amp;gt &amp;gt getOutLocked()&lt;br /&gt; {&lt;br /&gt;  return locked_object&amp;ltboost::shared_ptr&amp;ltstd::ofstream&amp;gt &amp;gt(&amp;file, &amp;out_lock);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; std::ofstream&amp; getOut()&lt;br /&gt; {&lt;br /&gt;  return *file;&lt;br /&gt; }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;Foo f;&lt;br /&gt;&lt;br /&gt;void fn_thread(int i)&lt;br /&gt;{&lt;br /&gt; /* Non thread safe */&lt;br /&gt; f.getOut() &amp;lt&amp;lt "What ";&lt;br /&gt; boost::this_thread::sleep(boost::posix_time::milliseconds(1));&lt;br /&gt; f.getOut() &amp;lt&amp;lt "can I do ";&lt;br /&gt; boost::this_thread::sleep(boost::posix_time::milliseconds(1));&lt;br /&gt; f.getOut() &amp;lt&amp;lt "sometimes ?\n" ;&lt;br /&gt; /*                */&lt;br /&gt;&lt;br /&gt; /* Thread safe&lt;br /&gt; locked_object&amp;ltboost::shared_ptr&amp;ltstd::ofstream&amp;gt &amp;gt lout = f.getOutLocked();&lt;br /&gt;&lt;br /&gt; (**lout) &amp;lt&amp;lt "What ";&lt;br /&gt; boost::this_thread::sleep(boost::posix_time::milliseconds(1));&lt;br /&gt; (**lout) &amp;lt&amp;lt "can I do ";&lt;br /&gt; boost::this_thread::sleep(boost::posix_time::milliseconds(1));&lt;br /&gt; (**lout) &amp;lt&amp;lt "sometimes ?\n" ; */&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt; for (int i = 0; i &amp;lt 50; ++i)&lt;br /&gt;  thread_list.push_back(boost::thread(boost::bind(fn_thread, i)) );&lt;br /&gt;&lt;br /&gt; for (std::vector&amp;ltboost::thread&amp;gt::iterator it = thread_list.begin(); it != thread_list.end(); ++it)&lt;br /&gt;  if (it-&amp;gtjoinable())&lt;br /&gt;   it-&amp;gtjoin();&lt;br /&gt;&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;When you run the above code as is, the threads will race for the file resource and the program will yield corrupt data like;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;What What What What What What What What What What can I do can I do can I do can I do can I do can I do can I do can I do What can I do What What What What What What What What What What What can I do What can I do can I do sometimes ?&lt;br /&gt;sometimes ?&lt;br /&gt;can I do can I do can I do sometimes ?&lt;br /&gt;sometimes ?&lt;br /&gt;can I do sometimes ?&lt;br /&gt;can I do can I do sometimes ?&lt;br /&gt;sometimes ?&lt;br /&gt;can I do can I do sometimes ?&lt;br /&gt;sometimes ?&lt;br /&gt;can I do can I do What What What What What What What What What can I do can I do sometimes ?&lt;br /&gt;sometimes ?&lt;br /&gt;sometimes ?&lt;br /&gt;sometimes ?&lt;br /&gt;sometimes ?&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In contrast, if you comment out the &lt;span style="font-style:italic;"&gt;Not thread safe&lt;/span&gt; block and make the &lt;span style="font-style:italic;"&gt;Thread-safe&lt;/span&gt;&lt;br /&gt;block active in the &lt;span style="font-style:italic;"&gt;fn_thread()&lt;/span&gt; function the output will be;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;What can I do sometimes ?&lt;br /&gt;What can I do sometimes ?&lt;br /&gt;What can I do sometimes ?&lt;br /&gt;What can I do sometimes ?&lt;br /&gt;What can I do sometimes ?&lt;br /&gt;What can I do sometimes ?&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;.&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;as expected. I would love to hear any opinions about the code and potential problems it may bring. What if our shared resource is not a simple handle but a complex tree structure where references to sub-nodes can be passed to other components of our program ? What synchronization issues would this locked_object&lt;&gt; pose ? How can we eliminate them ?&lt;br /&gt;&lt;br /&gt;Thank you for your time ! &lt;br /&gt;&lt;br /&gt;And as you all know; &lt;a href="http://www.youtube.com/watch?v=ccw8dQNAsmc"&gt;&lt;span style="font-style:italic;"&gt;Everything is something happens...&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Cheers!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35128052-3559375081722478714?l=neurorebel.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neurorebel.blogspot.com/feeds/3559375081722478714/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35128052&amp;postID=3559375081722478714' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/3559375081722478714'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/3559375081722478714'/><link rel='alternate' type='text/html' href='http://neurorebel.blogspot.com/2010/12/locked-internal-resources-digging-guts.html' title='Locked internal resources (digging the guts of your class safely)'/><author><name>neurorebel</name><uri>http://www.blogger.com/profile/06965524988672935344</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_JV83xeUju9w/SQeT73jPw_I/AAAAAAAAAA8/9PiYADflIO8/S220/Picture+5.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35128052.post-4103441612577350977</id><published>2010-06-26T10:59:00.027+03:00</published><updated>2010-06-26T13:15:33.221+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mvc pattern'/><category scheme='http://www.blogger.com/atom/ns#' term='design patterns'/><category scheme='http://www.blogger.com/atom/ns#' term='templates'/><category scheme='http://www.blogger.com/atom/ns#' term='static polymorphism'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><category scheme='http://www.blogger.com/atom/ns#' term='observer pattern'/><title type='text'>Observer pattern in C++ (without virtual functions)</title><content type='html'>Yesterday I was trying to implement the &lt;a href="http://en.wikipedia.org/wiki/Observer_pattern"&gt;observer pattern&lt;/a&gt; for use in a project of mine. The classes needed to be generic, type-safe, fast and easy to use. Asking too much ? Well no, not in the realm of C++ :) To retain type-safety I had to incorporate &lt;a href="http://en.wikipedia.org/wiki/Template_metaprogramming#Static_polymorphism"&gt;static polymorphism&lt;/a&gt; . That means &lt;span style="font-style:italic;"&gt;virtual functions&lt;/span&gt; were to be dumped for good... They force you to make dangerous type casts causing some nausea :) . This was the first thing that I typed into the editor without thinking :)&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="cpp"&gt; &lt;br /&gt;// A first and naive shot at the problem&lt;br /&gt;&lt;br /&gt;#include &amp;lt list&amp;gt&lt;br /&gt;#include &amp;lt boost/bind.hpp&amp;gt&lt;br /&gt;#include &amp;lt boost/function.hpp&amp;gt&lt;br /&gt;#include &amp;lt boost/foreach.hpp&amp;gt&lt;br /&gt;&lt;br /&gt;template &amp;lt typename TObserver, typename TSubject&amp;gt&lt;br /&gt;class observer&lt;br /&gt;{&lt;br /&gt;public:&lt;br /&gt; void observe(TSubject&amp; s)&lt;br /&gt; {&lt;br /&gt;  static_cast&amp;lt TObserver *&amp;gt(this)-&amp;gt do_observe(s);&lt;br /&gt; }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;template &amp;lt typename TObserver, typename TSubject&amp;gt&lt;br /&gt;class subject&lt;br /&gt;{&lt;br /&gt;public:&lt;br /&gt; typedef observer&amp;lt TObserver, TSubject&amp;gt observer_type;&lt;br /&gt;&lt;br /&gt;private:&lt;br /&gt; std::list&amp;lt observer_type *&amp;gt observers;&lt;br /&gt;&lt;br /&gt;public:&lt;br /&gt; typedef observer&amp;lt TObserver, TSubject&amp;gt observer_type;&lt;br /&gt;&lt;br /&gt; void add_observer(observer_type *po)&lt;br /&gt; { observers.push_back(po); }&lt;br /&gt;&lt;br /&gt; void remove_observer(observer_type *po)&lt;br /&gt; { observers.remove(po); }&lt;br /&gt;&lt;br /&gt; void notify_all()&lt;br /&gt; { &lt;br /&gt;  BOOST_FOREACH(observer_type *po, observers)&lt;br /&gt;  {&lt;br /&gt;   po-&amp;gt observe(*static_cast&amp;lt TSubject *&amp;gt(this));&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;};&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As with all "typing without thinking" practices, this piece of code yields a disappointment :) The idea is that your "concrete observer" will derive from the &lt;span style="font-style:italic;"&gt;observer&lt;/span&gt; class. So it will be parameterize with &lt;span style="font-style:italic;"&gt;its own type&lt;/span&gt; and the &lt;span style="font-style:italic;"&gt;subject type&lt;/span&gt; . The &lt;span style="font-style:italic;"&gt;subject &lt;/span&gt; template also needs - two - types to resolve the function call &lt;span style="font-style:italic;"&gt;observe()&lt;/span&gt; . But this means for each type of &lt;span style="font-style:italic;"&gt;observer&lt;/span&gt; you must define a new type of &lt;span style="font-style:italic;"&gt;concrete subject&lt;/span&gt;. &lt;br /&gt;&lt;br /&gt;e.g.&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;// Forward declaration&lt;br /&gt;class model;&lt;br /&gt;&lt;br /&gt;class view : public observer&amp;lt view, model&amp;gt&lt;br /&gt;{&lt;br /&gt;public:&lt;br /&gt; void do_observe(model&amp; m)&lt;br /&gt; {&lt;br /&gt;  std::cout &amp;lt &amp;lt  "view observed the model." &amp;lt &amp;lt  std::endl;&lt;br /&gt; }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;class controller : public observer&amp;lt controller, model&amp;gt&lt;br /&gt;{&lt;br /&gt;public:&lt;br /&gt; void do_observe(model&amp; m)&lt;br /&gt; {&lt;br /&gt;  std::cout &amp;lt&amp;lt  "controller observed the model." &amp;lt &amp;lt  std::endl;&lt;br /&gt; }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;// Here comes the problem..&lt;br /&gt;class model : public subject&amp;lt view /* oh oh !? */, model&amp;gt&lt;br /&gt;{&lt;br /&gt;};&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;See the declaration  of &lt;span style="font-style:italic;"&gt;class model&lt;/span&gt; ? With this declaration a "model" object can only accept a "view" object as an observer. &lt;br /&gt;&lt;br /&gt;After experimenting a bit, I was convinced that this is a bit hard to solve (at least with my current knowledge). The main problem is that your &lt;span style="font-style:italic;"&gt;&lt;span style="font-weight:bold;"&gt;concrete subject can notify only a single type of observer&lt;/span&gt;&lt;/span&gt;. If we were to use virtual functions, there would be no limitation on what type of &lt;span style="font-style:italic;"&gt;observer &lt;/span&gt;we could use with the subject as long as our &lt;span style="font-style:italic;"&gt;concrete observer&lt;/span&gt; were derived from the &lt;span style="font-style:italic;"&gt;abstract observer&lt;/span&gt;. But we don't want it because we want type-safety and performance ;). So how to achieve it ? Let's summarize everything :)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;&lt;br /&gt;Subjects can only notify a single type of observer. Moreover observers and subjects must be strongly typed so the programmer won't be able to register an observer operating on apples with a subject representing an orange :)&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;My point of view is that I should encapsulate the -operation- while satisfying the above requirements. The solution I came up with is to keep a list of &lt;span style="font-style:italic;"&gt;function objects&lt;/span&gt; representing the &lt;span style="font-style:italic;"&gt;operation - observe()&lt;/span&gt;. So here is the code for the pattern;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;// observer.hpp&lt;br /&gt;&lt;br /&gt;#ifndef OBSERVER_HPP&lt;br /&gt;#define OBSERVER_HPP&lt;br /&gt;&lt;br /&gt;#include &amp;lt list&amp;gt&lt;br /&gt;#include &amp;lt boost/bind.hpp&amp;gt&lt;br /&gt;#include &amp;lt boost/function.hpp&amp;gt&lt;br /&gt;#include &amp;lt boost/foreach.hpp&amp;gt&lt;br /&gt;&lt;br /&gt;// Forward declaration for subject&lt;br /&gt;template &amp;lt typename TSubject&amp;gt&lt;br /&gt;class subject;&lt;br /&gt;&lt;br /&gt;template &amp;lt typename TObserver, typename TSubject&amp;gt&lt;br /&gt;class observer&lt;br /&gt;{&lt;br /&gt;public:&lt;br /&gt; void observe(TSubject&amp; s)&lt;br /&gt; {&lt;br /&gt;  static_cast&amp;lt TObserver *&amp;gt(this)-&amp;gt do_observe(s);&lt;br /&gt; }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;template &amp;lt typename TSubject&amp;gt&lt;br /&gt;class subject&lt;br /&gt;{&lt;br /&gt;public:&lt;br /&gt; typedef boost::function&amp;lt void (TSubject&amp; ) &amp;gt observer_type;&lt;br /&gt;&lt;br /&gt;private:&lt;br /&gt; std::list&amp;lt  observer_type &amp;gt observers;&lt;br /&gt;&lt;br /&gt;public:&lt;br /&gt; template &amp;lt typename TObserver&amp;gt&lt;br /&gt; void add_observer(observer&amp;lt TObserver, TSubject&amp;gt&amp; o)&lt;br /&gt; {&lt;br /&gt;  observer_type o_fn = boost::bind(&amp;observer&amp;lt TObserver, TSubject&amp;gt::observe, boost::ref(o), _1);&lt;br /&gt;  observers.push_back(o_fn);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;protected:&lt;br /&gt; void notify_all()&lt;br /&gt; {&lt;br /&gt;  BOOST_FOREACH(observer_type o, observers)&lt;br /&gt;  {&lt;br /&gt;   o(boost::ref(*static_cast&amp;lt TSubject *&amp;gt(this)));&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;};&lt;br /&gt;#endif&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;STL and boost creates miracles for sure :) Let's have a look at the semantics of these templates. A &lt;span style="font-style:italic;"&gt;concrete subject&lt;/span&gt; will derive from the &lt;span style="font-style:italic;"&gt;subject&lt;/span&gt; class and when it's modified will call the &lt;span style="font-style:italic;"&gt;notify_all()&lt;/span&gt; function internally. A &lt;span style="font-style:italic;"&gt;concrete observer&lt;/span&gt; needs to derive from the &lt;span style="font-style:italic;"&gt;observer&lt;/span&gt; class and must define a &lt;span style="font-style:italic;"&gt;public do_observe()&lt;/span&gt; function which will operate on the &lt;span style="font-style:italic;"&gt;concrete subject&lt;/span&gt;. Let's see the example client code;&lt;br /&gt;&lt;br /&gt;A simple implementation of MVC pattern with our observer templates. (I promised for one pattern and you get two ! Yay ! )&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;// main.cpp&lt;br /&gt;#include &amp;lt iostream&amp;gt&lt;br /&gt;&lt;br /&gt;#include "observer.hpp"&lt;br /&gt;&lt;br /&gt;class model : public subject&amp;lt model&amp;gt&lt;br /&gt;{&lt;br /&gt;public:&lt;br /&gt; model()&lt;br /&gt; {&lt;br /&gt;  std::cout &amp;lt&amp;lt "model constructed\n";&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; void modify_model()&lt;br /&gt; {&lt;br /&gt;  this-&amp;gt notify_all();&lt;br /&gt; }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;class view : public observer&amp;lt view, model&amp;gt, public subject&amp;lt view&amp;gt&lt;br /&gt;{&lt;br /&gt;public:&lt;br /&gt; void do_observe(model&amp; m)&lt;br /&gt; {&lt;br /&gt;  std::cout &amp;lt&amp;lt "view observed the model" &amp;lt &amp;lt std::endl;&lt;br /&gt; }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;class controller : public observer&amp;lt controller, model&amp;gt, public observer&amp;lt controller, view&amp;gt&lt;br /&gt;{&lt;br /&gt;public:&lt;br /&gt; void do_observe(model&amp; m)&lt;br /&gt; {&lt;br /&gt;  std::cout &amp;lt&amp;lt "controller observed the model" &amp;lt&amp;lt std::endl;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; void do_observe(view&amp; v)&lt;br /&gt; {&lt;br /&gt;  std::cout &amp;lt&amp;lt "controller observed the view" &amp;lt&amp;lt std::endl;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt; model m;&lt;br /&gt; controller c;&lt;br /&gt; view v;&lt;br /&gt;&lt;br /&gt; m.add_observer(v);&lt;br /&gt; m.add_observer(c);&lt;br /&gt;&lt;br /&gt; v.add_observer(c);&lt;br /&gt;&lt;br /&gt; // when the model is modified all its observers will be notified&lt;br /&gt; m.modify_model();&lt;br /&gt;&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;So tell me what you think. I'm eager to hear a better solution or any suggestions to improve this one. If there are any problems with the above code that I can't see please comment so we can discuss. Thanks in advance ! :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35128052-4103441612577350977?l=neurorebel.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neurorebel.blogspot.com/feeds/4103441612577350977/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35128052&amp;postID=4103441612577350977' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/4103441612577350977'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/4103441612577350977'/><link rel='alternate' type='text/html' href='http://neurorebel.blogspot.com/2010/06/observer-pattern-in-c-without-virtual.html' title='Observer pattern in C++ (without virtual functions)'/><author><name>neurorebel</name><uri>http://www.blogger.com/profile/06965524988672935344</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_JV83xeUju9w/SQeT73jPw_I/AAAAAAAAAA8/9PiYADflIO8/S220/Picture+5.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35128052.post-5368342159621937368</id><published>2010-06-25T09:49:00.007+03:00</published><updated>2010-06-25T13:30:37.643+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='projects'/><category scheme='http://www.blogger.com/atom/ns#' term='status report'/><category scheme='http://www.blogger.com/atom/ns#' term='random thoughts'/><title type='text'>The struggle to increase productivity</title><content type='html'>Hi ! Yesterday I've installed Subversion on my computer to better manage my projects. I must say it's a relief :) The most useful thing for me so far was the ability to "branch" projects. So I can make some experimental changes without having to copy files and folders here and there. Changelogs, versioning etc. makes everything easy to track. I'm using &lt;a href="http://www.visualsvn.com/"&gt;VisualSVN&lt;/a&gt; . Very easy to setup and get going. Keeping track of what's done and what's next is what drives a project forward. Obvious... But grasping the concept requires time as usual :) . I'm using pen and paper, old fashioned and romantic in a way. Writing reports or short notes about where you are and what's your current destination is a good practice. Thanks to Peter (my boss and mentor :) ), I'm learning yet another aspect of software engineering. It's not just diagrams and documents, it's measuring the progress (which is really harder than design and documentation).&lt;br /&gt;&lt;br /&gt;Also, started to get a good grip of boost and STL. My C++ skills are increasing day by day ! If you're developing Windows applications you should definitely learn ATL and WTL (Did I ever mention this ?) . And here comes a cliché advise as usual :) Read source code !! There are so many awesome programmers who are so generous to share their work. Read some source code before you start a project. That's how I leveled up during the past few months :) . So make yourself a favor, take a cup of your favourite refreshment and visit &lt;a href="http://sourceforge.net/"&gt;SourceForge&lt;/a&gt; , &lt;a href="http://www.codeplex.com/"&gt;CodePlex&lt;/a&gt; . That's it for now. I'll just enjoy some morning coding accompanied by the sweet summer rain...&lt;br /&gt;&lt;br /&gt;Cheers !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35128052-5368342159621937368?l=neurorebel.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neurorebel.blogspot.com/feeds/5368342159621937368/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35128052&amp;postID=5368342159621937368' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/5368342159621937368'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/5368342159621937368'/><link rel='alternate' type='text/html' href='http://neurorebel.blogspot.com/2010/06/struggle-to-increase-productivity.html' title='The struggle to increase productivity'/><author><name>neurorebel</name><uri>http://www.blogger.com/profile/06965524988672935344</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_JV83xeUju9w/SQeT73jPw_I/AAAAAAAAAA8/9PiYADflIO8/S220/Picture+5.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35128052.post-2873160803003178077</id><published>2010-04-04T17:37:00.037+03:00</published><updated>2010-06-26T13:30:14.587+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='life'/><category scheme='http://www.blogger.com/atom/ns#' term='status report'/><category scheme='http://www.blogger.com/atom/ns#' term='random thoughts'/><title type='text'>A Change of Pace</title><content type='html'>Greetings from your favourite procrastinator ! I want at least a few blog entries between my two summer vacations :) . So I'll just try to give a quick status report and a boring treatise on software development hehe :)&lt;br /&gt; So, I haven't finished that game I was doing with SDL. Well, the reason is I don't want to create a stupid clone (I'm lying I have a serious problem about focusing :) ) . So I ceased working on it after 5 hours into development :) I wanted to polish my graphics programming skills for some time since GFX technology is running forward like crazy as usual and I'm so much behind all that stuff (Boy where was I ??)... So nowadays I'm focusing on DirectX 10 and making small demos without the stupid software engineering crap. And the good thing is that the practice pays off instantly ! :) Because I'm not trying to build that &lt;span style="font-style: italic;"&gt;perfect resource management system&lt;/span&gt; since I'm dealing with only a handful of resources. At the start it felt a bit weird but later on I realized that's the way it should be. This state of mind geared my brain up and let me &lt;span style="font-style: italic;"&gt;put more on the screen&lt;/span&gt;. Here is my recipé for a change of pace for all us perfectionist software benders;&lt;br /&gt; First thing to carve on your wall: &lt;span style="font-style: italic;"&gt;You can't do software engineering on your own&lt;/span&gt; nor can you do it with a few friends. I guess I lost my magic somewhere along the path when I was doing enterprise software development. It's good to study the methods and concepts of large scale software development for every individual programmer focusing on whatever specific subject (Databases, network, AI...). But individuals and small teams can only produce small scale work since large scale work is simply &lt;span style="font-style:italic;"&gt;labour intensive&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt; Think big and you're doomed to desperation with all your fancy diagrams, empty interface definitions and countless layers of abstraction even for a simple operation an a few numbers hoping that by some miraculous ignition you're going to implement all your ideas with your lightning fast fingers... Well that generally happens in movies :) It doesn't mean you should restrain your thirst for good design. Just quench it responsibly, keeping in mind that your first mission is to &lt;span style="font-style: italic;"&gt;get the job done&lt;/span&gt; :) Bear in mind that &lt;span style="font-style: italic;"&gt;software can not be created big&lt;/span&gt;. It &lt;span style="font-style: italic;"&gt;evolves&lt;/span&gt; into a bigger thing. The emerging development methods like Agile, Extreme Programming which are the craze for some time backs my conclusion I think.&lt;br /&gt;&lt;br /&gt; - But (a big fat but) -&lt;br /&gt; You should never forget that code is a valuable commodity and a human is always short of time. So you have to realize that redoing the same work you did the night before is a serious obstacle in front of your potential and productivity. There comes in the famous software engineering cliché: &lt;span style="font-style:italic;"&gt;Reusability&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt; Let's try to sketch the picture here. Every single step of your development journey must be rewarding in some way. You must get &lt;span style="font-style:italic;"&gt;results &lt;/span&gt;which can be seen with your bare eyes. In my case I'm doing graphics programming. One of the very basic tasks is to create a window for your program. You can do it in many ways and you can put countless abstractions and make it so cross-platform that even a Martian can use it to create a Pong game running on her spaceship's computer. But who cares about aliens anyway ? Just put a freakin' window onto the screen. Create a simple class to handle the usual stuff. You don't have to parameterize every single detail a window has like fonts, icons or the little system buttons on the top right. Forget them... You just want to render something and you don't need those features for a long time. Look at your code and try to get an intuition of what it does. And ask yourself the following questions:&lt;br /&gt;&lt;br /&gt; 1)Is your class easy to use ?&lt;br /&gt;&lt;br /&gt; 2)Is it up to the task ? &lt;br /&gt;      &lt;span style="font-style:italic;"&gt;e.g. creating and destroying a window without trouble&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; 3)Does the usage feel natural ?&lt;br /&gt;&lt;br /&gt; If you can find satisfactory answers to these in a glimpse of an eye then move on. Get the job done. Let's elaborate these questions but bear in mind that I'm no guru and this is just my intuition I developed during my studies and work. So my point of view might be lacking in some departments :) So... Your objects should be easy to create, you should be able to use some defaults for creation for example. If you're writing a class to handle polar coordinates add support for the necessary mathematical operations so you don't have to put in redundant and ugly code accessing public members of the class everytime you use it. Making the underlying data type templated could come in handy. Overload the arithmetic operators to be able to write natural statements. Or in the case of the windowing class put a cast operator for the OS handle type so you can directly pass your window object as a parameter to OS functions. These things sometimes don't hit the eye at first glance can make your day better in the long run. You'll see that the practice will take only a few seconds as you get used to it :)&lt;br /&gt;&lt;br /&gt;  Don't feel broken hearted if the components you develop don't seem to match their relatives grown up in an environment full of professionals who devoted decades to achieve their current experience. When you're finished with your project you'll have taken one more step towards that garden :)&lt;br /&gt;&lt;br /&gt;  Well... Random thoughts over :) I'll be moving to a better place shortly so I can put in more stuff like source code, videos etc. Also more technical articles about image processing and graphics programming are to come.&lt;br /&gt;&lt;br /&gt; Stay cool and treat nice to your debugger !&lt;br /&gt;&lt;br /&gt; neurorebel out.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35128052-2873160803003178077?l=neurorebel.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neurorebel.blogspot.com/feeds/2873160803003178077/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35128052&amp;postID=2873160803003178077' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/2873160803003178077'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/2873160803003178077'/><link rel='alternate' type='text/html' href='http://neurorebel.blogspot.com/2010/04/change-of-pace.html' title='A Change of Pace'/><author><name>neurorebel</name><uri>http://www.blogger.com/profile/06965524988672935344</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_JV83xeUju9w/SQeT73jPw_I/AAAAAAAAAA8/9PiYADflIO8/S220/Picture+5.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35128052.post-1991231903971802279</id><published>2010-01-18T02:34:00.042+02:00</published><updated>2010-01-18T04:28:24.479+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='indie gaming'/><category scheme='http://www.blogger.com/atom/ns#' term='status report'/><title type='text'>The Aftermath</title><content type='html'>It's sad that another year has passed by quitely. Nevertheless I have done good things in 2009 like forming good business connections and being involved in absolutely wonderful projects. The year 2009 had its ups and downs, and though I have little to tell, I have absolutely grown up significantly in terms of knowledge and experience. Looking forward to do much better in 2010 :).&lt;br /&gt;&lt;br /&gt;I have the occasional pile of half-finished and half-started projects on my hard-drive since I started to learn SDL and Box2D recently for quickly making small 2D games. I had so much fun during December to tell the truth. It's like reviving old days with much more freedom and power with regard to my improved skill-set and equipment. I have some code to share but you can learn much more from an ordinary SDL game making tutorial so I'll save it till I finish the "game". It won't take long, I promise :). I had trouble finding art assets that wouldn't look lame together. So I have come up with a "theme" which would involve only so much "-art-work" that even I, a stupid programmer, can cut with a litte fiddling with Photoshop hopefully...&lt;br /&gt;&lt;br /&gt;The last 2 months have been occupied by obligations at the school (exams, projects etc..) And not being the best example of a "student", I'm having a hard time dodging all the debris professors are throwing onto my feet :). &lt;br /&gt;&lt;br /&gt;By the way, if you're a coder and addicted to sci-fi/cyberpunk theme, here is your fix (if you still haven't read it) :&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.amazon.com/Snow-Crash-Bantam-Spectra-Book/dp/0553380958" target=blank&gt;&lt;img src="http://upload.wikimedia.org/wikipedia/en/1/19/Snowcrash-book-cover-uk.jpg" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;A cyber-punk thriller about a virus penetrating into the minds of hackers filled with lots of sarcasm about governments, corporations and religious cults. What more would you want ? :)&lt;br /&gt;&lt;br /&gt;Maybe you want to play a game filled with fun and gorgeous 2D artwork ? Well, here is my recipé :&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.datarealms.com/games.php"&gt;&lt;br /&gt;&lt;img src="http://www.datarealms.com/images/screenmenu.jpg" /&gt;&lt;br /&gt;&lt;/a&gt;Cortex Command feels like "Worms in real-time" with RTS elements like resource management and unit building - not to mention the nice "physics" aspect and the cyberpunk theme of the game.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://2dboy.com/games.php"&gt;&lt;br /&gt;&lt;img style="cursor:pointer; cursor:hand;width: 400px; height: 300px;" src="http://2dboy.com/blog/wp-content/uploads/2009/03/worldmap_old3a.jpg" alt="" /&gt;&lt;br /&gt;&lt;/a&gt;World of Goo is (more than) a puzzle game which will captivate even the most hard-core gamer. I hate puzzle games really... But this one is simply brilliant. With fantastic level designs, sound, music and story, it sucks you in like a giant vacuum cleaner (be waried).&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.tigsource.com/"&gt;&lt;img style="float: left; width: 100px; height: 100px;" src="http://www.derekyu.com/images/go-tigsource.gif" alt="" border=0/&gt;&lt;br /&gt;&lt;/a&gt;These are my picks of the year. Try them, buy them, spread the word. And surely there are lots of pearls to find in the sea. So remember to check out The Independent Gaming Source !&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;See you in a few weeks ;)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35128052-1991231903971802279?l=neurorebel.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neurorebel.blogspot.com/feeds/1991231903971802279/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35128052&amp;postID=1991231903971802279' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/1991231903971802279'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/1991231903971802279'/><link rel='alternate' type='text/html' href='http://neurorebel.blogspot.com/2010/01/aftermath.html' title='The Aftermath'/><author><name>neurorebel</name><uri>http://www.blogger.com/profile/06965524988672935344</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_JV83xeUju9w/SQeT73jPw_I/AAAAAAAAAA8/9PiYADflIO8/S220/Picture+5.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35128052.post-1620620868654695225</id><published>2009-10-23T05:13:00.013+03:00</published><updated>2009-10-23T05:48:57.940+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='visual studio'/><category scheme='http://www.blogger.com/atom/ns#' term='editor'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><category scheme='http://www.blogger.com/atom/ns#' term='vc++'/><title type='text'>Syntax highlighting fever</title><content type='html'>Well, just stopped by to share a tip on how you can avoid hurting your eyes while working on Visual Studio 2008. If you're coding for long hours in front of a widescreen LCD with full brightness you might be suffering some headaches like me. Check out Winterdom's nice color schemes; &lt;a href="http://winterdom.com/2007/11/vs2008colorschemes"&gt;http://winterdom.com/2007/11/vs2008colorschemes&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The only change I've made to these settings files has been decreasing the font sizes. I'd like to see more lines as it becomes harder to keep track of lengthy code files by scrolling up and down frequently. If you don't like the font sizes just open the settings file in a good editor and change the &lt;span style="font-style:italic;"&gt;FontSize&lt;/span&gt; attributes as you fancy. You can import the settings file from the &lt;span style="font-style:italic;"&gt;Tools-&gt;Import and Export Settings...&lt;/span&gt; (pretty easy eh? :) ). Do not forget to backup your current VS settings by exporting them to another file in case anything goes wrong. &lt;br /&gt;&lt;br /&gt;This is the modified DesertNights settings file I use for your convenience along with a screenshot ;)&lt;br /&gt;&lt;br /&gt;&lt;a href="http://ifile.it/v8c2ozd"&gt;http://ifile.it/v8c2ozd&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_JV83xeUju9w/SuEVz1a8exI/AAAAAAAAAC4/8oxIVsHW1Cg/s1600-h/screenshot.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 204px;" src="http://3.bp.blogspot.com/_JV83xeUju9w/SuEVz1a8exI/AAAAAAAAAC4/8oxIVsHW1Cg/s320/screenshot.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5395617808824171282" /&gt;&lt;/a&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;See you then !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35128052-1620620868654695225?l=neurorebel.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neurorebel.blogspot.com/feeds/1620620868654695225/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35128052&amp;postID=1620620868654695225' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/1620620868654695225'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/1620620868654695225'/><link rel='alternate' type='text/html' href='http://neurorebel.blogspot.com/2009/10/syntax-highlihgting-fever.html' title='Syntax highlighting fever'/><author><name>neurorebel</name><uri>http://www.blogger.com/profile/06965524988672935344</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_JV83xeUju9w/SQeT73jPw_I/AAAAAAAAAA8/9PiYADflIO8/S220/Picture+5.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_JV83xeUju9w/SuEVz1a8exI/AAAAAAAAAC4/8oxIVsHW1Cg/s72-c/screenshot.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35128052.post-7491119332563487152</id><published>2009-10-22T07:04:00.010+03:00</published><updated>2009-10-22T20:00:53.693+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='hello'/><category scheme='http://www.blogger.com/atom/ns#' term='status report'/><title type='text'>Locked &amp; Loaded</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_JV83xeUju9w/St_acBMG24I/AAAAAAAAACw/y5zCPkFM6s8/s1600-h/gemile1.jpg"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 320px; height: 240px;" src="http://4.bp.blogspot.com/_JV83xeUju9w/St_acBMG24I/AAAAAAAAACw/y5zCPkFM6s8/s320/gemile1.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5395271053503552386" /&gt;&lt;/a&gt;&lt;br /&gt;Hi there ! :)&lt;br /&gt;&lt;br /&gt;I'm in a really cheerful mood while writing this entry as you may have noticed thanks to this piece of paradise you see to the right where I've spent my summer vacation. I've been quite since July but as usual that's because of my procrastination about writing :) . Things are going great to say the least. Projects are fun, schedules are tight, coffee is hot and knowledge is growing fast. I've been teaching myself so many things for the last few months. I've already started to develop a simple 3D engine on XNA and will write more frequently after mid-term exams (I promise :) ). &lt;br /&gt;&lt;br /&gt;Upcoming entries will be about the experiences I gain while applying generic programming and template meta-programming techniques in C++ and C#. Generic programming is my sole focus nowadays really... I'm quite satisfied with my classical programming skills in C and "C++ as a better C". But I strongly feel that I need to improve my style in terms of "designing the code". As I've become quite conversant with STL, I want to take a step forward and taste the infamous Boost library which will also be a part of the language in its next iteration, namely the C++0x.&lt;br /&gt;&lt;br /&gt;A few updates on my game development adventures :)&lt;br /&gt;&lt;br /&gt;Well.. :) Still haven't produced something to show. But ! I've continued my researches and experiments as usual (but with greater patience :) ). I really got a good grip of 3D graphics programming in general. Developing a 3D engine is a rewarding process in terms of knowledge and experience but it's also sad to be aware of the fact that you can't beat CryTek as a "one man army" :) . My only purpose is to develop a simple framework which I can use to create a few simple games with. The real gain from this work will be some experience on meta-programming and knowledge about the clockwork of a 3D engine in general to suffice. &lt;br /&gt;&lt;br /&gt;Well... That's all that comes to my mind for the moment. I feel an effusive urge to hit the "Publish" button as I am out of words and feel the need to break the silence in this space ASAP :) So,&lt;br /&gt;&lt;br /&gt;See you soon ! :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35128052-7491119332563487152?l=neurorebel.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neurorebel.blogspot.com/feeds/7491119332563487152/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35128052&amp;postID=7491119332563487152' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/7491119332563487152'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/7491119332563487152'/><link rel='alternate' type='text/html' href='http://neurorebel.blogspot.com/2009/10/locked-loaded.html' title='Locked &amp; Loaded'/><author><name>neurorebel</name><uri>http://www.blogger.com/profile/06965524988672935344</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_JV83xeUju9w/SQeT73jPw_I/AAAAAAAAAA8/9PiYADflIO8/S220/Picture+5.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_JV83xeUju9w/St_acBMG24I/AAAAAAAAACw/y5zCPkFM6s8/s72-c/gemile1.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35128052.post-5681674067342131525</id><published>2009-07-24T04:07:00.013+03:00</published><updated>2009-07-24T06:12:39.824+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='life'/><title type='text'>Life, coding, summer</title><content type='html'>Wow scary ! July already ?! (well end of July). I've done quite a few things during this time but I can't decide where to start. Random thoughts are torturing my brain right at the moment. Anyways, let's pick one thing at a time in the hope of not making a mess of this peaceful space of mine :)&lt;br /&gt;&lt;br /&gt;So, I've bought a new computer !&lt;br /&gt;&lt;br /&gt;It's an Intel Core2Quad blah blah which has 2Gb DDR3 RAM, an ATI 4830 512MB Shader 4.0 graphics card, an amazing 22" widescreen Philips monitor. It's a mid-range gaming PC and I just love it to say the least :) Been gaming like hell ! Far Cry 2, Mirror's Edge, Fallout 3, you name it... A small reward of my "outsourced" skills :) As I've bragged about in my past posts, I've been working for some people based in Silicon Valley. We are developing a "stereoscopic vision" software. The prototype phase has been quite a nice adventure. I have obtained some test equipment like 3D glasses and had so much fun :) Well what's stereoscopic vision ? Ever seen a 3D movie like the latest Ice Age 3 ? That's stereoscopic vision. You get the same scene from 2 different perspectives respectively for your left and right eye and your brain handles the rest :) Quite exciting. There are many different flavors of hardware for stereoscopic 3d imagery. There are LCS shutter glasses which alternates between the left and right eyes by darkening one eye at a time. And there are special 3D displays which requires no glasses at all. But the idea is the same: "Show the same scene from two different perspective to the left and right eye respectively". I've been quite familiar with the DirectX pipeline during the project phase. Also played with OpenGL and Ogre3d engine too in my spare time. Nowadays I'm just researching, gaming and chilling out. Hopefully I'll be able to do a lot more with the knowledge I gained once I get rid of this procrastination :) &lt;br /&gt;&lt;br /&gt;Anyways, I force myself to start developing a worthy side-project solely with my own initiative but no luck :) I just can't concentrate well enough or ideas just don't feel good. I haven't been trying to come up with cool (or stupid :D ) ideas for such a long time :) Well maybe this is the problem. I'm just forcing myself to crunch the keyboard, maybe I should change my ways a little. The cure for my procrastination might be the sweet ignition of an exciting idea :) But I just can't keep it cool nowadays. Just quick bursts of motivation and boom all the concentration is gone... It's too damn hot and I'm home alone, that I suspect might be the problem... Always sleepy, talking to myself... But I really try hard to stay in line, reading, thinking and trying to understand new things.  And it pays somehow though little compared to all the hassle...&lt;br /&gt;&lt;br /&gt;Well after checking what I've written so far, I've come to the conclusion that I need a "real" vacation. Period.&lt;br /&gt;&lt;br /&gt;By the way I'm officially 25 years old as of May 31st. Hooray ! :) 25... It's like "Just do something already !!" :)) Well of course I am :) Always been... Sometimes I just forget what my big plan is. And I force my memory just to realize that there has never been such thing for me. "Just enjoy !" :)&lt;br /&gt;&lt;br /&gt;- Just enjoy !&lt;br /&gt;- "Just enjoy !" What a wonderful philosophy you have !&lt;br /&gt;&lt;br /&gt;Man, that crook from Mad Max :D&lt;br /&gt;&lt;br /&gt;Anyways... Let me grab a cup of instant tea. Ok, instantly I'm back, with a cup of tea in my hand haha ! :)&lt;br /&gt;&lt;br /&gt;And all of a sudden I'm gone ! :)&lt;br /&gt;&lt;br /&gt;See you soon !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35128052-5681674067342131525?l=neurorebel.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neurorebel.blogspot.com/feeds/5681674067342131525/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35128052&amp;postID=5681674067342131525' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/5681674067342131525'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/5681674067342131525'/><link rel='alternate' type='text/html' href='http://neurorebel.blogspot.com/2009/07/life-coding-summer.html' title='Life, coding, summer'/><author><name>neurorebel</name><uri>http://www.blogger.com/profile/06965524988672935344</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_JV83xeUju9w/SQeT73jPw_I/AAAAAAAAAA8/9PiYADflIO8/S220/Picture+5.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35128052.post-589356484363009064</id><published>2009-04-15T06:41:00.002+03:00</published><updated>2009-04-15T07:05:08.354+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='nothing much'/><category scheme='http://www.blogger.com/atom/ns#' term='hello'/><title type='text'>Sorry for the delay</title><content type='html'>Ok, it's a common phrase I use when unexpected things prevent me from making the deadline. In this case I'm employing these words to apologize for keeping the "line" "dead" for so long... Enough with word games. What did I do for the last 4 months ? Actually nothing, to tell the truth :) . But of course not !! I've been doing things, like.. Coding ?! Maybe... Yeah... I did (try to) make some improvements on past projects, got new assignments etc. Right now I'm doing some small video processing job for some Silicon Valley based company. And it's really fun though I guess I'd better not tell much about it here (till it's finished maybe). &lt;br /&gt;&lt;br /&gt;I haven't started to work on any games nor I worked on my OpenGL base code... It really breaks my heart... But I really didn't have the time. I'm doing 2 projects at the same time for now. But I hope to work hard and get my hands off those shortly... I really earned some valuable skills about DirectShow programming. Along with some knowledge about video processing. That really makes me feel good. After all it's not a bad trade-off. I know I could actually make some real progress about game development but I gained some valuable experience working off-shore. It's exciting to say the least. And I'm lucky that my employers are really good people. &lt;br /&gt;&lt;br /&gt;Anyways I've been downloading and watching TV Shows (yes I do illegal downloads, I use BitTorrent, my IP is 912.1411.285.0001). IT Crowd really rocks ! :) And I guess I'll watch another episode before sleeping. See you around ! Will write more frequently. Promise !!&lt;br /&gt;&lt;br /&gt;;P&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35128052-589356484363009064?l=neurorebel.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neurorebel.blogspot.com/feeds/589356484363009064/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35128052&amp;postID=589356484363009064' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/589356484363009064'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/589356484363009064'/><link rel='alternate' type='text/html' href='http://neurorebel.blogspot.com/2009/04/sorry-for-delay.html' title='Sorry for the delay'/><author><name>neurorebel</name><uri>http://www.blogger.com/profile/06965524988672935344</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_JV83xeUju9w/SQeT73jPw_I/AAAAAAAAAA8/9PiYADflIO8/S220/Picture+5.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35128052.post-8885945738701522707</id><published>2009-01-12T20:06:00.008+02:00</published><updated>2009-01-12T20:45:22.314+02:00</updated><title type='text'>Knock Knock !</title><content type='html'>Ok, it's been a month, a silent one to say the least :). No entries, but I've been quite busy hehe :) Final exams, projects etc.. I studied a significant amount of maths, crunched many lines of code, dreamed new things, dumped some of them, developed ideas, many of which turned out to be bulls... :) Feel like I'm on the right track, the little cute muse is flying around my head. Quite nice to feel the increasing traffic that my "Projects" directory causes on the HDD LED hehe :) (I'm really obsessive about Ctrl-S). Oh and I've recently had some pleasent moments with one of my most favourite games, Pizza Tycoon (1994) ! Yeah ! :) I've reverse engineered the GFX files and I'm planning to write a modding application. But that is a side project which I do for fun. When it starts to become something usable I'll release all the source and the information in the hope of not being sued by Microprose :\ (the game is listed as abandonware on many sites but who knows... ) Anyways this post is just to break the silence :) I'm good, alive and singing loud. Stay tuned for action :P&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35128052-8885945738701522707?l=neurorebel.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neurorebel.blogspot.com/feeds/8885945738701522707/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35128052&amp;postID=8885945738701522707' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/8885945738701522707'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/8885945738701522707'/><link rel='alternate' type='text/html' href='http://neurorebel.blogspot.com/2009/01/knock-knock.html' title='Knock Knock !'/><author><name>neurorebel</name><uri>http://www.blogger.com/profile/06965524988672935344</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_JV83xeUju9w/SQeT73jPw_I/AAAAAAAAAA8/9PiYADflIO8/S220/Picture+5.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35128052.post-1215243758375485156</id><published>2008-12-11T12:40:00.022+02:00</published><updated>2009-01-17T18:57:13.826+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='projects'/><category scheme='http://www.blogger.com/atom/ns#' term='video conferencing'/><category scheme='http://www.blogger.com/atom/ns#' term='code quality'/><category scheme='http://www.blogger.com/atom/ns#' term='directshow'/><title type='text'>A word on code quality</title><content type='html'>Hello fellow reader, and thank you for your interest in advance :). It's a nice sunny Thursday in Istanbul and I'm in the mood of chit-chatting with ya. This is about my latest project and code quality. So... I've been working on a video conferencing application for the last 25 days and successfully got my hands off the project before the deadline. The first phase was to develop the "middleware" that the application will be built on. I've developed 2 DirectShow filters to capture/push media samples on the fly. And a simple packet interchange framework along with a sample P2P video conferencing program demonstrating the usage of these.&lt;br /&gt;&lt;br /&gt;First, a crash course on DirectShow (Go RTFM if you're serious about DirectShow :) ). In DS any media stream is divided into these packages called "media samples". And these packagas run through a graph of "filters" which itself, is called a "filter graph". I assume you know about what a "graph" is. Every filter (node) in the graph is connected to each other via it's "pins". And there are shared buffers to exchange the media samples. These buffers are accessed via the IMediaSample interface as the pin's Receive() or FillBuffer() method is called. These methods are callback methods and they are called as the stream flows through the graph. So you could write a custom DS filter and for example zero-out green and blue bits of all the pixels thus leaving only the red channel of the video sample in your implementation and call it a "OhYeahRed! Filter" :) Or you could compress these pixels and put your own typeid on the header and create your own compressor codec :) Got the idea ? And an example filter graph for the clueless reader's convenience is as follows :) &lt;br /&gt;&lt;br /&gt;Suppose you have an application that just displays what your webcam captures. The DS filter graph would be like:&lt;br /&gt;&lt;br /&gt;[WebCam device filter] ---&gt; [Color Space Converter] ---&gt; [Video Renderer]&lt;br /&gt;&lt;br /&gt;WebCam device filter is a device filter around your webcam driver and &lt;br /&gt;Color space converter filter changes the format of the picture and matches them to your screen resolution. And finally the video renderer filter shows the bits in a window it exposes (It's the ancient renderer, VMR7 or VMR9 is the way to go for a nicer application)&lt;br /&gt;&lt;br /&gt;So a video conference application should basically do&lt;br /&gt;&lt;br /&gt;WebCam ---&gt; Video Compressor ---&gt; SinkFilter ---&gt; [App] .... Internet ....  [App] ---&gt; PushFilter --&gt; Decompressor --&gt; Video Renderer&lt;br /&gt;&lt;br /&gt;SinkFilter: passes all media samples captured from the upstream filter to the app with a custom COM interface.&lt;br /&gt;PushFilter: passes all media samples retrieved from the network to filter graph&lt;br /&gt;&lt;br /&gt;This is my naive approach to the problem also.&lt;br /&gt;&lt;br /&gt;Well I've developed a SinkFilter, a PushFilter, a very simple protocol (only 4 types of packets namely, audiotype, videotype, audiosample, videosample), a demo server app and a demo client app. The demo applications were developed in C#. And all the buffering work is done on these applications. I've avoided to do any complex job in the filters. Because DirectShow filters are COM objects and it's a very tedious job (though not so overwhelming but requires time) to develop a reliable buffering and synchronization mechanism on that level (with the added hassle of resource management with C++ and reference counting trouble of COM objects etc.) . The thing is, everything worked fine on my computer during my tests, but when my client tried to run the demo he ran into many error messages which I haven't bothered to handle :). Shame on me on that regard. You know the feeling when these kind of things happen. And yes, these things happen :). So I revised all the work I've done and noticed many places that could be flourished with proper error handling mechanisms thus expelling the feeling of uncertainty. While gazing at my 250 hours of keyboard crunching for a moment (which is 5 distinct projects), I realized that:&lt;br /&gt;&lt;br /&gt;The most important characteristic of high quality code is&lt;br /&gt;&lt;br /&gt;ERROR HANDLING (period)&lt;br /&gt;&lt;br /&gt;Shame on me, shame on me... :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35128052-1215243758375485156?l=neurorebel.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neurorebel.blogspot.com/feeds/1215243758375485156/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35128052&amp;postID=1215243758375485156' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/1215243758375485156'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/1215243758375485156'/><link rel='alternate' type='text/html' href='http://neurorebel.blogspot.com/2008/12/word-on-code-quality.html' title='A word on code quality'/><author><name>neurorebel</name><uri>http://www.blogger.com/profile/06965524988672935344</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_JV83xeUju9w/SQeT73jPw_I/AAAAAAAAAA8/9PiYADflIO8/S220/Picture+5.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35128052.post-3295359020195940721</id><published>2008-11-17T06:43:00.005+02:00</published><updated>2008-11-17T15:40:50.278+02:00</updated><title type='text'>These are troubled times...</title><content type='html'>Midterm exams, on-going projects and night-outs seem not to fit in 24 hours long chunks of awakeness... But I guess a little push makes the progress more significant. I'm so happy yet stressed by the amount of busy-ness I suffer nowadays. I've been hired as an outsource developer by a San Fransico based company to build a video conference application and doing quite well for the moment :). I will take the numerical analysis mid-term exam at 14:00 and woke up at 5:00am to study (yawns...). This is not the me I'm used to :). Hope it works... So anyways... I've been doing quite a wizardry (ehem ehem :) ) on the project and will try to write a nice article as I couldn't find any good references on the subject except some good yet unanswered questions on various forums. Well... As I'm sipping my cup of tea I realize that it's high time I should get into a more romantic mood with those pages of formulas :) Wish me good luck as I am always short of that... (Always complaining :P )&lt;br /&gt;&lt;br /&gt;Edit 15:38pm:&lt;br /&gt;The moment I saw Mario on the screen of the calculator banging the princess, I knew it was time to give up...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35128052-3295359020195940721?l=neurorebel.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neurorebel.blogspot.com/feeds/3295359020195940721/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35128052&amp;postID=3295359020195940721' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/3295359020195940721'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/3295359020195940721'/><link rel='alternate' type='text/html' href='http://neurorebel.blogspot.com/2008/11/these-are-troubled-times.html' title='These are troubled times...'/><author><name>neurorebel</name><uri>http://www.blogger.com/profile/06965524988672935344</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_JV83xeUju9w/SQeT73jPw_I/AAAAAAAAAA8/9PiYADflIO8/S220/Picture+5.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35128052.post-4746576134232997746</id><published>2008-11-02T05:07:00.014+02:00</published><updated>2008-11-02T06:08:21.158+02:00</updated><title type='text'>A little string matching more</title><content type='html'>Hi there !:) Just stopping by to share my 20mins of evening joy with a problem that my fellow flatmate has asked an advice about. He was doing a simple phonebook project and needed to add a nice search feature. Suppose we had records like;&lt;br /&gt;&lt;br /&gt;Name Lastname&lt;br /&gt;---- --------&lt;br /&gt;Mr   Brown&lt;br /&gt;Mrs  Brewn&lt;br /&gt;Miss Brauwn&lt;br /&gt;&lt;br /&gt;We want the program to yield all those records when the user entered "brwn". So I've just coded what pops in my mind at the very first moment... You might call it a simple heuristic analysis :P. The calc_score() function yields a score over 100:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="Cpp"&gt;&lt;br /&gt;#include &amp;lt stdio.h &amp;gt&lt;br /&gt;#include &amp;lt string.h &amp;gt&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;char ucase(const char&amp; ch)&lt;br /&gt;{&lt;br /&gt; if (ch &amp;gt= 'a')&lt;br /&gt;  return ch - ('a' - 'A');&lt;br /&gt;&lt;br /&gt; return ch;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;float calc_score(char *target, char *source)&lt;br /&gt;{&lt;br /&gt; int source_cur = 0, target_cur = 0,&lt;br /&gt;  target_len = (int)strlen(target),&lt;br /&gt;  source_len = (int)strlen(source),&lt;br /&gt;  last_match_index = -1,&lt;br /&gt;  match_score = 0, // number of matching characters&lt;br /&gt;  order_score = 0; // how many characters are ordered correctly ?&lt;br /&gt;&lt;br /&gt; float score;&lt;br /&gt;&lt;br /&gt; char subject;&lt;br /&gt;&lt;br /&gt; //if (target[0] != source[0])&lt;br /&gt; // return 0;&lt;br /&gt;&lt;br /&gt; while(source[source_cur] != 0)&lt;br /&gt; {&lt;br /&gt;  subject = source[source_cur++];&lt;br /&gt;  // search subject in target and save index&lt;br /&gt;  for ( ; target_cur &amp;lt target_len; target_cur++ )&lt;br /&gt;  {&lt;br /&gt;   if (ucase(target[target_cur]) == ucase(subject)) // one character matches&lt;br /&gt;   {&lt;br /&gt;    match_score++;&lt;br /&gt;    if (last_match_index &amp;gt= 0 &amp;&amp; last_match_index &amp;lt target_cur) // check the order of character&lt;br /&gt;     order_score++;&lt;br /&gt;&lt;br /&gt;    last_match_index = target_cur;&lt;br /&gt;&lt;br /&gt;    break;&lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; score = ((float)match_score / (float)source_len) * 0.25 + &lt;br /&gt;  ((float)order_score / (float)(source_len - 1)) * 0.75;&lt;br /&gt; &lt;br /&gt; return score;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt; char *target = "Fatih Gungor";&lt;br /&gt; char *str = "fthgngr";&lt;br /&gt;&lt;br /&gt; printf("score = %2.2f ", calc_score(target, str));&lt;br /&gt;&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Not so neat perhaps but heck... See ya' ;)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35128052-4746576134232997746?l=neurorebel.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neurorebel.blogspot.com/feeds/4746576134232997746/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35128052&amp;postID=4746576134232997746' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/4746576134232997746'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/4746576134232997746'/><link rel='alternate' type='text/html' href='http://neurorebel.blogspot.com/2008/11/little-string-matching-more.html' title='A little string matching more'/><author><name>neurorebel</name><uri>http://www.blogger.com/profile/06965524988672935344</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_JV83xeUju9w/SQeT73jPw_I/AAAAAAAAAA8/9PiYADflIO8/S220/Picture+5.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-35128052.post-8997994149261712156</id><published>2008-10-09T00:35:00.013+03:00</published><updated>2010-06-26T10:57:51.612+03:00</updated><title type='text'>Suspended suspended suspended</title><content type='html'>Ok, I've grown tired of cancelling projects but heck.. Who cares ? :) No seriously, I do care but when you are 24 things get out of control too quickly. Or at least in my case... Well, my fellow friend Cihan is unavailable for a long time (his skills as a graphics artist are to blame hehe :) ) so we kissed goodbye to ImagineCup 2009 :( Wish the best of luck to other participants from our country hehe :) Perhaps now is a good time to revise the old material on my lousy hard drive I thought. And well, digging through some stupid half-baked projects and obscure code snippets I've found some piece of fairly well organized OpenGL code. And for the following weeks it seems that I'll fiddle with it. And... I've found this website while StumbleUpon-ing which includes talks on various subjects from various people. My favourite is Clifford Stoll's talk ! He's a such an eccentric person and his talk is a must-see show :) Here's the link to the TED website:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.ted.com/"&gt;&lt;img style="cursor: pointer; width: 320px;" src="http://www.ted.com/images/ted_logo.gif" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Anyways, to get warmed up for ImagineCup I was doing an arkanoid clone with XNA to get started and... Yeah, I didn't complete it haha :) But I've learned a lot of things about general problems about collision detection. I plan to use this space as a log of my failed attempts to accomplish things since that's what's all about my life for the past few years :) Things aren't that bad in fact but small problems and obstacles getting in my way really bothers me :) So I won't be giving any promises to myself at this time. But yeah I've got some plans in my mind like that homebrew 3D graphics engine I've always wanted to develop. So I'll give it another shot. I feel really thrilled when I see that finding the correct information and putting together pieces of ideas and practices -to do something once and right- takes so much time. This is what happened to me. I've digged so many documents, talked to so many people, all those forum posts... But I really couldn't come up with the ideal development plan for a 3D engine. It's such vast subject and I hate wasting my time on redundant work... Yeah I've got little chunks of code that works, renders something, doing something on the geometry etc. But what I want to accomplish is a very clean and extensible piece of software library that will make me feel like I'm in love when I read the code or examine the documents :) Okay, since I'm done with my confession and feel comfortable with the current state of my soul, I can return to my job. You know what they say: See you later, alligator ! :P&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35128052-8997994149261712156?l=neurorebel.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neurorebel.blogspot.com/feeds/8997994149261712156/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=35128052&amp;postID=8997994149261712156' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/8997994149261712156'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/35128052/posts/default/8997994149261712156'/><link rel='alternate' type='text/html' href='http://neurorebel.blogspot.com/2008/10/suspended-suspended-suspended.html' title='Suspended suspended suspended'/><author><name>neurorebel</name><uri>http://www.blogger.com/profile/06965524988672935344</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_JV83xeUju9w/SQeT73jPw_I/AAAAAAAAAA8/9PiYADflIO8/S220/Picture+5.jpg'/></author><thr:total>1</thr:total></entry></feed>
