I'm writing an API, in which one of the function calls of which is meant to be a call to a factory for a series of tree nodes that take a number of parameters, some of which are the same and some of which are different. The kicker is that it's on the user to specify the exact structure of the tree - doing it algorithmically would go against what I'm trying to provide. The question I have is, what is the best (most intuitive, mostly) way to structure the function call? So far, my best idea is something like this:
void FooClass::createTree(
{
{2},
{4, 5},
{2, 2, 2, 2, 2, 2, 2, 2, 0}
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
},
{
{"N1"},
{"N2-1", "N2-2"},
{"N3-1", "N3-2", "N3-3", "N3-4", "N3-5", "N3-6", "N3-7", "N3-8", "N3-9"},
{"N4-1", "N4-2", "N4-3", "N4-4", "N4-5", "N4-6", "N4-7", "N4-8", "N4-9", "N4-10", "N4-11", "N4-12", "N4-13", "N4-14", "N4-15", "N4-16"}
},
other_args...
)
Where, obviously, a 0 would mean the termination of a particular branch. This is being built in C++, and is meant to be provided as part of a library function where the tree is used internally by FooClass
.
I realize that, ultimately, I'll need different calls for different combinations of varying/non-varying parameters, but what I'm stumped on is the "base case" format. I'd also like to avoid using a Builder object (as has been suggested), as the tree that is ultimately specified by the user must be constructed from the bottom up (a result of the problem domain - this is an unavoidable constraint).