This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <vector> | |
#include <memory> | |
namespace fsm | |
{ | |
class StateMachine; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var util = require('gulp-util'); | |
var clean = require('gulp-clean'); | |
var jshint = require('gulp-jshint'); | |
var less = require('gulp-less'); | |
var cssnano = require('gulp-cssnano'); | |
var uglify = require('gulp-uglify'); | |
var concat = require('gulp-concat'); | |
var sourcemaps = require('gulp-sourcemaps'); | |
var browserify = require('browserify'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is how the implementation should work: | |
int main() | |
{ | |
example_handler handler; | |
concrete_manager manager; | |
manager.add_handler(handler); | |
manager.poll_events(); | |
// events are created and sent to the handler automagically! | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
IDEAS | |
http://juanchopanzacpp.wordpress.com/2013/02/24/simple-observer-pattern-implementation-c11/ | |
http://anki3d.org/cxx11-variadic-templates-part1/ | |
http://stackoverflow.com/questions/11796121/implementing-the-visitor-pattern-using-c-templates | |
http://siondream.com/blog/tag/c11/ | |
*/ | |
#include <iostream> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Button : public Notifier | |
{ | |
public: | |
void press() | |
{ | |
notify(); | |
} | |
}; | |
class TextBox : public IListener |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <set> | |
#include <algorithm> | |
class IListener | |
{ | |
public: | |
virtual void handleNotification() = 0; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// public domain | |
#ifndef INCLUDED_REVERSE_ITERATE_HPP | |
#define INCLUDED_REVERSE_ITERATE_HPP | |
/* | |
Template used for reverse iteration in C++11 range-based for loops. | |
std::vector<int> v = {1, 2, 3, 4, 5}; | |
for (auto x : reverse_iterate(v)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef INCLUDED_SINGLETON_HPP | |
#define INCLUDED_SINGLETON_HPP | |
/* | |
Singleton pattern template. Only allows one instance of the object to exist. | |
NOTE: Manual destruction must be done before program exit. Not thread-safe. | |
class Foo : public Singleton<Foo> {}; | |
Foo &foo = Foo::getRef(); | |
foo.bar(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef INCLUDED_MULTITON_HPP | |
#define INCLUDED_MULTITON_HPP | |
#include <map> | |
#include <string> | |
/* | |
Multiton pattern template. It's similar to the singleton pattern, but | |
enables multiple instances through the use of keys. | |
NOTE: Manual destruction must be done before program exit. Not thread-safe. |
NewerOlder