Re: custom treemodel?



Jonathon Jongsma wrote:


Why would he need to derive a class? Wouldn't the templated class be enough?


Well, the CustomTreeModel class can implement a lot of the virtual
functions (i.e. iter_next_vfunc, things like that), but it can't very
easily implement anything related to values that are stored in the
container.  For example, say you want a custom treemodel that uses
std::vector<rgb_t> where rgb_t is defined as
struct rgb_t
{
int r, g, b
}

Do you want the model to have a single column of rgb_t objects, or do
you want three columns: an red column, a green column, and a blue
column?  Unless we want to limit the CustomTreeModel to only ever
having a single column, I think we need to rely on a more-derived
class to determine how the columns are defined (i.e. it needs to
implement get_n_columns_vfunc, etc.).  This certainly makes it more
complicated, but it also makes it more flexible.  But if you have any
ideas of how to do it all in one class, I'd certainly be happy to do
it that way.

I agree with this whole heartedly. If we start making assumptions about what gets passed to this class, it starts to lose some of its use. Unless theres a very very good cause for doing so I'd recommend making any assumptions.

Even though we might be thinking of using this to wrap tree models around STL containers, whats to stop someone from passing it a linked list of some non-standard format. Or what if we wanted to do something even simpler and just pass it an NxM dimensional array?

Looks good so far. And I sure am glad I'm not the one scratching my head about virtual inheritance and GObjects...as much fun as it sounds.

Paul



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]