Self tracking library

Post Reply
User avatar
majenko
Site Admin
Posts: 2188
Joined: Wed Nov 09, 2011 7:51 pm
Location: UK
Contact:

Self tracking library

Post by majenko » Wed Nov 20, 2013 1:07 pm

I have just written a little piece on my blog about how a class in a library can be made to keep track of any objects of that class you create in your sketch. It's a very useful trick which can make object management an absolute breeze.

By using a combination of static member functions and variables, and linked lists, you can make a library maintain its own list of defined objects so it is able to perform operations on all those objects, or maybe such things as find an object by some other reference than it's pointer.

As an example I take a small rotary encoder library I wrote last night which keeps track of the encoders you have defined so it can attach itself to change notification interrupts properly.

http://hacking.majenko.co.uk/self-tracking-library
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".

Post Reply