Self tracking library

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

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.
Why not visit my shop?
Universal IDE:
"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