I'm designing a software for displaying ModelView objects based on a DataModel.
The DataModel is displayed by a ModelView object which can itself contain a bunch of ViewObjects. It is like a container of ViewObjects to constitute to a ModelView and finally display the DataModel.
These ViewObjects can be dependent of each other inside the ModelView so for instance a position of one ViewObject may depend on another.
Then also the layout of the final screen is decided based on all of the ModelViews.
These ViewObject is inherited from a common BaseView class, but the client can simply add new ViewObject types to the hierarchy by inheriting from BaseView class. These derived classes may have specific functions to them which may need to be called in order to connect them together inside a ModelView.
Could you someone give me an idea how to do this without dynamic casting?
EDIT: I have defined the following class:
class EventView // ModelView class containing
{
private:
//Pointer to BaseViews constituting to ModelView
std::shared_ptr<BaseView> m_FlowView;
std::shared_ptr<BaseView> m_SourceView;
std::shared_ptr<BaseView> m_TargetView;
std::shared_ptr<BaseView> m_WorkerView;
std::shared_ptr<TEvent> m_Model;
}
The client can inherit from BaseView a BaseView can be a line or a circle or a curve or anything else. Hence they can be totally different. In my point of view I need only just a list of BaseView objects to draw them but it is the responsability of the client code to interconnect them together and place them together. But as I will store only BaseView pointers client may need downcasting to interconnect the elements.