- Object Interactions
- Object Interaction Scenario in IT Management
- Example of a Mediator
- Mediator Base Class
- Mediator Subclass
- Widget Class
- Two Widget Subclasses
- LspDirector Implementation
- Widget Class Implementation
- PathWidget Class Implementation
- Putting It All Together
- Conclusion
- Additional Reading
Mediator Subclass
Listing 3 illustrates the mediator subclass, LspDirector, which is derived from ConnectionDirector. Notice that this derived class is less generic than the base class for the reasons mentioned in the previous section.
Listing 3 Mediator Class: LspDirector
class LspDirector : public ConnectionDirector { public: explicit LspDirector(int); virtual ~LspDirector(void); virtual void WidgetChanged(Widget*); virtual void CreateWidgets(); void ChangePath(char*); void ChangeQoSDetails(char*); private: int lspId; PathWidget* _lspPath; QosWidget* _qosDescriptor; };
The class LspDirector contains three private data members that relate to the dependent objects. The lspId is used to differentiate each LSP instance in the network; in other words, each LSP has its own instance ID. So, in Figure 1, LSP123 has a unique ID that differs from any other LSP in the network. The other two data members are pointers to the dependent objects (the widgets—more about them in the next section).
The two methods ChangePath() and ChangeQoSDetails() are used to apply configuration changes to the widgets. Let’s now finally see what’s in a widget!