Disable Effect


I've been making a lot of progress on the CDMB recently! I almost have enough templates created to build a library I can code against. So far, the CDMB has three different "member templates" that you can use to give functionality to the classes you define. Each template also takes some of it's own parameters to suit particular uses.

  • Atom - An immutable primitive. These variables can only be set once by the client. They are intended to be set at object creation time, and from then on may only be read by the client.
  • Flagset - A set of boolean flags, neatly stored in packed form, with definable enumerated key values used to set or read them.
  • Multiclass - This template provides functionality for creating one-to-many relationships between classes. The basis of this is on the "one" side, there is a container like an std::vector or a python list of references to objects on the "many" side.

And now to discuss this blog posts namesake. There is a convenience feature that I had planned to add to the generated libraries, where the Multiclass template is used, which I'll describe for you:

Let's say you have a class Node, which has a one-to-many relationship with itself, provided by the Multiclass template. The collection of child nodes, we'll call children. Let's also pretend that Nodes have another function called doStuff().

// Tell a single Node to doStuff() -- easy

// Iterate over all the children and tell them to doStuff();
for(Node::iterator it = node.children().begin(); it != node.children().end(); ++it) {

// My convenience feature which would do the same as above:

Now, before you get too worried about why this is a bad idea, what is wrong with my code above, whether it is useful or not, and so on -- Does this have a name? A container inheriting the functions of the contained class, and making them act across the whole container? 

blog comments powered by Disqus