- Takeaway
- A Network of Interest
- Dedicated Network Path
- Creating the LSP
- An LSP is Born
- Command Base Class
- deleteNetworkObject Subclass of Command
- The LSP Is Created and Later Deleted Using the Command Pattern
- Conclusion
- Additional Reading
deleteNetworkObject Subclass of Command
Listing 6 illustrates an example of a delete command pattern.
Listing 6 Delete Command Pattern
class deleteNetworkObject : public Command { public: explicit deleteNetworkObject(LspConnection* lsp); ~deleteNetworkObject(); virtual void Execute(); private: LspConnection* connection; }; deleteNetworkObject::deleteNetworkObject(LspConnection* lsp) { connection = lsp; }
An instance of deleteNetworkObject is passed a pointer to an instance of LspConnection. The constructor for deleteNetworkObject simply stores the LspConnection pointer passed to it, which will be used in the Execute() method, as illustrated in Listing 7.
Listing 7 Execution of a Delete Operation
void deleteNetworkObject::Execute() { //Delete the LSP components starting with the LSP printf("Deleting LSP ID %d\n", connection->getLspId()); //Specialized code here for LSP deletion //Delete the LSP preference printf("Deleting LSP Preference %d\n", connection->getLspPreference()); //Specialized code here for LSP preference deletion //Delete the LSP path ID printf("Deleting LSP Path ID %d\n", connection->getLspPathId()); //Specialized code here for LSP path deletion }
As you can see in Listing 7, I enumerate the entities for deletion, followed by a comment indicating that specialized code is required to remove them from the network. This typically amounts to calling an API that provides access to some protocol. The latter can be SNMP or some proprietary means.