{"id":107,"date":"2008-09-03T13:52:49","date_gmt":"2008-09-03T20:52:49","guid":{"rendered":"http:\/\/162.243.68.163\/blog\/?p=107"},"modified":"2008-09-03T13:55:24","modified_gmt":"2008-09-03T20:55:24","slug":"random-code-snippet","status":"publish","type":"post","link":"https:\/\/tekhedd.com\/?p=107","title":{"rendered":"Random code snippet"},"content":{"rendered":"<pre>\/\/\r\n\/\/ Event handler for a callback that takes no parameters\r\n\/\/\r\nclass EventHandlerBase\r\n{\r\n   virtual void HandleEvent() = 0;\r\n};\r\n\r\n\/\/\r\n\/\/ T is the class that will receive callbacks\r\n\/\/ U is the method signature or something\r\n\/\/\r\ntemplate &lt;class T, class U &gt;\r\nclass EventHandler\r\n{\r\n   T _obj;\r\n   U _func;\r\n\r\npublic:\r\n   EventHandler( T * obj, U * func )\r\n      : _obj( obj ),\r\n        _func( func )\r\n   {\r\n      ;\r\n   }\r\n\r\n   void Register( T * obj, U * func )\r\n   {\r\n      _obj = obj;               \/\/ param checking?\r\n      _func = func;\r\n   }\r\n\r\n   void HandleEvent()\r\n   {\r\n      _func-&gt;obj();\r\n   }\r\n};<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/\/ \/\/ Event handler for a callback that takes no parameters \/\/ class EventHandlerBase { virtual void HandleEvent() = 0; }; \/\/ \/\/ T is the class that will receive callbacks \/\/ U is the method signature or something \/\/ template &lt;class T, class U &gt; class EventHandler { T _obj; U _func; public: EventHandler( [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[85,86],"class_list":["post-107","post","type-post","status-publish","format-standard","hentry","category-other","tag-c","tag-code"],"_links":{"self":[{"href":"https:\/\/tekhedd.com\/index.php?rest_route=\/wp\/v2\/posts\/107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tekhedd.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tekhedd.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tekhedd.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/tekhedd.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=107"}],"version-history":[{"count":4,"href":"https:\/\/tekhedd.com\/index.php?rest_route=\/wp\/v2\/posts\/107\/revisions"}],"predecessor-version":[{"id":111,"href":"https:\/\/tekhedd.com\/index.php?rest_route=\/wp\/v2\/posts\/107\/revisions\/111"}],"wp:attachment":[{"href":"https:\/\/tekhedd.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tekhedd.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tekhedd.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}