Author image

Exception Class Hierarchies in C++


How to program exceptions, manage error codes etc. That is the question for today.

Luckily c++ exceptions are very standard in their programming. The strategy is to create a base exception class with a name of your choosing (KeyException was mine) and then you can create subclass exception classes, nested in the various principal classes of your codebase. For example, in a game engine project you can create GraphicsException, WindowException, KeyboardException all inherit from KeyException and override the getType and what() functions to provide meaningful unambiguous errors.

Many people confuse exceptions with error codes and asserts. Which one to use and when?

There is no hard and fast rule, but I'll give you my (and many others) rule of thumb: Assertions should be used for...

Author image

KeyEngine - 3d Game Engine


Hobby DirectX11 C++ 3d game engine, with ambitions of evolving into a full fledged game engine in 98.13 billion years.

Author image

"KeyC0de Productions" intro sequence


If you've seen some of my YouTube videos you may have noticed the 12 sec intro sequence that rolls first thing.

I made this mainly using 3d Studio Max 2015 and Adobe After Effects.

To say it was tough would be an understatement, as I'm not really a modeler, animator. I just loved 3d Studio max and years ago I got the student license which allowed me to play and tinker with it to my heart's content. Same goes with After Effects, although the After Effects aspect was much simpler, required less work and after watching a few YouTube tutorials I was set.

I drew inspiration from various intros I adore such as:

  • Audio Visual Enterprises (1993)
  • Prism Entertainment (80s)
  • Gun Media (which is basically a carbon copy of Vidmark Entertainment 88)
  • Zodiac video (from 1985)
  • WWE Monday Night 1985
  • 20-20 vision (90s)

The music tune you will hear being played is a free sound from 

Author image

Aspect Oriented Programming


Aspect Oriented Programming (AOP) is a programming paradigm that aims to increase modularity by allowing the separation of cross-cutting concerns. It does so by adding additional behavior to existing code without modifying the code itself, instead separately specifying which code is modified via a 'pointcut' specification, such as “log all function calls when the function's name begins with 'set'”. This allows secondary behaviors (eg logging) to be added to a program without cluttering the meaty code that's core to the functionality.

Design

  • The AspectConfiguration specifies which aspect applies to which method of an object
  • Each aspect is essentially a method (or a separate class containing a group of those aspect-methods) written in an aspect-oriented language (or annotation, or through an idiom in an existing language).
  • Aspects are wrapped 'before', 'after' or 'around' methods. For example we...

Author image

Thread Pool


A thread pool is a software design pattern that helps programmers achieve concurrency in an optimal way. By maintaining a pool of threads ready to execute at any moment performance is increased since latency is minimized by keeping a set of threads always available; at the ready, instead of frequently starting them up and destroying them because of frequent brief tasks. Thus we avoid short lived threads which break concurrency.

All this because creating and destroying threads takes a longer time than keeping them constantly alive and waiting.

Design

  • there is an array of threads - m_pool
  • there is a FIFO queue of tasks (a Task should be a wrapper for a Callable object) - m_tasks. Task are enqueue()ed into the task queue
  • all threads are started...

Author image

Event Queue, Message Bus and Dispatcher


NOTE: I will use the terms event and message interchangeably. In some contexts there may be a minor differentiation but for this discussion it will be ignored.

Event Queue or Message Bus

Definition:

Decouple when a message or event is sent from when it is processed. - R. Nystrom

What's the easiest way to manage the connections between event listeners and event producers? You guessed it, “Event Queues”.

When an event occurs, such as user input, or an entity sending an event to another entity, it needs to be stored somewhere such that it's not lost while in transit between the source that reported the event and when the program gets around to respond to it. That “somewhere” is a queue.

New events are added (aka enqueue) to a queue of unprocessed events. And at a later time when it's convenient in the application we...

Author image

Console on a Windows GUI Application


Provision Windows C++ GUI applications with a fully featured & functional console window that you can use for logging or whatever other purpose you deem would prove useful.

I used Windows 8.1 x86_64, Visual Studio 2017 & C++17 to build the project.

Github

Github repository link.

Author image

C++ Timing


A Timer that I plan to use in a lot of projects.

Bonus: Performance log - merely an extension of the Timer entries, which is actually an array of pair<timestamp,stringLabel>. It has many uses. Find one!

Plenty of test cases to test thy mettle.

I used Windows 8.1 x86_64, Visual Studio 2017 to build the project. It should work on other platforms as well.

Github

Github repository link.

Author image

Quadcopter Drone CC3200 Radio Telemetry Project


This was my Electronics Engineering Bachelor Thesis Project (2015).

Nikos Lazaridis, Technical University of Piraeus, Greece.

Texas Instruments (T.I.) CC3200 wifi unit, acting as the telemetry intermediate between the Ground Control Station (GCS) and the APM Ardupilot flight controller on top of the QuadCopter/Drone.

The thesis is written in Greek. You can find it in Thesis_QuadcopterTelemetry_Nikos_Lazaridis_ppapag.pdf. If I get requests I may get motivated to translate it to English.

Most of the code has been written in Texas Instruments Code Composer Studio 6. I haven't tested it with updated CCS versions.

Showcase

Youtube video link.

Github

Github repository link.

Author image

C++ Vector Implementation


A C++14/17 ready allocator_traits aware Vector similar to std::vector . I made it to familiarize myself with the internals of containers in the C++ standard library.

TODO:

  • fix some obscure Iterator problems (perhaps add begin() and end() to it) - we'll see
  • shrinkToFit(#) : if current storage is larger than # Bytes, it shrinks it to # bytes
  • halfSize() shrink

I won't attempt to create a full tutorial on this, because LokiAstari has covered this in excruciating detail already - in a level I can't hope to match (check out acknowledgements section below). If you're overwhelmed with templated code check out this tutorial:

1 2 ... 7