9\refer\DesignPatterns\Factory\Debug\Factory_D.exe" Orac le connection established Press any key to continue_ Figure 33.4 Output obtained on executing factory program. // Output of the factory program is shown in Figure 33.4. 33.6 Adapter Design Pattern Overview: This pattern is very useful while handling a legacy code. With this pat- tern, no change is required when changing the front end or back end of an appli- cation. The interaction between two incompactable modules is made possible by adding an adapter to the interface and do necessary conversions to make interaction possible. Example of usage in telecom management programming: Adapter pattern is quite common in management applications were there will be legacy code that can- not be changed. Consider the scenario where a client application expects an SNMP message and the version information as two separate items while the server sends the version information in the message itself. Rather than changing the client or server, this problem can be fixed by adding an adapter that splits the message from the server to the format required by the client. Implementation: // Adapter Design Pattern // ver0.0 Jithesh Sathyan Aug 06, 2009 #include <iostream> #include <string> using namespace std; OSS Design Patterns class server_msq public: string snmpver_msg; setvalue (string msg) snmpver msg = msg; getvalue ( ) class newClient public: string version; string msg; public: setvalue() getvalue ( ) cout<<"Version: "<<version<<endl; cout << "Message: "<<msg<<endl; class adapter : public newClient public: setvalue (server_msq *obj) version = (obj->snmpver_msg).substr (0,2); msg = (obj->smpver_msg) substr (3, (obj->snmpver_ msg) length ()) getvalue ( ) cout<< "Version: "<<version<<endl; cout. "Message: "<<msg<<endl; Fundamentals of EMS, NMS and OSS/BSS "D:\desktop_08_09\refer\DesignPatterns\Adapter\Debug\Adapter.exe" Version: v2 Message: Test Message Press any key to continue Figure 33.5 Output obtained on executing adapter program. void main () server_msq *serv = new server m