Ok, I’ve got a class I’d like to release, but am stuck trying to think of a good name for it!
Basically it’s a tree node object, sort of an “XmlElement on steroids”… It contains a set of named properties (these are implemented as ‘var’ objects so they can store numbers natively rather than having to convert them to strings like xml does). Like xml, it can contain any number of sub-nodes. But its killer feature is that every operation you do to the tree (add/remove nodes, change/remove properties) is undoable. It also lets you attach listeners to any node to find out when properties or the tree structure changes. And because it’s similar in structure to XML, it can be converted to/from XML for easy storage in a readable format.
When I was writing the original Jucer the thing that was an absolute PITA was that every time I added any option that changed an item’s properties, I had to write an UndoableAction class to implement it - this took ages and made the code really bloated and unreadable. But using one of these trees, it’d handle all of that for you, and it’d be a breeze to build powerful editors for complex structures.
So it’s a cool class, but what should I call it!? VarTree, SmartNode, VarNode, Node, SmartTree, PowerTree… ? All a bit naff… Ideas please!
I think it’d be a good idea for it to have methods to load/save it as either JSON/XML/binary. Not sure if it’d be appropriate for loading 3rd party JSON data, as it’s probably not an exact mapping for the JSON grammar.
DataNode or PropertyNode sounds good, but since it is smart enough to support undo-redo SmartDataNode
could be worth while.