Posted on 2011-05-24 13:10
Tommy Liang 阅读(215)
评论(0) 编辑 收藏 引用 所属分类:
development idea
think about the grid listeners of grid, it's so complicate that it's hard to maintain relationship and status,I think it's necessary to arose an intermediate level to cope with this;
perhaps like this:
//somewhere in A.hpp ...
Grid A("guid_a");
//somewhere else in B.hpp
Grid B("guid_b");
//somewhere else in C.hpp
Form c("guid_c");
A.AddListener("guid_b"); //why use string but not directly object pointer? because perhaps listeners is not yet valid at this runtime, this is just a registeration work
A.AddListener("guid_c");
//cope with the code when A select a row:
GridListenerHandler handler(A);
handler.HandleListeners();
//how to handle? like follow:
Context context = ...;
BOOST_FOREACH(shared_ptr<IListener> listener, InnerGetListeners())
{
listener->Execute(context);
}