Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > PHP/MySQL/Scripting

  • Print
  • + Share This
Like this article? We recommend

deleteNetworkObject Subclass of Command

Listing 6 illustrates an example of a delete command pattern.

Listing 6 Delete Command Pattern

class deleteNetworkObject : public Command {
  explicit deleteNetworkObject(LspConnection* lsp);
  virtual void Execute();
  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.

  • + Share This
  • 🔖 Save To Your Account